edu.internet2.middleware.shibboleth.idp.util
Class HttpServletHelper

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.idp.util.HttpServletHelper

public class HttpServletHelper
extends Object

A helper class that provides access to internal state from Servlets and hence also JSPs.


Field Summary
static String ATTRIBUTE_FILTER_ENGINE_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the AttributeFilteringEngine service: "AttributeFilterEngineId" .
static String ATTRIBUTE_RESOLVER_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the AttributeResolver service: "AttributeResolverId" .
static String DEFAULT_ATTRIBUTE_FILTER_ENGINE_SID
          Default ID by which the AttributeFilteringEngine is know within the Servlet context: "shibboleth.AttributeFilterEngine" .
static String DEFAULT_ATTRIBUTE_RESOLVER_SID
          Default ID by which the AttributeResolver is know within the Servlet context: "shibboleth.AttributeResolver" .
static String DEFAULT_LOGIN_CTX_PARITION
          Default name for the StorageService partition which holds LoginContexts: "loginContexts" .
static String DEFAULT_PROFILE_HANDLER_MNGR_SID
          Default ID by which the IdPProfileHandlerManager is know within the Servlet context: "shibboleth.HandlerManager" .
static String DEFAULT_RP_CONFIG_MNGR_SID
          Default ID by which the RelyingPartyConfigurationManager is know within the Servlet context: "shibboleth.RelyingPartyConfigurationManager" .
static String DEFAULT_SAML1_AA_SID
          Default ID by which the SAML1AttributeAuthority is know within the Servlet context: "shibboleth.SAML1AttributeAuthority" .
static String DEFAULT_SAML2_AA_SID
          Default ID by which the SAML2AttributeAuthority is know within the Servlet context: "shibboleth.SAML2AttributeAuthority" .
static String DEFAULT_SESSION_MNGR_SID
          Default ID by which the SessionManager is know within the Servlet context: "shibboleth.SessionManager" .
static String DEFAULT_STORAGE_SERVICE_SID
          Default ID by which the StorageService is know within the Servlet context: "shibboleth.StorageService" .
static String IDP_SESSION_COOKIE
          Name of the cookie containing the IdP session ID: "_idp_session" .
static String LOGIN_CTX_KEY_NAME
          Name of the key to the current authentication login context: "_idp_authn_lc_key" .
static String LOGIN_CTX_PARTITION_CTX_PARAM
          ServletContext parameter name bearing the name of the StorageService partition into which LoginContexts are stored: "loginContextPartitionName" .
static String PROFILE_HANDLER_MNGR_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the IdPProfileHandlerManager service: "ProfileHandlerMngrId" .
static String RP_CONFIG_MNGR_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the RelyingPartyConfigurationManager service: * * * "RelyingPartyConfigurationManagerId" .
static String SAML1_AA_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the SAML1AttributeAuthority service: "SAML1AttributeAuthorityId" .
static String SAML2_AA_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the SAML2AttributeAuthority service: "SAML2AttributeAuthorityId" .
static String SESSION_MNGR_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the SessionManager service: "SessionManagerId" .
static String STORAGE_SERVICE_SID_CTX_PARAM
          ServletContext parameter name bearing the ID of the SAML1AttributeAuthority service: "StorageServiceId" .
 
Constructor Summary
HttpServletHelper()
           
 
Method Summary
static void bindLoginContext(LoginContext loginContext, javax.servlet.http.HttpServletRequest httpRequest)
          Binds a LoginContext to the current request.
static void bindLoginContext(LoginContext loginContext, org.opensaml.util.storage.StorageService storageService, javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse)
          Binds a LoginContext to the issuer of the current request.
