added ability to provide a map of custom attributes
This commit is contained in:
Scott Battaglia 2008-05-07 15:55:18 +00:00
parent 1f770cd549
commit f92005dd8e
2 changed files with 35 additions and 0 deletions

View File

@ -43,6 +43,11 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
*/
private boolean renew;
/**
* A map containing custom parameters to pass to the validation url.
*/
private Map customParameters;
/**
* Constructs a new TicketValidator with the casServerUrlPrefix.
*
@ -87,6 +92,10 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
populateUrlAttributeMap(urlParameters);
if (this.customParameters != null) {
urlParameters.putAll(this.customParameters);
}
final String suffix = getUrlSuffix();
final StringBuffer buffer = new StringBuffer(urlParameters.size()*10 + this.casServerUrlPrefix.length() + suffix.length() +1);
@ -171,4 +180,8 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
public void setRenew(final boolean renew) {
this.renew = renew;
}
public void setCustomParameters(final Map customParameters) {
this.customParameters = customParameters;
}
}

View File

@ -20,11 +20,17 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Creates either a CAS20ProxyTicketValidator or a CAS20ServiceTicketValidator depending on whether any of the
* proxy parameters are set.
* <p>
* This filter can also pass additional parameteres to the ticket validator. Any init parameter not included in the
* reserved list {@link org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter#RESERVED_INIT_PARAMS}.
*
* @author Scott Battaglia
* @version $Revision$ $Date$
@ -43,6 +49,8 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal
*/
private static final String PARAM_PROXY_GRANTING_TICKET = "pgtId";
private static final String[] RESERVED_INIT_PARAMS = new String[] {"proxyReceptorUrl", "acceptAnyProxy", "allowedProxyChains", "casServerUrlPrefix", "proxyCallbackUrl", "renew", "exceptionOnValidationFailure", "redirectAfterValidation", "useSession", "serverName", "service", "artifactParameterName", "serviceParameterName", "encodeServiceUrl"};
/**
* The URL to send to the CAS server as the URL that will process proxying requests on the CAS client.
*/
@ -87,6 +95,20 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal
validator.setProxyGrantingTicketStorage(this.proxyGrantingTicketStorage);
validator.setProxyRetriever(new Cas20ProxyRetriever(casServerUrlPrefix));
validator.setRenew(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "renew", "false")));
final Map additionalParameters = new HashMap();
final List params = Arrays.asList(RESERVED_INIT_PARAMS);
for (final Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
final String s = (String) e.nextElement();
if (!params.contains(s)) {
additionalParameters.put(s, filterConfig.getInitParameter(s));
}
}
validator.setCustomParameters(additionalParameters);
return validator;
}