net.sf.jguard.jee.authentication.http
Class JGuardServletRequestWrapper

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by net.sf.jguard.jee.authentication.http.JGuardServletRequestWrapper
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class JGuardServletRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper

wrap the ServletRequest object to 'decorate' it to respect the JAAS mechanism present in j2se.

Author:
Charles Gay

Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
JGuardServletRequestWrapper(String applicationName, AuthenticationManager authenticationManager, javax.servlet.http.HttpServletRequest req, LoginContextWrapper loginContextWrapper)
           
 
Method Summary
 String getHeader(String headerName)
           
 String getRemoteUser()
          return login of the user.
 Principal getUserPrincipal()
          return a SubjectAsPrincipal object which wrap the Subject in a Principal.
 boolean isUserInRole(String role)
          wrap the isUserInRole method to check against all the RolePrincipal's set of the Subject object.
 void setHeader(String headerName, String headerValue)
           
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Constructor Detail

JGuardServletRequestWrapper

@Inject
public JGuardServletRequestWrapper(String applicationName,
                                          AuthenticationManager authenticationManager,
                                          javax.servlet.http.HttpServletRequest req,
                                          LoginContextWrapper loginContextWrapper)
Method Detail

isUserInRole

public boolean isUserInRole(String role)
wrap the isUserInRole method to check against all the RolePrincipal's set of the Subject object.

Specified by:
isUserInRole in interface javax.servlet.http.HttpServletRequest
Overrides:
isUserInRole in class javax.servlet.http.HttpServletRequestWrapper
Parameters:
role - : name of the principal(role) we are looking for
Returns:
boolean :return 'true' if one of the principal the Subject owns has got the same name.return 'false' otherwise.

getUserPrincipal

public Principal getUserPrincipal()
return a SubjectAsPrincipal object which wrap the Subject in a Principal.

Specified by:
getUserPrincipal in interface javax.servlet.http.HttpServletRequest
Overrides:
getUserPrincipal in class javax.servlet.http.HttpServletRequestWrapper
Returns:
principal

getRemoteUser

public String getRemoteUser()
return login of the user.

Specified by:
getRemoteUser in interface javax.servlet.http.HttpServletRequest
Overrides:
getRemoteUser in class javax.servlet.http.HttpServletRequestWrapper
Returns:
remote user login credential String value

setHeader

public void setHeader(String headerName,
                      String headerValue)

getHeader

public String getHeader(String headerName)
Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest
Overrides:
getHeader in class javax.servlet.http.HttpServletRequestWrapper


Copyright © 2004-2011. All Rights Reserved.