test_class.declarator: jwtTokenUtil
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private JwtTokenUtil jwtTokenUtil;
test_class.type: JwtTokenUtil
test_class.var_name: jwtTokenUtil
test_class.file: trading-webapp/src/test/java/fr/ymanvieu/trading/webapp/jwt/JwtTokenUtilTest.java
test_class.identifier: JwtTokenUtilTest
test_case.body: @Test
  	public void testGenerateToken() throws Exception {
  		// GIVEN
  		Instant start = Instant.now().minusSeconds(1);
  		User userDetails = new User("username", "", asList(new SimpleGrantedAuthority("USER"), new SimpleGrantedAuthority("ADMIN")));
  		Duration expiration = Duration.ofMinutes(30);
  		
  		// WHEN
  		String token = jwtTokenUtil.generateToken(userDetails);
  		
  		
  		// THEN
  		assertThat(jwtTokenUtil.getUsernameFromToken(token)).isEqualTo("username");
  		assertThat(jwtTokenUtil.getIssuedAtDateFromToken(token)).isBetween(start, Instant.now());
  		assertThat(jwtTokenUtil.getExpirationDateFromToken(token)).isBetween(start.plus(expiration), Instant.now().plus(expiration));
  	
  
  		String[] roles = jwtTokenUtil.getClaimFromToken(token, c -> c.get(JwtTokenUtil.CLAIM_KEY_ROLES, String.class)).split(JwtTokenUtil.ROLES_CLAIM_DELIMITER);
  		
  		assertThat(roles).containsExactlyInAnyOrder("ADMIN", "USER");	
  	}
