edu.internet2.middleware.shibboleth.wayf
Class DiscoveryServiceHandler

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.wayf.DiscoveryServiceHandler

public class DiscoveryServiceHandler
extends Object

Specific handler for each version of the Discovery Service.


Field Summary
private  HandlerConfig config
          Config handles detailed behavior.
private static String ENTITYID_PARAM_NAME
          The SP id.
private  boolean isDefault
          If isDefault is true then if there is a mismatch then this handler is used.
private static String ISPASSIVE_PARAM_NAME
          Whether we are allowed to interact.
private static String KNOWN_POLICY_NAME
          The only policy we know about.
private  String location
          The location defines the last part of the URL which distinguished this handler.
private static Logger LOG
          Mandatory Serialization constant.
private static String POLICY_PARAM_NAME
          Whether we understand this or not.
private static String PROVIDERID_OBJECT_PARAM_NAME
          The entityDescriptor for the SP (if present).
private static String PROVIDERID_PARAM_NAME
          This is the ID (in the metadata) of the SP.
private static String RETURN_ATTRIBUTE_NAME
          "return" is an invalid attribute, so we use returnX.
private static String RETURN_INDEX_NAME
          Alternatively the index of where to send the address back to.
private static String RETURN_PARAM_NAME
          Where to send the request back to.
private static String RETURNID_DEFAULT_VALUE
          What returnIDParam defaults to.
private static String RETURNID_PARAM_NAME
          What value to put the ID of the selected metadata into.
private static String SHIRE_PARAM_NAME
          Shire is the SP Assertion Consumer endpoint.
private  List<IdPSiteSet> siteSets
          The list of all the metadata providers that this discovery handler believes in.
private static String TARGET_PARAM_NAME
          TargetName is where we are trying to get to.
private  List<Plugin> thePlugins
          The list of all the plugins that this hanlder has had configured.
private static String TIME_PARAM_NAME
          time is to do with replay attack.
 
Constructor Summary
protected DiscoveryServiceHandler(Element config, Map<String,IdPSiteSet> federations, Map<String,Plugin> plugins, HandlerConfig defaultConfig)
          Constructor to create and configure the handler.
 
Method Summary
private  void checkForSAML2EndPoints(org.opensaml.saml2.metadata.EntityDescriptor sp)
          Check for SAML2 endpoints.
We have been approached with a DS message.
 void doGet(HttpServletRequest req, HttpServletResponse res)
          Processes the get request.
private static boolean equalsURL(org.opensaml.samlext.idpdisco.DiscoveryResponse discovery, URL providedName)
          Helper function to see whether the provided endpoint in the metadata matches the provided return URL in the request.
static void forwardRequest(HttpServletRequest req, HttpServletResponse res, IdPSite site)
          Uses an HTTP Status 307 redirect to forward the user to the IdP or the SP.
protected  String getLocation()
          The 'Name' of the service.
private static String getSPId(HttpServletRequest req)
          Examine the request and return the ID of the service provider by checking Both DS and WAYF protocols.
private static String getValue(HttpServletRequest req, String name)
          Gets the value for the parameter either from the parameter or from jsp.
private  void handleError(HttpServletRequest req, HttpServletResponse res, String message)
          Handles all "recoverable" errors in WAYF processing by logging the error and forwarding the user to an appropriate error page.
private  void handleLookup(HttpServletRequest req, HttpServletResponse res, String searchName)
          Displays a Discovery Service selection page, having first consulted the plugins as needed.
private  void handleSelection(HttpServletRequest req, HttpServletResponse res)
          When the WAYF user has selected something we look it up, tell the plugins and then dispatch to the Idp.
protected  boolean isDefault()
          Whether this is the default service.
private  void policePolicyType(HttpServletRequest req, HttpServletResponse res)
          Make sure that the policy is provides and is of the correct type.
private  void setDisplayLanguage(Collection<IdPSite> sites, HttpServletRequest req)
          Prior to display we set the display language from the browser.
private  void setupReturnAddress(String spName, HttpServletRequest req)
          This sets up the parameter RETURN_ATTRIBUTE_NAME with the return address harvested from the reqest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHIRE_PARAM_NAME

private static final String SHIRE_PARAM_NAME
Shire is the SP Assertion Consumer endpoint.

See Also:
Constant Field Values

TARGET_PARAM_NAME

private static final String TARGET_PARAM_NAME
TargetName is where we are trying to get to.

See Also:
Constant Field Values

TIME_PARAM_NAME

private static final String TIME_PARAM_NAME
time is to do with replay attack.

See Also:
Constant Field Values

PROVIDERID_PARAM_NAME

private static final String PROVIDERID_PARAM_NAME
This is the ID (in the metadata) of the SP.

See Also:
Constant Field Values

PROVIDERID_OBJECT_PARAM_NAME

private static final String PROVIDERID_OBJECT_PARAM_NAME
The entityDescriptor for the SP (if present).

See Also:
Constant Field Values

ENTITYID_PARAM_NAME

private static final String ENTITYID_PARAM_NAME
The SP id.

See Also:
Constant Field Values

RETURN_PARAM_NAME

private static final String RETURN_PARAM_NAME
Where to send the request back to.

See Also:
Constant Field Values

RETURN_ATTRIBUTE_NAME

private static final String RETURN_ATTRIBUTE_NAME
"return" is an invalid attribute, so we use returnX.

See Also:
Constant Field Values

RETURN_INDEX_NAME

private static final String RETURN_INDEX_NAME
Alternatively the index of where to send the address back to.

See Also:
Constant Field Values

RETURNID_PARAM_NAME

private static final String RETURNID_PARAM_NAME
What value to put the ID of the selected metadata into.

See Also:
Constant Field Values

