public String constructToken(long iat, String jti) { Map<String, Object> claims = new HashMap<>(); claims.put("iat", iat); claims.put("application_id", this.applicationId); claims.put("jti", jti); JWTSigner.Options options = new JWTSigner.Options() .setAlgorithm(Algorithm.RS256); return this.signer.sign(claims, options); }
claims.put(Claims.LASTNAME, userDetails.getLastname()); final JWTSigner.Options options = new JWTSigner.Options(); options.setExpirySeconds(environment.getProperty("jwt.expire-after", Integer.class, DEFAULT_JWT_EXPIRE_AFTER)); options.setIssuedAt(true); options.setJwtId(true);
claims.put(Claims.LASTNAME, userDetails.getLastname()); final JWTSigner.Options options = new JWTSigner.Options(); options.setExpirySeconds(environment.getProperty("jwt.expire-after", Integer.class, DEFAULT_JWT_EXPIRE_AFTER)); options.setIssuedAt(true); options.setJwtId(true);
switch (this.options.getAlgorithm()) { case RS256: final PemReader pemParser = new PemReader(new StringReader(key)); throw new AuthenticationException("Unsupported algorithm '" + this.options.getAlgorithm().getValue() + "', this must be 'RS256'");
claims.put(JWTHelper.Claims.LASTNAME, user.getLastname()); final JWTSigner.Options options = new JWTSigner.Options(); options.setExpirySeconds(environment.getProperty("jwt.expire-after", Integer.class, DEFAULT_JWT_EXPIRE_AFTER)); options.setIssuedAt(true); options.setJwtId(true);
this.options.setAlgorithm(algorithm); this.options.setExpirySeconds(300); // 5 minutes expiration time this.options.setIssuedAt(true);
claims.put(JWTHelper.Claims.LASTNAME, user.getLastname()); final JWTSigner.Options options = new JWTSigner.Options(); options.setExpirySeconds(environment.getProperty("jwt.expire-after", Integer.class, DEFAULT_JWT_EXPIRE_AFTER)); options.setIssuedAt(true); options.setJwtId(true);
private Map<String, Object> getTokenRegistrationParams(final UserEntity userEntity, final String portalUri) { // generate a JWT to store user's information and for security purpose final Map<String, Object> claims = new HashMap<>(); claims.put(Claims.ISSUER, environment.getProperty("jwt.issuer", DEFAULT_JWT_ISSUER)); claims.put(Claims.SUBJECT, userEntity.getId()); claims.put(Claims.EMAIL, userEntity.getEmail()); claims.put(Claims.FIRSTNAME, userEntity.getFirstname()); claims.put(Claims.LASTNAME, userEntity.getLastname()); final JWTSigner.Options options = new JWTSigner.Options(); options.setExpirySeconds(environment.getProperty("user.creation.token.expire-after", Integer.class, DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER)); options.setIssuedAt(true); options.setJwtId(true); // send a confirm email with the token final String jwtSecret = environment.getProperty("jwt.secret"); if (jwtSecret == null || jwtSecret.isEmpty()) { throw new IllegalStateException("JWT secret is mandatory"); } final String token = new JWTSigner(jwtSecret).sign(claims, options); String portalUrl = environment.getProperty("portalURL"); if (portalUrl!= null && portalUrl.endsWith("/")) { portalUrl = portalUrl.substring(0, portalUrl.length() - 1); } String registrationUrl = portalUrl + portalUri + token; return new NotificationParamsBuilder() .user(userEntity) .token(token) .registrationUrl(registrationUrl) .build(); }
private Map<String, Object> getTokenRegistrationParams(final UserEntity userEntity, final String portalUri) { // generate a JWT to store user's information and for security purpose final Map<String, Object> claims = new HashMap<>(); claims.put(Claims.ISSUER, environment.getProperty("jwt.issuer", DEFAULT_JWT_ISSUER)); claims.put(Claims.SUBJECT, userEntity.getId()); claims.put(Claims.EMAIL, userEntity.getEmail()); claims.put(Claims.FIRSTNAME, userEntity.getFirstname()); claims.put(Claims.LASTNAME, userEntity.getLastname()); final JWTSigner.Options options = new JWTSigner.Options(); options.setExpirySeconds(environment.getProperty("user.creation.token.expire-after", Integer.class, DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER)); options.setIssuedAt(true); options.setJwtId(true); // send a confirm email with the token final String jwtSecret = environment.getProperty("jwt.secret"); if (jwtSecret == null || jwtSecret.isEmpty()) { throw new IllegalStateException("JWT secret is mandatory"); } final String token = new JWTSigner(jwtSecret).sign(claims, options); String portalUrl = environment.getProperty("portalURL"); if (portalUrl!= null && portalUrl.endsWith("/")) { portalUrl = portalUrl.substring(0, portalUrl.length() - 1); } String registrationUrl = portalUrl + portalUri + token; return new NotificationParamsBuilder() .user(userEntity) .token(token) .registrationUrl(registrationUrl) .build(); }
public DcosAuthImpl(final StringCredentials credentials) { this( credentials, new JWTSigner.Options(), ContentType.APPLICATION_JSON, HttpClientBuilder.create(), new HttpClientContext() ); }