Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ApplicationScoped
- public class TokenManager {
- public String createToken(final CreateTokenRequest createTokenRequest, final User user) {
- final Instant now = Instant.now();
- try {
- return JwtBuilder.create("jwtBuilder")
- .subject(user.getName())
- .expirationTime(
- now.plusMillis(createTokenRequest.getValidityDurationMillis()).getEpochSecond()
- )
- .claim(“upn”, user.getName())
- .claim(“groups”, createTokenRequest.getRoles())
- .buildJwt()
- .compact();
- } catch (final JwtException | InvalidBuilderException | InvalidClaimException e) {
- throw new IllegalStateException("could not create JWT", e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement