fix partey tags
This commit is contained in:
@@ -59,7 +59,7 @@ public class JwtKeyManager {
|
||||
/**
|
||||
* Gets the jwk set.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param createDefault the create default
|
||||
* @return the jwk set
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ public class JwtKeyManager {
|
||||
/**
|
||||
* Gets the latest.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param createDefault the create default
|
||||
* @return the latest
|
||||
*/
|
||||
@@ -140,6 +140,13 @@ public class JwtKeyManager {
|
||||
return jwtKeyRepository.findOne(qJwtKey.keyID.eq(keyID)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by created.
|
||||
*
|
||||
* @param name the name
|
||||
* @param created the created
|
||||
* @return the by created
|
||||
*/
|
||||
@Transactional
|
||||
public JwtKey getByCreated(String name, Instant created) {
|
||||
return jwtKeyRepository
|
||||
@@ -229,7 +236,7 @@ public class JwtKeyManager {
|
||||
/**
|
||||
* Gets the jws algorithm.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param createDefault the create default
|
||||
* @return the jws algorithm
|
||||
*/
|
||||
|
||||
@@ -24,8 +24,7 @@ import de.bstly.we.jwt.model.JwtKey;
|
||||
import de.bstly.we.model.User;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
* The Class JwtUserManager.
|
||||
*/
|
||||
@Component
|
||||
public class JwtUserManager {
|
||||
@@ -37,6 +36,16 @@ public class JwtUserManager {
|
||||
|
||||
public static final String JWT_USER_DATA_KEY_NAME = "user";
|
||||
|
||||
/**
|
||||
* Creates the signed jwt.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param data the data
|
||||
* @param issuer the issuer
|
||||
* @param lifetime the lifetime
|
||||
* @return the signed JWT
|
||||
* @throws JOSEException the JOSE exception
|
||||
*/
|
||||
public SignedJWT createSignedJwt(Long userId, Object data, String issuer, Long lifetime)
|
||||
throws JOSEException {
|
||||
User user = userManager.get(userId);
|
||||
@@ -72,6 +81,14 @@ public class JwtUserManager {
|
||||
return jwt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify.
|
||||
*
|
||||
* @param jwt the jwt
|
||||
* @return true, if successful
|
||||
* @throws JOSEException the JOSE exception
|
||||
* @throws ParseException the parse exception
|
||||
*/
|
||||
public boolean verify(SignedJWT jwt) throws JOSEException, ParseException {
|
||||
if (jwt.getHeader() == null || !StringUtils.hasText(jwt.getHeader().getKeyID())) {
|
||||
throw new KeySourceException("No KeyID provided!");
|
||||
|
||||
@@ -27,8 +27,7 @@ import de.bstly.we.controller.support.EntityResponseStatusException;
|
||||
import de.bstly.we.jwt.businesslogic.JwtUserManager;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
* The Class JwtUserDataController.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jwt/user")
|
||||
@@ -40,6 +39,12 @@ public class JwtUserDataController extends BaseController {
|
||||
@Value("${bstly.we.jwtUserIssuer:}")
|
||||
private String jwtUserIssuer;
|
||||
|
||||
/**
|
||||
* Creates the signed jwt auth.
|
||||
*
|
||||
* @param request the request
|
||||
* @return the string
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping("/auth")
|
||||
public String createSignedJwtAuth(HttpServletRequest request) {
|
||||
@@ -62,6 +67,13 @@ public class JwtUserDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the signed jwt.
|
||||
*
|
||||
* @param data the data
|
||||
* @param request the request
|
||||
* @return the string
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping("/create")
|
||||
public String createSignedJwt(@RequestBody Object data, HttpServletRequest request) {
|
||||
@@ -84,6 +96,14 @@ public class JwtUserDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verfiy.
|
||||
*
|
||||
* @param serialized the serialized
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
* @return the object
|
||||
*/
|
||||
@PostMapping("verify")
|
||||
public Object verfiy(@RequestBody String serialized, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
Reference in New Issue
Block a user