We have a server that returns custom fields in the response that we would like
to parse out by overriding customParseResponse in the
Cas20ServiceTicketValidator.
We couldn't find a way to create a custom subclass of
Cas20ServiceTicketValidator in Cas20ProxyReceivingTicketValidationFilter so
we've prepared a patch to allow a new init-param to specify a custom
implementation class.
Also in Cas20ServiceTicketValidator, if there are no custom attributes in
extractCustomAttributes it returns a Collections.emptyMap(), which is
immutable. So I explored changing this to returning an empty HashMap so that a
customParseResponse implementation could always add to the existing attributes
(even if empty).
I have attached a patch. I hope this is useful.
Best regards,
Karl
--
You are currently subscribed to cas-dev@lists.jasig.org as:
arch...@mail-archive.com
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/cas-dev
Index:
cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java
===================================================================
---
cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java
(revision 25548)
+++
cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java
(working copy)
@@ -112,6 +112,52 @@
}
this.timer.schedule(this.timerTask, this.millisBetweenCleanUps,
this.millisBetweenCleanUps);
}
+
+ /**
+ * Construct a Cas20ProxyTicketValidator using either the default
implementation of a subclass using a class name in
+ * a proxyTicketValidator filter configuration parameter.
+ * @param filterConfig the Filter Configuration object.
+ * @param casServerUrlPrefix the casServerUrlPrefix
+ * @return a new unconfigured Cas20ProxyTicketValidator
+ */
+ protected Cas20ProxyTicketValidator createProxyTicketValidator(final
FilterConfig filterConfig, String casServerUrlPrefix) {
+ Cas20ProxyTicketValidator v = null;
+
+ final String className =
getPropertyFromInitParams(filterConfig, "proxyTicketValidator", null);
+ if (className != null) {
+ log.trace("Using proxyTicketValidator parameter: " +
className);
+ v = ReflectUtils.newInstance(className,
casServerUrlPrefix);
+ }
+
+ if (v == null) {
+ v = new Cas20ProxyTicketValidator(casServerUrlPrefix);
+ }
+
+ return v;
+ }
+
+ /**
+ * Construct a Cas20ServiceTicketValidator using either the default
implementation of a subclass using a class name in
+ * a ticketValidator filter configuration parameter.
+ * @param filterConfig the Filter Configuration object.
+ * @param casServerUrlPrefix the casServerUrlPrefix
+ * @return a new unconfigured Cas20ServiceTicketValidator
+ */
+ protected Cas20ServiceTicketValidator createTicketValidator(final
FilterConfig filterConfig, String casServerUrlPrefix) {
+ Cas20ServiceTicketValidator v = null;
+
+ final String className =
getPropertyFromInitParams(filterConfig, "ticketValidator", null);
+ if (className != null) {
+ log.trace("Using ticketValidator parameter: " +
className);
+ v = ReflectUtils.newInstance(className,
casServerUrlPrefix);
+ }
+
+ if (v == null) {
+ v = new Cas20ServiceTicketValidator(casServerUrlPrefix);
+ }
+
+ return v;
+ }
/**
* Constructs a Cas20ServiceTicketValidator or a Cas20ProxyTicketValidator
based on supplied parameters.
@@ -126,12 +172,12 @@
final Cas20ServiceTicketValidator validator;
if (CommonUtils.isNotBlank(allowAnyProxy) ||
CommonUtils.isNotBlank(allowedProxyChains)) {
- final Cas20ProxyTicketValidator v = new
Cas20ProxyTicketValidator(casServerUrlPrefix);
+ final Cas20ProxyTicketValidator v =
createProxyTicketValidator(filterConfig, casServerUrlPrefix);
v.setAcceptAnyProxy(parseBoolean(allowAnyProxy));
v.setAllowedProxyChains(CommonUtils.createProxyList(allowedProxyChains));
validator = v;
} else {
- validator = new Cas20ServiceTicketValidator(casServerUrlPrefix);
+ validator = createTicketValidator(filterConfig,
casServerUrlPrefix);
}
validator.setProxyCallbackUrl(getPropertyFromInitParams(filterConfig,
"proxyCallbackUrl", null));
validator.setProxyGrantingTicketStorage(this.proxyGrantingTicketStorage);
Index:
cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidator.java
===================================================================
---
cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidator.java
(revision 25548)
+++
cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidator.java
(working copy)
@@ -31,7 +31,6 @@
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -126,7 +125,8 @@
final int pos2 = xml.indexOf("</cas:attributes>");
if (pos1 == -1) {
- return Collections.emptyMap();
+ /* Return an empty map, but mutable so that customParseResponse
can add to it */
+ return new HashMap<String, Object>();
}
final String attributesText = xml.substring(pos1+16, pos2);