removed old commented beanfilter code

This commit is contained in:
Rohan Sircar 2019-11-20 15:16:42 +05:30
parent eb7b2ab6d7
commit 4c11415d9c

View File

@ -47,54 +47,6 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
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) {
Duration duration = Duration.between(userToken.getCreationTime(), Instant.now());
long minutes = Math.abs(duration.toMinutes());