Specifically I need to get the userId that had been posted from the j_security check action by the form based login (WSAD 5.0). Once I get the username from the session I need to "append" it to the request for an application which is a Servlet. But I am not able to get good examples how to do that especially on request wrappers.(are they any links?) I have got the basic logic down here but can you help me fine tune it.
In the domethod () I suppose I have to do this
RequestDispatcher rd = hrequest.getRequestDispatcher(�HS�); //HS is mapped to handle servlet where I the request need to go
hresponse.setHeader("SAMLAuthenticationMethod", "password");
PrincipalWrapper wrapper = new PrincipalWrapper(hrequest, new PrincipalImpl("user name here");
rd.forward(wrapper, hresponse);
Then I guess I can obtain the authenticated user from REMOTE_USER request header in handle servlet.
I guess I need to import java.security.Principal & sun.security.acl.PrincipalImpl;
/**
* <code>HttpServletRequest</code> wrapper class. Returns a locally specified principal.
*/
private class PrincipalWrapper extends HttpServletRequestWrapper {
private Principal principal;
private PrincipalWrapper(HttpServletRequest request, Principal principal) {
super(request);
this.principal = principal;
}
/**
* @see javax.servlet.http.HttpServletRequest#getRemoteUser()
*/
public
String getRemoteUser() {
return principal.getName();
}
/**
* @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
*/
public Principal getUserPrincipal() {
return principal;
}
}