org.jasig.cas.client.validation
Class AbstractUrlBasedTicketValidator

java.lang.Object
  extended by org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator
All Implemented Interfaces:
TicketValidator
Direct Known Subclasses:
AbstractCasProtocolUrlBasedTicketValidator, Saml11TicketValidator

public abstract class AbstractUrlBasedTicketValidator
extends java.lang.Object
implements TicketValidator

Abstract validator implementation for tickets that must be validated against a server.

Since:
3.1
Version:
$Revision$ $Date$
Author:
Scott Battaglia

Field Summary
protected  org.apache.commons.logging.Log log
          Commons Logging instance.
 
Constructor Summary
protected AbstractUrlBasedTicketValidator(java.lang.String casServerUrlPrefix)
          Constructs a new TicketValidator with the casServerUrlPrefix.
 
Method Summary
protected  java.lang.String constructValidationUrl(java.lang.String ticket, java.lang.String serviceUrl)
          Constructs the URL to send the validation request to.
protected  java.lang.String encodeUrl(java.lang.String url)
          Encodes a URL using the URLEncoder format.
protected abstract  java.lang.String getUrlSuffix()
          The endpoint of the validation URL.
protected abstract  Assertion parseResponseFromServer(java.lang.String response)
          Parses the response from the server into a CAS Assertion.
protected  void populateUrlAttributeMap(java.util.Map urlParameters)
          Template method for ticket validators that need to provide additional parameters to the validation url.
protected abstract  java.lang.String retrieveResponseFromServer(java.net.URL validationUrl, java.lang.String ticket)
          Contacts the CAS Server to retrieve the response for the ticket validation.
 void setCustomParameters(java.util.Map customParameters)
           
 void setRenew(boolean renew)
           
 Assertion validate(java.lang.String ticket, java.lang.String service)
          Attempts to validate a ticket for the provided service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Commons Logging instance.

Constructor Detail

AbstractUrlBasedTicketValidator

protected AbstractUrlBasedTicketValidator(java.lang.String casServerUrlPrefix)
Constructs a new TicketValidator with the casServerUrlPrefix.

Parameters:
casServerUrlPrefix - the location of the CAS server.
Method Detail

populateUrlAttributeMap

protected void populateUrlAttributeMap(java.util.Map urlParameters)
Template method for ticket validators that need to provide additional parameters to the validation url.

Parameters:
urlParameters - the map containing the parameters.

getUrlSuffix

protected abstract java.lang.String getUrlSuffix()
The endpoint of the validation URL. Should be relative (i.e. not start with a "/"). I.e. validate or serviceValidate.

Returns:
the endpoint of the validation URL.

constructValidationUrl

protected final java.lang.String constructValidationUrl(java.lang.String ticket,
                                                        java.lang.String serviceUrl)
Constructs the URL to send the validation request to.

Parameters:
ticket - the ticket to be validated.
serviceUrl - the service identifier.
Returns:
the fully constructed URL.

encodeUrl

protected final java.lang.String encodeUrl(java.lang.String url)
Encodes a URL using the URLEncoder format.

Parameters:
url - the url to encode.
Returns:
the encoded url, or the original url if "UTF-8" character encoding could not be found.

parseResponseFromServer

protected abstract Assertion parseResponseFromServer(java.lang.String response)
                                              throws TicketValidationException
Parses the response from the server into a CAS Assertion.

Parameters:
response - the response from the server, in any format.
Returns:
the CAS assertion if one could be parsed from the response.
Throws:
TicketValidationException - if an Assertion could not be created.

retrieveResponseFromServer

protected abstract java.lang.String retrieveResponseFromServer(java.net.URL validationUrl,
                                                               java.lang.String ticket)
Contacts the CAS Server to retrieve the response for the ticket validation.

Parameters:
validationUrl - the url to send the validation request to.
ticket - the ticket to validate.
Returns:
the response from the CAS server.

validate

public Assertion validate(java.lang.String ticket,
                          java.lang.String service)
                   throws TicketValidationException
Description copied from interface: TicketValidator
Attempts to validate a ticket for the provided service.

Specified by:
validate in interface TicketValidator
Parameters:
ticket - the ticket to attempt to validate.
service - the service this ticket is valid for.
Returns:
an assertion from the ticket.
Throws:
TicketValidationException - if the ticket cannot be validated.

setRenew

public void setRenew(boolean renew)

setCustomParameters

public void setCustomParameters(java.util.Map customParameters)


Copyright © 2006-2009 JA-SIG. All Rights Reserved.