static edu.internet2.middleware.shibboleth.common.attribute.filtering.AttributeFilteringEngine<?> getAttributeFilterEnginer(javax.servlet.ServletContext context)
          Gets the AttributeFilteringEngine service bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.attribute.filtering.AttributeFilteringEngine<?> getAttributeFilterEnginer(javax.servlet.ServletContext context, String serviceId)
          Gets the AttributeFilteringEngine bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolver<?> getAttributeResolver(javax.servlet.ServletContext context)
          Gets the AttributeResolver service bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolver<?> getAttributeResolver(javax.servlet.ServletContext context, String serviceId)
          Gets the AttributeResolver bound to the Servlet context.
static String getContextParam(javax.servlet.ServletContext context, String name, String defaultValue)
          Gets a value for a given context parameter.
static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest httpRequest, String cookieName)
          Gets the first Cookie whose name matches the given name.
static LoginContext getLoginContext(javax.servlet.http.HttpServletRequest httpRequest)
          Gets the login context from the current request.
static LoginContext getLoginContext(org.opensaml.util.storage.StorageService storageService, javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest httpRequest)
          Gets the LoginContext for the user issuing the HTTP request.
static IdPProfileHandlerManager getProfileHandlerManager(javax.servlet.ServletContext context)
          Gets the IdPProfileHandlerManager service bound to the Servlet context.
static IdPProfileHandlerManager getProfileHandlerManager(javax.servlet.ServletContext context, String serviceId)
          Gets the IdPProfileHandlerManager bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfigurationManager getRelyingPartyConfirmationManager(javax.servlet.ServletContext context)
          Gets the RelyingPartyConfigurationManager service bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfigurationManager getRelyingPartyConfirmationManager(javax.servlet.ServletContext context, String serviceId)
          Gets the RelyingPartyConfigurationManager bound to the Servlet context.
static org.opensaml.saml2.metadata.EntityDescriptor getRelyingPartyMetadata(String relyingPartyEntityId, edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfigurationManager rpConfigMngr)
          Gets the metatdata for a given relying party.
static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML1AttributeAuthority getSAML1AttributeAuthority(javax.servlet.ServletContext context)
          Gets the SAML1AttributeAuthority service bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML1AttributeAuthority getSAML1AttributeAuthority(javax.servlet.ServletContext context, String serviceId)
          Gets the SAML1AttributeAuthority bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML2AttributeAuthority getSAML2AttributeAuthority(javax.servlet.ServletContext context)
          Gets the SAML2AttributeAuthority service bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML2AttributeAuthority getSAML2AttributeAuthority(javax.servlet.ServletContext context, String serviceId)
          Gets the SAML2AttributeAuthority bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.session.SessionManager<Session> getSessionManager(javax.servlet.ServletContext context)
          Gets the SessionManager service bound to the Servlet context.
static edu.internet2.middleware.shibboleth.common.session.SessionManager<Session> getSessionManager(javax.servlet.ServletContext context, String serviceId)
          Gets the SessionManager bound to the Servlet context.
static org.opensaml.util.storage.StorageService<?,?> getStorageService(javax.servlet.ServletContext context)
          Gets the StorageService service bound to the Servlet context.
static org.opensaml.util.storage.StorageService<?,?> getStorageService(javax.servlet.ServletContext context, String serviceId)
          Gets the StorageService bound to the Servlet context.
static Session getUserSession(javax.servlet.http.HttpServletRequest httpRequest)
          Gets the user session from the request.
static LoginContext unbindLoginContext(org.opensaml.util.storage.StorageService storageService, javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse)
          Unbinds a LoginContext from the current request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDP_SESSION_COOKIE

public static final String IDP_SESSION_COOKIE
Name of the cookie containing the IdP session ID: "_idp_session" .

See Also:
Constant Field Values

LOGIN_CTX_KEY_NAME

public static final String LOGIN_CTX_KEY_NAME
Name of the key to the current authentication login context: "_idp_authn_lc_key" .

See Also:
Constant Field Values

ATTRIBUTE_FILTER_ENGINE_SID_CTX_PARAM

public static final String ATTRIBUTE_FILTER_ENGINE_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the AttributeFilteringEngine service: "AttributeFilterEngineId" .

