use of org.pac4j.jwt.config.encryption.SecretEncryptionConfiguration in project cas by apereo.
the class TokenAuthenticationActionTests method verifyAction.
@Test
public void verifyAction() throws Exception {
val g = new JwtGenerator();
g.setSignatureConfiguration(new SecretSignatureConfiguration(SIGNING_SECRET, JWSAlgorithm.HS256));
g.setEncryptionConfiguration(new SecretEncryptionConfiguration(ENCRYPTION_SECRET, JWEAlgorithm.DIR, EncryptionMethod.A192CBC_HS384));
val profile = new CommonProfile();
profile.setId("casuser");
profile.addAttribute("uid", "uid");
profile.addAttribute("givenName", "CASUser");
profile.addAttribute("memberOf", CollectionUtils.wrapSet("system", "cas", "admin"));
val token = g.generate(profile);
val request = new MockHttpServletRequest();
request.addHeader(TokenConstants.PARAMETER_NAME_TOKEN, token);
val context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService("https://example.token.org"));
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, this.action.getObject().execute(context).getId());
}
Aggregations