@Test @WithMockUserContext(userName = TEST_USER_NAME, userId = TEST_USER_ID, groups = TEST_GROUP, orgUnitId = TEST_ORG_UNIT_ID) public void testIssueToken() { JwtRawToken token = authManager.issueTokenForCurrentUser(null); JwtTokenClaims claims = jwtTokenVerifier.readClaims(token.getToken()); Assert.assertEquals(TEST_USER_NAME, claims.getUserName()); Assert.assertEquals(TEST_USER_ID, claims.getUserId().longValue()); }
public JwtRawToken issueTokenForCurrentUser(Long expiration) { Object principal = getPrincipal(); if (principal instanceof UserContext) { return new JwtRawToken(jwtTokenGenerator.encodeToken(((UserContext) principal).toClaims(), expiration)); } else { return new JwtRawToken(jwtTokenGenerator.encodeToken(new UserContext(principal.toString()).toClaims(), expiration)); } }
AuthManager { public JwtRawToken issueTokenForCurrentUser(Long expiration) { Object principal = getPrincipal(); if (principal instanceof UserContext) { return new JwtRawToken(jwtTokenGenerator.encodeToken(((UserContext) principal).toClaims(), expiration)); } else { return new JwtRawToken(jwtTokenGenerator.encodeToken(new UserContext(principal.toString()).toClaims(), expiration)); } } }
AuthManager { public JwtRawToken issueTokenForCurrentUser(Long expiration) { Object principal = getPrincipal(); if (principal instanceof UserContext) { return new JwtRawToken(jwtTokenGenerator.encodeToken(((UserContext) principal).toClaims(), expiration)); } else { return new JwtRawToken(jwtTokenGenerator.encodeToken(new UserContext(principal.toString()).toClaims(), expiration)); } } @Autowired  AuthManager(JwtTokenGenerator jwtTokenGenerator); }
AuthManager { public JwtRawToken issueTokenForCurrentUser(Long expiration) { Object principal = getPrincipal(); if (principal instanceof UserContext) { return new JwtRawToken(jwtTokenGenerator.encodeToken(((UserContext) principal).toClaims(), expiration)); } else { return new JwtRawToken(jwtTokenGenerator.encodeToken(new UserContext(principal.toString()).toClaims(), expiration)); } } @Autowired  AuthManager(JwtTokenGenerator jwtTokenGenerator); UserContext getUserContext(); String getAuthorizedUser(); JwtRawToken issueTokenForCurrentUser(Long expiration); }
AuthManager { public JwtRawToken issueTokenForCurrentUser(Long expiration) { Object principal = getPrincipal(); if (principal instanceof UserContext) { return new JwtRawToken(jwtTokenGenerator.encodeToken(((UserContext) principal).toClaims(), expiration)); } else { return new JwtRawToken(jwtTokenGenerator.encodeToken(new UserContext(principal.toString()).toClaims(), expiration)); } } @Autowired  AuthManager(JwtTokenGenerator jwtTokenGenerator); UserContext getUserContext(); String getAuthorizedUser(); JwtRawToken issueTokenForCurrentUser(Long expiration); static final String UNAUTHORIZED_USER; }