final class SpnegoHttpServletRequest extends javax.servlet.http.HttpServletRequestWrapper implements DelegateServletRequest, SpnegoAccessControl
Also, see the documentation on the DelegateServletRequest
class.
Finally, a credential delegation example can be found on http://spnego.sourceforge.net
Modifier and Type | Field and Description |
---|---|
private UserAccessControl |
accessControl
authZ framework interface.
|
private static String |
MESSAGE_UNSUPPORTED |
private SpnegoPrincipal |
principal
Client Principal.
|
Constructor and Description |
---|
SpnegoHttpServletRequest(javax.servlet.http.HttpServletRequest request,
SpnegoPrincipal spnegoPrincipal)
Creates Servlet Request specifying KerberosPrincipal of user.
|
SpnegoHttpServletRequest(javax.servlet.http.HttpServletRequest request,
SpnegoPrincipal spnegoPrincipal,
UserAccessControl userAccessControl)
Creates Servlet Request specifying KerberosPrincipal of user
and a specified User Access Control (authZ).
|
Modifier and Type | Method and Description |
---|---|
boolean |
anyAccess(String... resources)
Checks to see if the user has at least one of the passed-in user-defined
resource labels
|
boolean |
anyRole(String... roles)
Checks to see if the user has at least one of the passed-in attributes.
|
String |
getAuthType()
Returns "Negotiate" or "Basic" else default auth type.
|
GSSCredential |
getDelegatedCredential()
Returns the requester's delegated credential.
|
String |
getRemoteUser()
Returns authenticated username (sans domain/realm) else default username.
|
UserInfo |
getUserInfo()
Returns the user's info object.
|
Principal |
getUserPrincipal()
Returns KerberosPrincipal of user.
|
boolean |
hasAccess(String resource)
Checks to see if the user has access to the user-defined resource label.
|
boolean |
hasAccess(String resourceX,
String... resourceYs)
Checks to see if the user has the first user-defined resource label
AND has at least one of the passed-in user-defined resource labels.
|
boolean |
hasRole(String role)
Checks to see if the user has the passed-in attribute.
|
boolean |
hasRole(String featureX,
String... featureYs)
Checks to see if the user has the first attribute
AND has at least one of the passed-in attributes.
|
boolean |
isUserInRole(String role) |
getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
private static final String MESSAGE_UNSUPPORTED
private final transient SpnegoPrincipal principal
private final transient UserAccessControl accessControl
SpnegoHttpServletRequest(javax.servlet.http.HttpServletRequest request, SpnegoPrincipal spnegoPrincipal)
request
- spnegoPrincipal
- SpnegoHttpServletRequest(javax.servlet.http.HttpServletRequest request, SpnegoPrincipal spnegoPrincipal, UserAccessControl userAccessControl)
request
- spnegoPrincipal
- userAccessControl
- public String getAuthType()
getAuthType
in interface javax.servlet.http.HttpServletRequest
getAuthType
in class javax.servlet.http.HttpServletRequestWrapper
HttpServletRequest.getAuthType()
public GSSCredential getDelegatedCredential()
DelegateServletRequest
Returns null if request has no delegated credential or if delegated credentials are not supported.
getDelegatedCredential
in interface DelegateServletRequest
public String getRemoteUser()
getRemoteUser
in interface javax.servlet.http.HttpServletRequest
getRemoteUser
in class javax.servlet.http.HttpServletRequestWrapper
HttpServletRequest.getRemoteUser()
public Principal getUserPrincipal()
getUserPrincipal
in interface javax.servlet.http.HttpServletRequest
getUserPrincipal
in class javax.servlet.http.HttpServletRequestWrapper
HttpServletRequest.getUserPrincipal()
public boolean anyRole(String... roles)
SpnegoAccessControl
String[] attributes = new String[] {"Developer", "Los Angeles", "Manager"}; if (accessControl.anyRole(attributes)) { // will be in here if the user has at least one matching attribute }
anyRole
in interface SpnegoAccessControl
roles
- e.g. Team Lead, IT, Developerpublic boolean hasRole(String role)
SpnegoAccessControl
String attribute = "Developer"; if (accessControl.hasRole(attribute)) { // will be in here if the user has the matching attribute }
hasRole
in interface SpnegoAccessControl
role
- e.g. Team Lead, IT, Developerpublic boolean hasRole(String featureX, String... featureYs)
SpnegoAccessControl
String attributeX = "Los Angeles"; String[] attributeYs = new String[] {"Developer", "Manager"}; if (accessControl.hasRole(attributeX, attributeYs)) { // will be in here if the user has attributeX // AND has at least one of the attributeYs. }
hasRole
in interface SpnegoAccessControl
featureX
- e.g. Information TechnologyfeatureYs
- e.g. Team Lead, IT-Architecture-DLpublic boolean anyAccess(String... resources)
SpnegoAccessControl
String[] resources = new String[] {"admin-links", "ops-buttons"}; if (accessControl.anyAccess(resources)) { // will be in here if the user has at least one matching resource }
anyAccess
in interface SpnegoAccessControl
resources
- e.g. admin-links, ops-buttonspublic boolean hasAccess(String resource)
SpnegoAccessControl
boolean hasPermission = false; if (request instanceof SpnegoAccessControl) { SpnegoAccessControl accessControl = (SpnegoAccessControl) request; hasPermission = accessControl.hasAccess("finance-links"); }
hasAccess
in interface SpnegoAccessControl
resource
- e.g. admin-buttonspublic boolean hasAccess(String resourceX, String... resourceYs)
SpnegoAccessControl
String resourceX = "finance-links"; String[] resourceYs = new String[] {"admin-links", "accounting-buttons"}; if (accessControl.hasAccess(resourceX, resourceYs)) { // will be in here if the user has resourceX // AND has at least one of the resourceYs. }
hasAccess
in interface SpnegoAccessControl
resourceX
- e.g. finance-linksresourceYs
- e.g. admin-links, accounting-buttonspublic UserInfo getUserInfo()
SpnegoAccessControl
getUserInfo
in interface SpnegoAccessControl
public boolean isUserInRole(String role)
isUserInRole
in interface javax.servlet.http.HttpServletRequest
isUserInRole
in class javax.servlet.http.HttpServletRequestWrapper