See Also:
Constant Field Values

ATTRIBUTE_RESOLVER_SID_CTX_PARAM

public static final String ATTRIBUTE_RESOLVER_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the AttributeResolver service: "AttributeResolverId" .

See Also:
Constant Field Values

LOGIN_CTX_PARTITION_CTX_PARAM

public static final String LOGIN_CTX_PARTITION_CTX_PARAM
ServletContext parameter name bearing the name of the StorageService partition into which LoginContexts are stored: "loginContextPartitionName" .

See Also:
Constant Field Values

PROFILE_HANDLER_MNGR_SID_CTX_PARAM

public static final String PROFILE_HANDLER_MNGR_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the IdPProfileHandlerManager service: "ProfileHandlerMngrId" .

See Also:
Constant Field Values

RP_CONFIG_MNGR_SID_CTX_PARAM

public static final String RP_CONFIG_MNGR_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the RelyingPartyConfigurationManager service: * * * "RelyingPartyConfigurationManagerId" .

See Also:
Constant Field Values

SAML1_AA_SID_CTX_PARAM

public static final String SAML1_AA_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the SAML1AttributeAuthority service: "SAML1AttributeAuthorityId" .

See Also:
Constant Field Values

SAML2_AA_SID_CTX_PARAM

public static final String SAML2_AA_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the SAML2AttributeAuthority service: "SAML2AttributeAuthorityId" .

See Also:
Constant Field Values

SESSION_MNGR_SID_CTX_PARAM

public static final String SESSION_MNGR_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the SessionManager service: "SessionManagerId" .

See Also:
Constant Field Values

STORAGE_SERVICE_SID_CTX_PARAM

public static final String STORAGE_SERVICE_SID_CTX_PARAM
ServletContext parameter name bearing the ID of the SAML1AttributeAuthority service: "StorageServiceId" .

See Also:
Constant Field Values

DEFAULT_ATTRIBUTE_FILTER_ENGINE_SID

public static final String DEFAULT_ATTRIBUTE_FILTER_ENGINE_SID
Default ID by which the AttributeFilteringEngine is know within the Servlet context: "shibboleth.AttributeFilterEngine" .

See Also:
Constant Field Values

DEFAULT_ATTRIBUTE_RESOLVER_SID

public static final String DEFAULT_ATTRIBUTE_RESOLVER_SID
Default ID by which the AttributeResolver is know within the Servlet context: "shibboleth.AttributeResolver" .

See Also:
Constant Field Values

DEFAULT_LOGIN_CTX_PARITION

public static final String DEFAULT_LOGIN_CTX_PARITION
Default name for the StorageService partition which holds LoginContexts: "loginContexts" .

See Also:
Constant Field Values

DEFAULT_PROFILE_HANDLER_MNGR_SID

public static final String DEFAULT_PROFILE_HANDLER_MNGR_SID
Default ID by which the IdPProfileHandlerManager is know within the Servlet context: "shibboleth.HandlerManager" .

See Also:
Constant Field Values

DEFAULT_RP_CONFIG_MNGR_SID

public static final String DEFAULT_RP_CONFIG_MNGR_SID
Default ID by which the RelyingPartyConfigurationManager is know within the Servlet context: "shibboleth.RelyingPartyConfigurationManager" .

See Also:
Constant Field Values

DEFAULT_SAML1_AA_SID

public static final String DEFAULT_SAML1_AA_SID
Default ID by which the SAML1AttributeAuthority is know within the Servlet context: "shibboleth.SAML1AttributeAuthority" .

See Also:
Constant Field Values

DEFAULT_SAML2_AA_SID

public static final String DEFAULT_SAML2_AA_SID
Default ID by which the SAML2AttributeAuthority is know within the Servlet context: "shibboleth.SAML2AttributeAuthority" .

See Also:
Constant Field Values

DEFAULT_SESSION_MNGR_SID

