My requirement is ” Our users are Authenticated by External System using SSO”.
On successful authentication the external system returns header variables viz. userId,
firstName, lastName etc to our System.
Currently I am able to retrieve these header variables using
request.getHeader(“userId”) in my JSP page.
But I am using JSF 2.0 and not able to figure out as to how this can be done in JSF. I saw one example here on Stack overflow …
Map<String, String> requestHeaders = context.getExternalContext().getRequestHeaderMap();
String userName = requestHeaders.get(requestHeaderName);
but there was no further response as how this will be invoked on the backing bean.
Any pointer or sample code would be helpful.
The
contextis here just the current instance of theFacesContext. This is a request based threadlocal variable which is always available throughout all the JSF code which is controlled by theFacesServlet.You can invoke this in for example the bean’s constructor, the bean’s
@PostConstructmethod, the bean’s action(listener) method, etcetera. The right place depends on the moment you want to collect this information and what you want to do with this information.