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 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  HostnameVerifier hostnameVerifier
          Hostname verifier used when making an SSL request to the CAS server.
protected  org.apache.commons.logging.Log log
          Commons Logging instance.
 
Constructor Summary
protected AbstractUrlBasedTicketValidator(String casServerUrlPrefix)
          Constructs a new TicketValidator with the casServerUrlPrefix.
 
Method Summary
protected  String constructValidationUrl(String ticket, String serviceUrl)
          Constructs the URL to send the validation request to.
protected  String encodeUrl(String url)
          Encodes a URL using the URLEncoder format.
protected  String getEncoding()
           
protected abstract  String getUrlSuffix()
          The endpoint of the validation URL.
protected abstract  Assertion parseResponseFromServer(String response)
          Parses the response from the server into a CAS Assertion.
protected  void populateUrlAttributeMap(Map<String,String> urlParameters)
          Template method for ticket validators that need to provide additional parameters to the validation url.
protected abstract  String retrieveResponseFromServer(URL validationUrl, String ticket)
          Contacts the CAS Server to retrieve the response for the ticket validation.
 void setCustomParameters(Map<String,String> customParameters)
           
protected abstract  void setDisableXmlSchemaValidation(boolean disabled)
          Disable XML Schema validation.
 void setEncoding(String encoding)
           
 void setHostnameVerifier(HostnameVerifier verifier)
           
 void setRenew(boolean renew)
           
 Assertion validate(String ticket, 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.


hostnameVerifier

protected HostnameVerifier hostnameVerifier
Hostname verifier used when making an SSL request to the CAS server.

Constructor Detail

AbstractUrlBasedTicketValidator

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

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

populateUrlAttributeMap

protected void populateUrlAttributeMap(Map<String,String> 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 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.

setDisableXmlSchemaValidation

protected abstract void setDisableXmlSchemaValidation(boolean disabled)
Disable XML Schema validation. Note, setting this to true may not be reversable. Defaults to false. Setting it to false after setting it to true may not have any affect.

Parameters:
disabled - whether to disable or not.

constructValidationUrl

protected final String constructValidationUrl(String ticket,
                                              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 String encodeUrl(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(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 String retrieveResponseFromServer(URL validationUrl,
                                                     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(String ticket,
                          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 final void setRenew(boolean renew)

setCustomParameters

public final void setCustomParameters(Map<String,String> customParameters)

setHostnameVerifier

public final void setHostnameVerifier(HostnameVerifier verifier)

setEncoding

public final void setEncoding(String encoding)

getEncoding

protected final String getEncoding()


Copyright © 2006-2011 Jasig. All Rights Reserved.