public static final String DEFAULT_SESSION_MNGR_SID
Default ID by which the SessionManager is know within the Servlet context: "shibboleth.SessionManager" .

See Also:
Constant Field Values

DEFAULT_STORAGE_SERVICE_SID

public static final String DEFAULT_STORAGE_SERVICE_SID
Default ID by which the StorageService is know within the Servlet context: "shibboleth.StorageService" .

See Also:
Constant Field Values
Constructor Detail

HttpServletHelper

public HttpServletHelper()
Method Detail

bindLoginContext

public static void bindLoginContext(LoginContext loginContext,
                                    javax.servlet.http.HttpServletRequest httpRequest)
Binds a LoginContext to the current request.

Parameters:
loginContext - login context to be bound
httpRequest - current HTTP request

bindLoginContext

public static void bindLoginContext(LoginContext loginContext,
                                    org.opensaml.util.storage.StorageService storageService,
                                    javax.servlet.ServletContext context,
                                    javax.servlet.http.HttpServletRequest httpRequest,
                                    javax.servlet.http.HttpServletResponse httpResponse)
Binds a LoginContext to the issuer of the current request. The binding is done by creating a random UUID, placing that in a cookie in the request, and storing the context in to the storage service under that key.

Parameters:
loginContext - the login context to be bound
storageService - the storage service which will hold the context
context - the Servlet context
httpRequest - the current HTTP request
httpResponse - the current HTTP response

getAttributeFilterEnginer

public static edu.internet2.middleware.shibboleth.common.attribute.filtering.AttributeFilteringEngine<?> getAttributeFilterEnginer(javax.servlet.ServletContext context)
Gets the AttributeFilteringEngine service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getAttributeFilterEnginer

public static edu.internet2.middleware.shibboleth.common.attribute.filtering.AttributeFilteringEngine<?> getAttributeFilterEnginer(javax.servlet.ServletContext context,
                                                                                                                                   String serviceId)
Gets the AttributeFilteringEngine bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getAttributeResolver

public static edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolver<?> getAttributeResolver(javax.servlet.ServletContext context)
Gets the AttributeResolver service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getAttributeResolver

public static edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolver<?> getAttributeResolver(javax.servlet.ServletContext context,
                                                                                                                      String serviceId)
Gets the AttributeResolver bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getContextParam

public static String getContextParam(javax.servlet.ServletContext context,
                                     String name,
                                     String defaultValue)
Gets a value for a given context parameter. If no value is present the default value is used.

Parameters:
context - the Servlet context
name - name of the context parameter
defaultValue - default value of the parameter
Returns:
the value of the context parameter or the default value if the parameter is not set or does not contain a value

getCookie

public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest httpRequest,
                                                  String cookieName)
Gets the first Cookie whose name matches the given name.

Parameters:
cookieName - the cookie name
httpRequest - HTTP request from which the cookie should be extracted
Returns:
the cookie or null if no cookie with that name was given

getLoginContext

public static LoginContext getLoginContext(javax.servlet.http.HttpServletRequest httpRequest)
Gets the login context from the current request. The login context is only in this location while the request is being transferred from the authentication engine back to the profile handler.

Parameters:
httpRequest - current HTTP request
Returns:
the login context or null if no login context is bound to the request

getLoginContext

public static LoginContext getLoginContext(org.opensaml.util.storage.StorageService storageService,
                                           javax.servlet.ServletContext context,
                                           javax.servlet.http.HttpServletRequest httpRequest)
Gets the LoginContext for the user issuing the HTTP request. Note, login contexts are only available during the authentication process.

Parameters:
context - the Servlet context
storageService - storage service to use when retrieving the login context
httpRequest - current HTTP request
Returns:
the login context or null if none is available

getProfileHandlerManager

public static IdPProfileHandlerManager getProfileHandlerManager(javax.servlet.ServletContext context)
Gets the IdPProfileHandlerManager service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getProfileHandlerManager

