Skip to content

Instantly share code, notes, and snippets.

@slmanju
Created January 7, 2018 14:35
Show Gist options
  • Select an option

  • Save slmanju/470e9416a90f09dee2ce206b3dfac809 to your computer and use it in GitHub Desktop.

Select an option

Save slmanju/470e9416a90f09dee2ce206b3dfac809 to your computer and use it in GitHub Desktop.
public class AuthenticationTokenFilter extends UsernamePasswordAuthenticationFilter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String authorizationToken = httpRequest.getHeader(HttpHeaders.AUTHORIZATION);
if (authorizationToken != null && authorizationToken.equals("winteriscoming")) {
SecurityContextHolder.getContext()
.setAuthentication(new UsernamePasswordAuthenticationToken("manjula", null, Collections.emptyList()));
}
chain.doFilter(request, response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment