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

public abstract class AbstractUrlBasedTicketValidator
extends Object
implements TicketValidator

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

Since:
3.1
Author:
Scott Battaglia

Field Summary
protected  org.slf4j.Logger logger
           
 
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 getCasServerUrlPrefix()
           
protected  Map<String,String> getCustomParameters()
           
protected  String getEncoding()
           
protected  HttpURLConnectionFactory getURLConnectionFactory()
           
protected abstract  String getUrlSuffix()
          The endpoint of the validation URL.
protected  boolean isRenew()
           
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)
           
 void setEncoding(String encoding)
           
 void setRenew(boolean renew)
           
 void setURLConnectionFactory(HttpURLConnectionFactory urlConnectionFactory)
           
 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

logger

protected final org.slf4j.Logger logger
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.

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 final 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)

setEncoding

public final void setEncoding(String encoding)

getEncoding

protected final String getEncoding()

isRenew

protected final boolean isRenew()

getCasServerUrlPrefix

protected final String getCasServerUrlPrefix()

getCustomParameters

protected final Map<String,String> getCustomParameters()

getURLConnectionFactory

protected HttpURLConnectionFactory getURLConnectionFactory()

setURLConnectionFactory

public void setURLConnectionFactory(HttpURLConnectionFactory urlConnectionFactory)


Copyright © 2006-2015 Jasig. All Rights Reserved.