test_case.class_method_signature: JwtTokenUtilTest.testGenerateToken()
test_case.full_signature: @Test public void testGenerateToken()
test_case.identifier: testGenerateToken
test_case.invocations: minusSeconds now asList ofMinutes generateToken isEqualTo assertThat getUsernameFromToken isBetween assertThat getIssuedAtDateFromToken now isBetween assertThat getExpirationDateFromToken plus plus now split getClaimFromToken get containsExactlyInAnyOrder assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGenerateToken()
focal_class.declarator: CLAIM_KEY_ROLES = "roles"
focal_class.modifier: static final
focal_class.original_string: static final String CLAIM_KEY_ROLES = "roles";
focal_class.type: String
focal_class.var_name: CLAIM_KEY_ROLES
focal_class.declarator: ROLES_CLAIM_DELIMITER = ","
focal_class.modifier: static final
focal_class.original_string: static final String ROLES_CLAIM_DELIMITER = ",";
focal_class.type: String
focal_class.var_name: ROLES_CLAIM_DELIMITER
focal_class.declarator: jwtConfig
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private JwtProperties jwtConfig;
focal_class.type: JwtProperties
focal_class.var_name: jwtConfig
focal_class.file: trading-webapp/src/main/java/fr/ymanvieu/trading/webapp/jwt/JwtTokenUtil.java
focal_class.identifier: JwtTokenUtil
focal_class.class_method_signature: JwtTokenUtil.getUsernameFromToken(String token)
focal_class.full_signature: public String getUsernameFromToken(String token)
focal_class.identifier: getUsernameFromToken
focal_class.modifiers: public
focal_class.parameters: (String token)
focal_class.return: String
focal_class.signature: String getUsernameFromToken(String token)
focal_class.class_method_signature: JwtTokenUtil.getIssuedAtDateFromToken(String token)
focal_class.full_signature: public Instant getIssuedAtDateFromToken(String token)
focal_class.identifier: getIssuedAtDateFromToken
focal_class.modifiers: public
focal_class.parameters: (String token)
focal_class.return: Instant
focal_class.signature: Instant getIssuedAtDateFromToken(String token)
focal_class.class_method_signature: JwtTokenUtil.getExpirationDateFromToken(String token)
focal_class.full_signature: public Instant getExpirationDateFromToken(String token)
focal_class.identifier: getExpirationDateFromToken
focal_class.modifiers: public
focal_class.parameters: (String token)
focal_class.return: Instant
focal_class.signature: Instant getExpirationDateFromToken(String token)
focal_class.class_method_signature: JwtTokenUtil.getClaimFromToken(String token, Function<Claims, T> claimsResolver)
focal_class.full_signature: public T getClaimFromToken(String token, Function<Claims, T> claimsResolver)
focal_class.identifier: getClaimFromToken
focal_class.modifiers: public
focal_class.parameters: (String token, Function<Claims, T> claimsResolver)
focal_class.return: T
focal_class.signature: T getClaimFromToken(String token, Function<Claims, T> claimsResolver)
focal_class.class_method_signature: JwtTokenUtil.getAllClaimsFromToken(String token)
focal_class.full_signature: private Claims getAllClaimsFromToken(String token)
focal_class.identifier: getAllClaimsFromToken
focal_class.modifiers: private
focal_class.parameters: (String token)
focal_class.return: Claims
focal_class.signature: Claims getAllClaimsFromToken(String token)
focal_class.class_method_signature: JwtTokenUtil.isTokenExpired(String token)
focal_class.full_signature: private Boolean isTokenExpired(String token)
focal_class.identifier: isTokenExpired
focal_class.modifiers: private
focal_class.parameters: (String token)
focal_class.return: Boolean
focal_class.signature: Boolean isTokenExpired(String token)
focal_class.class_method_signature: JwtTokenUtil.isCreatedBeforeLastPasswordReset(Instant created, Instant lastPasswordReset)
focal_class.full_signature: private Boolean isCreatedBeforeLastPasswordReset(Instant created, Instant lastPasswordReset)
focal_class.identifier: isCreatedBeforeLastPasswordReset
focal_class.modifiers: private
focal_class.parameters: (Instant created, Instant lastPasswordReset)
focal_class.return: Boolean
focal_class.signature: Boolean isCreatedBeforeLastPasswordReset(Instant created, Instant lastPasswordReset)
focal_class.class_method_signature: JwtTokenUtil.generateToken(UserDetails userDetails)
focal_class.full_signature: public String generateToken(UserDetails userDetails)
focal_class.identifier: generateToken
focal_class.modifiers: public
focal_class.parameters: (UserDetails userDetails)
focal_class.return: String
focal_class.signature: String generateToken(UserDetails userDetails)
focal_class.class_method_signature: JwtTokenUtil.doGenerateToken(String subject, Map<String, Object> claims)
focal_class.full_signature: private String doGenerateToken(String subject, Map<String, Object> claims)
focal_class.identifier: doGenerateToken
focal_class.modifiers: private
focal_class.parameters: (String subject, Map<String, Object> claims)
focal_class.return: String
focal_class.signature: String doGenerateToken(String subject, Map<String, Object> claims)
focal_class.class_method_signature: JwtTokenUtil.canTokenBeRefreshed(String token, Instant lastPasswordReset)
focal_class.full_signature: public Boolean canTokenBeRefreshed(String token, Instant lastPasswordReset)
focal_class.identifier: canTokenBeRefreshed
focal_class.modifiers: public
focal_class.parameters: (String token, Instant lastPasswordReset)
focal_class.return: Boolean
focal_class.signature: Boolean canTokenBeRefreshed(String token, Instant lastPasswordReset)
focal_class.class_method_signature: JwtTokenUtil.generateRefreshToken(String subject)
focal_class.full_signature: public String generateRefreshToken(String subject)
focal_class.identifier: generateRefreshToken
focal_class.modifiers: public
focal_class.parameters: (String subject)
focal_class.return: String
focal_class.signature: String generateRefreshToken(String subject)
focal_class.class_method_signature: JwtTokenUtil.validateToken(String token, UserDetails userDetails)
focal_class.full_signature: public Boolean validateToken(String token, UserDetails userDetails)
focal_class.identifier: validateToken
focal_class.modifiers: public
focal_class.parameters: (String token, UserDetails userDetails)
focal_class.return: Boolean
focal_class.signature: Boolean validateToken(String token, UserDetails userDetails)
focal_class.class_method_signature: JwtTokenUtil.getGrantedAuthoritiesFromToken(String authToken)
focal_class.full_signature: public Collection<? extends GrantedAuthority> getGrantedAuthoritiesFromToken(String authToken)
focal_class.identifier: getGrantedAuthoritiesFromToken
focal_class.modifiers: public
focal_class.parameters: (String authToken)
focal_class.return: Collection<? extends GrantedAuthority>
focal_class.signature: Collection<? extends GrantedAuthority> getGrantedAuthoritiesFromToken(String authToken)
focal_method.body: public String generateToken(UserDetails userDetails) {
          Map<String, Object> claims = new HashMap<>();
          claims.put(CLAIM_KEY_ROLES, userDetails.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(joining(ROLES_CLAIM_DELIMITER)));
          
          log.info("generateToken()");
          
          return doGenerateToken(userDetails.getUsername(), claims);
      }
focal_method.class_method_signature: JwtTokenUtil.generateToken(UserDetails userDetails)
focal_method.full_signature: public String generateToken(UserDetails userDetails)
focal_method.identifier: generateToken
focal_method.invocations: put collect map stream getAuthorities joining info doGenerateToken getUsername
focal_method.modifiers: public
focal_method.parameters: (UserDetails userDetails)
focal_method.return: String
focal_method.signature: String generateToken(UserDetails userDetails)