@Test public void getEmailOutOfAccessToken() { String actualEmail = jwtTool.getEmailOutOfAccessToken("eyJhbGciOiJIUzI1NiJ9" + ".eyJzdWIiOiJ0ZXN0QGdtYWlsLmNvbSIsImF1dGh" + "vcml0aWVzIjpbIlJPTEVfVVNFUiJdLCJpYXQiOjE1NzU4MzY5NjUsImV4cCI6OTk5OTk5OTk5OTk5fQ" + ".YFicrqBFN0Q662HqkI2P8yuykgvJjiTgUqsUhN4ICHI"); assertEquals(expectedEmail, actualEmail); }
public String getEmailOutOfAccessToken(String token) { String[] splitToken = token.split("\\."); String unsignedToken = splitToken[0] + "." + splitToken[1] + "."; DefaultJwtParser parser = new DefaultJwtParser(); Jwt<?, ?> jwt = parser.parse(unsignedToken); return ((Claims) jwt.getBody()).getSubject(); }
JwtTool { public String getEmailOutOfAccessToken(String token) { String[] splitToken = token.split("\\."); String unsignedToken = splitToken[0] + "." + splitToken[1] + "."; DefaultJwtParser parser = new DefaultJwtParser(); Jwt<?, ?> jwt = parser.parse(unsignedToken); return ((Claims) jwt.getBody()).getSubject(); } }
JwtTool { public String getEmailOutOfAccessToken(String token) { String[] splitToken = token.split("\\."); String unsignedToken = splitToken[0] + "." + splitToken[1] + "."; DefaultJwtParser parser = new DefaultJwtParser(); Jwt<?, ?> jwt = parser.parse(unsignedToken); return ((Claims) jwt.getBody()).getSubject(); } @Autowired  JwtTool(@Value("${accessTokenValidTimeInMinutes}") Integer accessTokenValidTimeInMinutes,
                   @Value("${refreshTokenValidTimeInMinutes}") Integer refreshTokenValidTimeInMinutes,
                   @Value("${tokenKey}") String accessTokenKey); }
JwtTool { public String getEmailOutOfAccessToken(String token) { String[] splitToken = token.split("\\."); String unsignedToken = splitToken[0] + "." + splitToken[1] + "."; DefaultJwtParser parser = new DefaultJwtParser(); Jwt<?, ?> jwt = parser.parse(unsignedToken); return ((Claims) jwt.getBody()).getSubject(); } @Autowired  JwtTool(@Value("${accessTokenValidTimeInMinutes}") Integer accessTokenValidTimeInMinutes,
                   @Value("${refreshTokenValidTimeInMinutes}") Integer refreshTokenValidTimeInMinutes,
                   @Value("${tokenKey}") String accessTokenKey); String createAccessToken(String email, ROLE role); String createRefreshToken(User user); String getEmailOutOfAccessToken(String token); boolean isTokenValid(String token, String tokenKey); String getAccessTokenKey(); String getTokenFromHttpServletRequest(HttpServletRequest servletRequest); String generateTokenKey(); }
JwtTool { public String getEmailOutOfAccessToken(String token) { String[] splitToken = token.split("\\."); String unsignedToken = splitToken[0] + "." + splitToken[1] + "."; DefaultJwtParser parser = new DefaultJwtParser(); Jwt<?, ?> jwt = parser.parse(unsignedToken); return ((Claims) jwt.getBody()).getSubject(); } @Autowired  JwtTool(@Value("${accessTokenValidTimeInMinutes}") Integer accessTokenValidTimeInMinutes,
                   @Value("${refreshTokenValidTimeInMinutes}") Integer refreshTokenValidTimeInMinutes,
                   @Value("${tokenKey}") String accessTokenKey); String createAccessToken(String email, ROLE role); String createRefreshToken(User user); String getEmailOutOfAccessToken(String token); boolean isTokenValid(String token, String tokenKey); String getAccessTokenKey(); String getTokenFromHttpServletRequest(HttpServletRequest servletRequest); String generateTokenKey();  }