Skip to content

Instantly share code, notes, and snippets.

@robhinds
Created March 26, 2014 09:09
Show Gist options
  • Save robhinds/9779339 to your computer and use it in GitHub Desktop.
Save robhinds/9779339 to your computer and use it in GitHub Desktop.
public class CustomTokenBasedRememberMeService extends TokenBasedRememberMeServices{
public CustomTokenBasedRememberMeService(String key, UserDetailsService userDetailsService) {
super(key, userDetailsService);
}
private final String HEADER_SECURITY_TOKEN = "Header name for token goes here";
/**
* Locates the Spring Security remember me token in the request and returns its value.
*
* @param request the submitted request which is to be authenticated
* @return the value of the request header (which was originally provided by the cookie - API expects it in header)
*/
@Override protected String extractRememberMeCookie(HttpServletRequest request) {
String token = request.getHeader(HEADER_SECURITY_TOKEN);
if ((token == null) || (token.length() == 0)) {
return null;
}
return token;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment