edu.internet2.middleware.shibboleth.wayf.plugins.provider
Class SamlCookiePlugin

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.wayf.plugins.provider.SamlCookiePlugin
All Implemented Interfaces:
Plugin

public class SamlCookiePlugin
extends Object
implements Plugin

This is a test implementation of the _SAML_IDP cookie lookup stuff to see whether it fits the plugin architecture.


Nested Class Summary
private static class SamlCookiePlugin.Context
          This is just a marker tag.
 class SamlCookiePlugin.SamlIdPCookie
          Class to abstract away the saml cookie for us.
 
Field Summary
private  boolean alwaysFollow
          Do we always go where the cookie tells us, or do we just provide the cookie as a hint.
private  String cacheDomain
          Lipservice towards having a common domain cookie.
private  int cacheExpiration
          How long the cookie our will be active?
private static String COOKIE_NAME
          As specified in the SAML2 profiles specification.
private static int DEFAULT_CACHE_EXPIRATION
          By default we keep the cookie around for a week.
private  boolean deleteCookie
          Is our job to clean up the cookie.
private static Logger log
          Handle for logging.
private static String PARAMETER_NAME
          The parameter which controls the cache.
private static String PARAMETER_PERM
          Parameter to say make it last a long time.
private static String PARAMETER_SESSION
          Parameter to say just keep this as long as the browser is open.
 
Constructor Summary
private SamlCookiePlugin()
          Create a plugin with the hard-wired default settings.
  SamlCookiePlugin(Element element)
          This constructor is called during wayf initialization with it's own little bit of XML config.
 
Method Summary
private static void deleteCookie(HttpServletRequest req, HttpServletResponse res)
          Delete the cookie from the response.
private static Cookie getCookie(HttpServletRequest req)
          Extract the cookie from a request.
private  SamlCookiePlugin.SamlIdPCookie getIdPCookie(HttpServletRequest req, HttpServletResponse res, String domain)
          Load up the cookie and convert it into a SamlIdPCookie.
 PluginContext lookup(HttpServletRequest req, HttpServletResponse res, PluginMetadataParameter parameter, Map<String,IdPSite> validIdps, PluginContext context, List<IdPSite> idpList)
          This is the 'hook' in the lookup part of Discovery Service processing.
 PluginMetadataParameter refreshMetadata(org.opensaml.saml2.metadata.provider.MetadataProvider metadata)
          Plugin point which is called when the data is refreshed.
 PluginContext search(HttpServletRequest req, HttpServletResponse res, PluginMetadataParameter parameter, String pattern, Map<String,IdPSite> validIdps, PluginContext context, Collection<IdPSite> searchResult, List<IdPSite> idpList)
          Plugin point for searching.
 void selected(HttpServletRequest req, HttpServletResponse res, PluginMetadataParameter parameter, String idP)
          Plugin point for selection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_NAME

private static final String PARAMETER_NAME
The parameter which controls the cache.

See Also:
Constant Field Values

PARAMETER_PERM

private static final String PARAMETER_PERM
Parameter to say make it last a long time.

See Also:
Constant Field Values

PARAMETER_SESSION

private static final String PARAMETER_SESSION
Parameter to say just keep this as long as the browser is open.

See Also:
Constant Field Values

log

private static Logger log
Handle for logging.


COOKIE_NAME

private static final String COOKIE_NAME
As specified in the SAML2 profiles specification.

See Also:
Constant Field Values

DEFAULT_CACHE_EXPIRATION

private static final int DEFAULT_CACHE_EXPIRATION
By default we keep the cookie around for a week.

See Also:
Constant Field Values

alwaysFollow

private boolean alwaysFollow
Do we always go where the cookie tells us, or do we just provide the cookie as a hint.


deleteCookie

private boolean deleteCookie
Is our job to clean up the cookie.


cacheDomain

private final String cacheDomain
Lipservice towards having a common domain cookie.


cacheExpiration

private int cacheExpiration
How long the cookie our will be active?

Constructor Detail

SamlCookiePlugin

public SamlCookiePlugin(Element element)
This constructor is called during wayf initialization with it's own little bit of XML config.

Parameters:
element - - further information to be gleaned from the DOM.

SamlCookiePlugin

private SamlCookiePlugin()
Create a plugin with the hard-wired default settings.