RETURNID_DEFAULT_VALUE

private static final String RETURNID_DEFAULT_VALUE
What returnIDParam defaults to.

See Also:
Constant Field Values

ISPASSIVE_PARAM_NAME

private static final String ISPASSIVE_PARAM_NAME
Whether we are allowed to interact.

See Also:
Constant Field Values

POLICY_PARAM_NAME

private static final String POLICY_PARAM_NAME
Whether we understand this or not.

See Also:
Constant Field Values

KNOWN_POLICY_NAME

private static final String KNOWN_POLICY_NAME
The only policy we know about.

See Also:
Constant Field Values

LOG

private static final Logger LOG
Mandatory Serialization constant.


location

private final String location
The location defines the last part of the URL which distinguished this handler.


isDefault

private final boolean isDefault
If isDefault is true then if there is a mismatch then this handler is used.


config

private final HandlerConfig config
Config handles detailed behavior.


siteSets

private final List<IdPSiteSet> siteSets
The list of all the metadata providers that this discovery handler believes in.


thePlugins

private final List<Plugin> thePlugins
The list of all the plugins that this hanlder has had configured.

Constructor Detail

DiscoveryServiceHandler

protected DiscoveryServiceHandler(Element config,
                                  Map<String,IdPSiteSet> federations,
                                  Map<String,Plugin> plugins,
                                  HandlerConfig defaultConfig)
                           throws ShibbolethConfigurationException
Constructor to create and configure the handler.

Parameters:
config - - DOM Element with configuration information.
federations - - Supplies all known providers which will be included if so configured.
plugins - - Supplies all known plugins which will be included if configured in.
defaultConfig - - The default configurations.
Throws:
ShibbolethConfigurationException - - if we find something odd in the config file.
Method Detail

getLocation

protected String getLocation()
The 'Name' of the service. the path used to identify the ServiceHandler.

Returns:
the path used to identify the ServiceHandler.

isDefault

protected boolean isDefault()
Whether this is the default service.

Returns:
is it?

policePolicyType

private void policePolicyType(HttpServletRequest req,
                              HttpServletResponse res)
Make sure that the policy is provides and is of the correct type.

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

doGet

public void doGet(HttpServletRequest req,
                  HttpServletResponse res)
Processes the get request.

Parameters:
req - current HTTP request
res - current HTTP response

handleSelection

private void handleSelection(HttpServletRequest req,
                             HttpServletResponse res)
                      throws WayfRequestHandled,
                             WayfException
When the WAYF user has selected something we look it up, tell the plugins and then dispatch to the Idp.

Parameters:
req - - standard J2EE stuff
res - - standard J2EE stuff
Throws:
WayfRequestHandled - - if one of the plugins has done the dispatch
WayfException - - if we had an errors

setupReturnAddress

private void setupReturnAddress(String spName,
                                HttpServletRequest req)
                         throws WayfException
This sets up the parameter RETURN_ATTRIBUTE_NAME with the return address harvested from the reqest.

Parameters:
spName - - the name of the Service provider.
req - - The request.
Throws:
WayfException - - if we spot spoofing or there is no defaumlt

equalsURL

private static boolean equalsURL(org.opensaml.samlext.idpdisco.DiscoveryResponse discovery,
                                 URL providedName)
Helper function to see whether the provided endpoint in the metadata matches the provided return URL in the request.

Parameters:
discovery -
providedName -
Returns:
if the URL is empty.

handleLookup

private void handleLookup(HttpServletRequest req,
                          HttpServletResponse res,
                          String searchName)
                   throws WayfException,
                          WayfRequestHandled
Displays a Discovery Service selection page, having first consulted the plugins as needed.

Parameters:
req - Describes the request
res - Describes the response
searchName - What are we looking for?
Throws:
WayfRequestHandled - if a plugin has dealt with the request
WayfException - in case of an error.

checkForSAML2EndPoints

private void checkForSAML2EndPoints(org.opensaml.saml2.metadata.EntityDescriptor sp)
Check for SAML2 endpoints.
We have been approached with a DS message. An SP may not be announcing it SAML2-ness in the metadata This allows us to check.

Parameters:
sp - the EntityDescript of an SP which has asked for DS protocol.

setDisplayLanguage

private void setDisplayLanguage(Collection<IdPSite> sites,
                                HttpServletRequest req)
Prior to display we set the display language from the browser. There is probably a proper way to do this using jsp, but I want to keep the API between JSP and java the same 1.3->2.0

Parameters:
sites - - the sites we need to impact
req - - from which we get the locale

forwardRequest

public static void forwardRequest(HttpServletRequest req,
                                  HttpServletResponse res,
                                  IdPSite site)
                           throws WayfException
Uses an HTTP Status 307 redirect to forward the user to the IdP or the SP.

Parameters:
req - request under consideration
res - response under construction
site - The Idp
Throws:
WayfException - if bad things happen.

handleError

private void handleError(HttpServletRequest req,
                         HttpServletResponse res,
                         String message)
Handles all "recoverable" errors in WAYF processing by logging the error and forwarding the user to an appropriate error page.

Parameters:
req - request under consideration
res - response under construction
message - - what so say

getValue

private static String getValue(HttpServletRequest req,
                               String name)
Gets the value for the parameter either from the parameter or from jsp.

Parameters:
req - - the request.
name - - the name of the parameter.
Returns:
- result

getSPId

private static String getSPId(HttpServletRequest req)
                       throws WayfException
Examine the request and return the ID of the service provider by checking Both DS and WAYF protocols.

Parameters:
req - the request.
Returns:
The entityID of th SP initiating the reuqest.
Throws:
WayfException - if no SP ID was found


Copyright © 1999-2012. All Rights Reserved.