@Test public void testJWTNoEncryption() throws Exception { Date previous = new Date(System.currentTimeMillis() - 10000000000L); String token = loginJWTTokenHandler .createTokenForEPerson(context, new MockHttpServletRequest(), previous, new ArrayList<>()); SignedJWT signedJWT = SignedJWT.parse(token); String personId = (String) signedJWT.getJWTClaimsSet().getClaim(EPersonClaimProvider.EPERSON_ID); assertEquals("epersonID", personId); }
public String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate, List<Group> groups) throws JOSEException, SQLException { if (StringUtils.isNotBlank(request.getParameter(AUTHORIZATION_TOKEN_PARAMETER))) { throw new AccessDeniedException("Short lived tokens can't be used to generate other tokens"); } EPerson ePerson = updateSessionSalt(context, previousLoginDate); JWTClaimsSet claimsSet = buildJwtClaimsSet(context, request); SignedJWT signedJWT = createSignedJWT(request, ePerson, claimsSet); String token; if (isEncryptionEnabled()) { token = encryptJWT(signedJWT).serialize(); } else { token = signedJWT.serialize(); } return token; }
JWTTokenHandler { public String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate, List<Group> groups) throws JOSEException, SQLException { if (StringUtils.isNotBlank(request.getParameter(AUTHORIZATION_TOKEN_PARAMETER))) { throw new AccessDeniedException("Short lived tokens can't be used to generate other tokens"); } EPerson ePerson = updateSessionSalt(context, previousLoginDate); JWTClaimsSet claimsSet = buildJwtClaimsSet(context, request); SignedJWT signedJWT = createSignedJWT(request, ePerson, claimsSet); String token; if (isEncryptionEnabled()) { token = encryptJWT(signedJWT).serialize(); } else { token = signedJWT.serialize(); } return token; } }
JWTTokenHandler { public String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate, List<Group> groups) throws JOSEException, SQLException { if (StringUtils.isNotBlank(request.getParameter(AUTHORIZATION_TOKEN_PARAMETER))) { throw new AccessDeniedException("Short lived tokens can't be used to generate other tokens"); } EPerson ePerson = updateSessionSalt(context, previousLoginDate); JWTClaimsSet claimsSet = buildJwtClaimsSet(context, request); SignedJWT signedJWT = createSignedJWT(request, ePerson, claimsSet); String token; if (isEncryptionEnabled()) { token = encryptJWT(signedJWT).serialize(); } else { token = signedJWT.serialize(); } return token; }  }
JWTTokenHandler { public String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate, List<Group> groups) throws JOSEException, SQLException { if (StringUtils.isNotBlank(request.getParameter(AUTHORIZATION_TOKEN_PARAMETER))) { throw new AccessDeniedException("Short lived tokens can't be used to generate other tokens"); } EPerson ePerson = updateSessionSalt(context, previousLoginDate); JWTClaimsSet claimsSet = buildJwtClaimsSet(context, request); SignedJWT signedJWT = createSignedJWT(request, ePerson, claimsSet); String token; if (isEncryptionEnabled()) { token = encryptJWT(signedJWT).serialize(); } else { token = signedJWT.serialize(); } return token; }  EPerson parseEPersonFromToken(String token, HttpServletRequest request, Context context); String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate,
                                        List<Group> groups); void invalidateToken(String token, HttpServletRequest request, Context context); String getJwtKey(); boolean getIncludeIP(); long getExpirationPeriod(); boolean isEncryptionEnabled(); boolean getCompressionEnabled(); byte[] getEncryptionKey(); }
JWTTokenHandler { public String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate, List<Group> groups) throws JOSEException, SQLException { if (StringUtils.isNotBlank(request.getParameter(AUTHORIZATION_TOKEN_PARAMETER))) { throw new AccessDeniedException("Short lived tokens can't be used to generate other tokens"); } EPerson ePerson = updateSessionSalt(context, previousLoginDate); JWTClaimsSet claimsSet = buildJwtClaimsSet(context, request); SignedJWT signedJWT = createSignedJWT(request, ePerson, claimsSet); String token; if (isEncryptionEnabled()) { token = encryptJWT(signedJWT).serialize(); } else { token = signedJWT.serialize(); } return token; }  EPerson parseEPersonFromToken(String token, HttpServletRequest request, Context context); String createTokenForEPerson(Context context, HttpServletRequest request, Date previousLoginDate,
                                        List<Group> groups); void invalidateToken(String token, HttpServletRequest request, Context context); String getJwtKey(); boolean getIncludeIP(); long getExpirationPeriod(); boolean isEncryptionEnabled(); boolean getCompressionEnabled(); byte[] getEncryptionKey();  }