Apache Struts 2 Documentation > Home > FAQs > How do I obtain security details (JAAS) |
You can obtain the UserPrincipal and other security details by going through the request or implementing PrincipalAware. Implementing PrincipalAware is preferred.
First obtain the HttpServletRequest and then obtain the security Principal.
HttpServletRequest request = ServletActionContext.getRequest(); String authType = request.getAuthType(); // http or https String user = request.getRemoteUser(); // the user principal (in string) Principalprincipal = request.getUserPrincipal(); // get a Principal object bool isAuth = request.isUserInRole("patrick");
Preferred
@see org.apache.struts.action2.interceptor.PrincipalProxy
@see org.apache.struts.action2.interceptor.PrincipalAware
@see org.apache.struts.action2.interceptor.ServletConfigInterceptor