Add to web.xml
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
In the class you need access to it...
@Autowired
private HttpServletRequest context;
Then some code... (in this case it extracts it from Message Digest loggon)
private String getAuthenticationUser()
{
String authorization = context.getHeader("authorization");
if (authorization.startsWith("Digest response")) {
String[] splits = authorization.split(",");
for (String split : splits)
{
String[] splitKeyValue = split.trim().split("=");
if(splitKeyValue[0].equalsIgnoreCase("username")) {
authorization = splitKeyValue[1];
authorization = authorization.replace("\"", "");
break;
}
}
}
return authorization;
}