Method Detail

lookup

public PluginContext lookup(HttpServletRequest req,
                            HttpServletResponse res,
                            PluginMetadataParameter parameter,
                            Map<String,IdPSite> validIdps,
                            PluginContext context,
                            List<IdPSite> idpList)
                     throws WayfRequestHandled
This is the 'hook' in the lookup part of Discovery Service processing.

Specified by:
lookup in interface Plugin
Parameters:
req - - Describes the current request. Used to find any appropriate cookies
res - - Describes the current response. Used to redirect the request.
parameter - - Describes the metadata.
context - - Any processing context returned from a previous call. We set this on first call and use non null to indicate that we don't go there again.
validIdps - The list of IdPs which is currently views as possibly matches for the pattern. The Key is the EntityId for the IdP and the value the object which describes the Idp
idpList - The set of Idps which are currently considered as potential hints.
Returns:
a context to hand to subsequent calls
Throws:
WayfRequestHandled - if the plugin has handled the request. issues a redirect)
See Also:
Plugin.lookup(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, edu.internet2.middleware.shibboleth.wayf.plugins.PluginMetadataParameter, java.util.Map, edu.internet2.middleware.shibboleth.wayf.plugins.PluginContext, java.util.List)

refreshMetadata

public PluginMetadataParameter refreshMetadata(org.opensaml.saml2.metadata.provider.MetadataProvider metadata)
Plugin point which is called when the data is refreshed.

Specified by:
refreshMetadata in interface Plugin
Parameters:
metadata - - where to get the data from.
Returns:
the value which will be provided as input to subsequent calls
See Also:
Plugin.refreshMetadata(org.opensaml.saml2.metadata.provider.MetadataProvider)

search

public PluginContext search(HttpServletRequest req,
                            HttpServletResponse res,
                            PluginMetadataParameter parameter,
                            String pattern,
                            Map<String,IdPSite> validIdps,
                            PluginContext context,
                            Collection<IdPSite> searchResult,
                            List<IdPSite> idpList)
                     throws WayfRequestHandled
Plugin point for searching.

Specified by:
search in interface Plugin
Parameters:
req - Describes the current request.
res - Describes the current response.
parameter - Describes the metadata.
pattern - What we are searchign for.
validIdps - The list of IdPs which is currently views as possibly matches for the pattern. The Key is the EntityId for the IdP and the value the object which describes the Idp
context - Any processing context returned from a previous call. We set this on first call and use non null to indicate that we don't go there again.
searchResult - What the search yielded.
idpList - The set of Idps which are currently considered as potential hints.
Returns:
a context to hand to subsequent calls.
Throws:
WayfRequestHandled
WayfRequestHandled - if the plugin has handled the request.
See Also:
Plugin.search(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, edu.internet2.middleware.shibboleth.wayf.plugins.PluginMetadataParameter, java.lang.String, java.util.Map, edu.internet2.middleware.shibboleth.wayf.plugins.PluginContext, java.util.Collection, java.util.List)

selected

public void selected(HttpServletRequest req,
                     HttpServletResponse res,
                     PluginMetadataParameter parameter,
                     String idP)
Plugin point for selection.

Specified by:
selected in interface Plugin
Parameters:
req - Describes the current request.
res - Describes the current response.
parameter - Describes the metadata.
idP - Describes the idp.
See Also:
Plugin.selected(HttpServletRequest, HttpServletResponse, PluginMetadataParameter, String)

getCookie

private static Cookie getCookie(HttpServletRequest req)
Extract the cookie from a request.

Parameters:
req - the request.
Returns:
the cookie.

deleteCookie

private static void deleteCookie(HttpServletRequest req,
                                 HttpServletResponse res)
Delete the cookie from the response.

Parameters:
req - The request.
res - The response.

getIdPCookie

private SamlCookiePlugin.SamlIdPCookie getIdPCookie(HttpServletRequest req,
                                                    HttpServletResponse res,
                                                    String domain)
Load up the cookie and convert it into a SamlIdPCookie. If there is no underlying cookie return a null one.

Parameters:
req - The request.
res - The response.
domain - - if this is set then any created cookies are set to this domain
Returns:
the new object.


Copyright © 1999-2012. All Rights Reserved.