removed old commented beanfilter code
This commit is contained in:
parent
eb7b2ab6d7
commit
4c11415d9c
@ -47,54 +47,6 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
this.tokenTimeoutDuration = Integer.parseInt(tokenTimeoutDuration);
|
this.tokenTimeoutDuration = Integer.parseInt(tokenTimeoutDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
|
|
||||||
// throws IOException, ServletException {
|
|
||||||
// final HttpServletRequest httpRequest = (HttpServletRequest) request;
|
|
||||||
//
|
|
||||||
// // extract token from header
|
|
||||||
// final String accessToken = httpRequest.getHeader("X-AUTH-TOKEN");
|
|
||||||
// if (null != accessToken) {
|
|
||||||
// // get and check whether token is valid ( from DB or file wherever you are
|
|
||||||
// // storing the token)
|
|
||||||
// Token token = tokenService.verifyToken(accessToken);
|
|
||||||
//
|
|
||||||
// if (token == null) {
|
|
||||||
// throw new UsernameNotFoundException("Token not issued by us");
|
|
||||||
// }
|
|
||||||
// UserToken userToken = userTokenService.getTokenByTokenString(accessToken);
|
|
||||||
//
|
|
||||||
// if (userToken == null) {
|
|
||||||
// throw new UsernameNotFoundException("Token not associated with any user");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String userName = userToken.getUserName();
|
|
||||||
// if (userName == null) {
|
|
||||||
// throw new UsernameNotFoundException("User not found");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// System.out.println("Timeout duration = " + tokenTimeoutDuration);
|
|
||||||
// boolean isTokenExpired = isTokenExpired(userToken);
|
|
||||||
// System.out.println("expired? " + isTokenExpired);
|
|
||||||
// if (!isTokenExpired) {
|
|
||||||
// userTokenService.saveToken(userToken);
|
|
||||||
// SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(userToken.getRole());
|
|
||||||
// List<SimpleGrantedAuthority> updatedAuthorities = new ArrayList<SimpleGrantedAuthority>();
|
|
||||||
// updatedAuthorities.add(simpleGrantedAuthority);
|
|
||||||
// final UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
|
|
||||||
// userName, token.getKey(), updatedAuthorities);
|
|
||||||
// SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
||||||
// } else {
|
|
||||||
// userTokenService.deleteToken(userToken.getUserName());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// chain.doFilter(request, response);
|
|
||||||
// }
|
|
||||||
|
|
||||||
private boolean isTokenExpired(UserToken userToken) {
|
private boolean isTokenExpired(UserToken userToken) {
|
||||||
Duration duration = Duration.between(userToken.getCreationTime(), Instant.now());
|
Duration duration = Duration.between(userToken.getCreationTime(), Instant.now());
|
||||||
long minutes = Math.abs(duration.toMinutes());
|
long minutes = Math.abs(duration.toMinutes());
|
||||||
|
Loading…
Reference in New Issue
Block a user