use of com.tistory.heowc.auth.UserDetailsImpl in project SpringBootSample by heowc.
the class RefreshController method refreshToken.
@GetMapping
public ResponseEntity<String> refreshToken(Authentication authentication) {
UserDetails userDetails = new UserDetailsImpl(authentication.getPrincipal().toString(), new ArrayList<>(authentication.getAuthorities()));
String token = JwtUtil.refreshToken(userDetails);
HttpHeaders headers = new HttpHeaders();
headers.add(JwtInfo.HEADER_NAME, token);
return ResponseEntity.status(HttpStatus.OK).headers(headers).build();
}
use of com.tistory.heowc.auth.UserDetailsImpl in project SpringBootSample by heowc.
the class JwtUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String token) {
DecodedJWT decodedJWT = JwtUtil.tokenToJwt(token);
if (decodedJWT == null) {
throw new BadCredentialsException("Not used Token");
}
String id = decodedJWT.getClaim("id").asString();
String role = decodedJWT.getClaim("role").asString();
return new UserDetailsImpl(id, AuthorityUtils.createAuthorityList(role));
}
Aggregations