Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.acegisecurity.wrapper
Class SecurityContextHolderAwareRequestWrapper

    java.lang.Object
      javax.servlet.ServletRequestWrapper
          javax.servlet.http.HttpServletRequestWrapper
              org.acegisecurity.wrapper.SecurityContextHolderAwareRequestWrapper

All Implemented Interfaces:
  javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

    public class SecurityContextHolderAwareRequestWrapper

extends javax.servlet.http.HttpServletRequestWrapper

An Acegi Security-aware `HttpServletRequestWrapper`, which uses the `SecurityContext`-defined `Authentication` object for `isUserInRole(java.lang.String)` and `HttpServletRequestWrapper.getRemoteUser()` responses.

Version:
  $Id: SecurityContextHolderAwareRequestWrapper.java,v 1.3 2005/11/29 13:10:11 benalex Exp $
Author:
  Orlando Garcia Carmona, Ben Alex

Field Summary

Fields inherited from interface javax.servlet.http.HttpServletRequest
`BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

Constructor Summary
`SecurityContextHolderAwareRequestWrapper(javax.servlet.http.HttpServletRequest request)`

Method Summary
`String` | `getRemoteUser()` Returns the principal's name, as obtained from the `SecurityContextHolder`.
`Principal` | `getUserPrincipal()` Returns the `Authentication` (which is a subclass of `Principal`), or `null` if unavailable.
`boolean` | `isUserInRole(String role)` Simple searches for an exactly matching `GrantedAuthority#getAuthority()`.

Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
`getAuthType, getContextPath, getCookies, getDateHeader, getHeader, 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, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, 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, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding`

Constructor Detail

### SecurityContextHolderAwareRequestWrapper

    public SecurityContextHolderAwareRequestWrapper(javax.servlet.http.HttpServletRequest request)

Method Detail

### getRemoteUser

    public String getRemoteUser()

  Returns the principal's name, as obtained from the `SecurityContextHolder`. Properly handles both `String`-based and `UserDetails`-based principals.

  Specified by:
    `getRemoteUser` in interface `javax.servlet.http.HttpServletRequest`
  Overrides:
    `getRemoteUser` in class `javax.servlet.http.HttpServletRequestWrapper`
  Returns:
    the username or `null` if unavailable

### isUserInRole

    public boolean isUserInRole(String role)

  Simple searches for an exactly matching `GrantedAuthority#getAuthority()`.

  Will always return `false` if the `SecurityContextHolder` contains an `Authentication` with `null` `principal` and/or `GrantedAuthority[]` objects.

  Specified by:
    `isUserInRole` in interface `javax.servlet.http.HttpServletRequest`
  Overrides:
    `isUserInRole` in class `javax.servlet.http.HttpServletRequestWrapper`
  Parameters:
    `role` - the `GrantedAuthority` `String` representation to check for
  Returns:
    `true` if an exact (case sensitive) matching granted authority is located, `false` otherwise

### getUserPrincipal

    public Principal getUserPrincipal()

  Returns the `Authentication` (which is a subclass of `Principal`), or `null` if unavailable.

  Specified by:
    `getUserPrincipal` in interface `javax.servlet.http.HttpServletRequest`
  Overrides:
    `getUserPrincipal` in class `javax.servlet.http.HttpServletRequestWrapper`
  Returns:
    the `Authentication`, or `null`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2005 Acegi Technology Pty Limited. All Rights Reserved.