public static IdPProfileHandlerManager getProfileHandlerManager(javax.servlet.ServletContext context,
                                                                String serviceId)
Gets the IdPProfileHandlerManager bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getRelyingPartyConfirmationManager

public static edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfigurationManager getRelyingPartyConfirmationManager(javax.servlet.ServletContext context)
Gets the RelyingPartyConfigurationManager service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getRelyingPartyConfirmationManager

public static edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfigurationManager getRelyingPartyConfirmationManager(javax.servlet.ServletContext context,
                                                                                                                                          String serviceId)
Gets the RelyingPartyConfigurationManager bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getRelyingPartyMetadata

public static org.opensaml.saml2.metadata.EntityDescriptor getRelyingPartyMetadata(String relyingPartyEntityId,
                                                                                   edu.internet2.middleware.shibboleth.common.relyingparty.RelyingPartyConfigurationManager rpConfigMngr)
Gets the metatdata for a given relying party.

Parameters:
relyingPartyEntityId - the ID of the relying party
rpConfigMngr - relying party configuration manager
Returns:
the metadata for the relying party or null if no SAML metadata exists for the given relying party

getSAML1AttributeAuthority

public static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML1AttributeAuthority getSAML1AttributeAuthority(javax.servlet.ServletContext context)
Gets the SAML1AttributeAuthority service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getSAML1AttributeAuthority

public static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML1AttributeAuthority getSAML1AttributeAuthority(javax.servlet.ServletContext context,
                                                                                                                               String serviceId)
Gets the SAML1AttributeAuthority bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getSAML2AttributeAuthority

public static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML2AttributeAuthority getSAML2AttributeAuthority(javax.servlet.ServletContext context)
Gets the SAML2AttributeAuthority service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getSAML2AttributeAuthority

public static edu.internet2.middleware.shibboleth.common.attribute.provider.SAML2AttributeAuthority getSAML2AttributeAuthority(javax.servlet.ServletContext context,
                                                                                                                               String serviceId)
Gets the SAML2AttributeAuthority bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getSessionManager

public static edu.internet2.middleware.shibboleth.common.session.SessionManager<Session> getSessionManager(javax.servlet.ServletContext context)
Gets the SessionManager service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getSessionManager

public static edu.internet2.middleware.shibboleth.common.session.SessionManager<Session> getSessionManager(javax.servlet.ServletContext context,
                                                                                                           String serviceId)
Gets the SessionManager bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getStorageService

public static org.opensaml.util.storage.StorageService<?,?> getStorageService(javax.servlet.ServletContext context)
Gets the StorageService service bound to the Servlet context.

Parameters:
context - the Servlet context
Returns:
the service or null if there is no such service bound to the context

getStorageService

public static org.opensaml.util.storage.StorageService<?,?> getStorageService(javax.servlet.ServletContext context,
                                                                              String serviceId)
Gets the StorageService bound to the Servlet context.

Parameters:
context - the Servlet context
serviceId - the ID under which the service bound
Returns:
the service or null if there is no such service bound to the context

getUserSession

public static Session getUserSession(javax.servlet.http.HttpServletRequest httpRequest)
Gets the user session from the request. Retrieving the session in this manner does NOT update the last activity time of the session.

Parameters:
httpRequest - current request
Returns:
the users session, if one exists

unbindLoginContext

public static LoginContext unbindLoginContext(org.opensaml.util.storage.StorageService storageService,
                                              javax.servlet.ServletContext context,
                                              javax.servlet.http.HttpServletRequest httpRequest,
                                              javax.servlet.http.HttpServletResponse httpResponse)
Unbinds a LoginContext from the current request. The unbinding results in the destruction of the associated context key cookie and removes the context from the storage service.

Parameters:
storageService - storage service holding the context
context - the Servlet context
httpRequest - current HTTP request
httpResponse - current HTTP response
Returns:
the login context that was unbound or null if there was no bound context


Copyright © 2006-2009 Internet2. All Rights Reserved.