From 7647009ca45a94be3b9f05cbf0658c66740d25c8 Mon Sep 17 00:00:00 2001 From: LELEU Jerome Date: Mon, 5 Jan 2015 15:55:33 +0100 Subject: [PATCH] CASC-217: Update the ticket validators to point to the new endpoint First commit --- .../java/org/jasig/cas/client/Protocol.java | 2 +- ...0ProxyReceivingTicketValidationFilter.java | 16 ++++++-- ...0ProxyReceivingTicketValidationFilter.java | 40 +++++++++++++++++++ .../validation/Cas30ProxyTicketValidator.java | 37 +++++++++++++++++ .../Cas30ServiceTicketValidator.java | 37 +++++++++++++++++ 5 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyReceivingTicketValidationFilter.java create mode 100644 cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyTicketValidator.java create mode 100644 cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ServiceTicketValidator.java diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/Protocol.java b/cas-client-core/src/main/java/org/jasig/cas/client/Protocol.java index e26761d..bf259aa 100644 --- a/cas-client-core/src/main/java/org/jasig/cas/client/Protocol.java +++ b/cas-client-core/src/main/java/org/jasig/cas/client/Protocol.java @@ -26,7 +26,7 @@ package org.jasig.cas.client; */ public enum Protocol { - CAS1("ticket", "service"), CAS2(CAS1), SAML11("SAMLart", "TARGET"); + CAS1("ticket", "service"), CAS2(CAS1), CAS3(CAS2), SAML11("SAMLart", "TARGET"); private final String artifactParameterName; diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java index 8c7a632..deefe22 100644 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java +++ b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyReceivingTicketValidationFilter.java @@ -68,13 +68,23 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal private int millisBetweenCleanUps; + protected Class defaultServiceTicketValidatorClass; + + protected Class defaultProxyTicketValidatorClass; + /** * Storage location of ProxyGrantingTickets and Proxy Ticket IOUs. */ private ProxyGrantingTicketStorage proxyGrantingTicketStorage = new ProxyGrantingTicketStorageImpl(); public Cas20ProxyReceivingTicketValidationFilter() { - super(Protocol.CAS2); + this(Protocol.CAS2); + this.defaultServiceTicketValidatorClass = Cas20ServiceTicketValidator.class; + this.defaultProxyTicketValidatorClass = Cas20ProxyTicketValidator.class; + } + + protected Cas20ProxyReceivingTicketValidationFilter(final Protocol protocol) { + super(protocol); } protected void initInternal(final FilterConfig filterConfig) throws ServletException { @@ -144,13 +154,13 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal if (allowAnyProxy || CommonUtils.isNotBlank(allowedProxyChains)) { final Cas20ProxyTicketValidator v = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, - Cas20ProxyTicketValidator.class); + this.defaultProxyTicketValidatorClass); v.setAcceptAnyProxy(allowAnyProxy); v.setAllowedProxyChains(CommonUtils.createProxyList(allowedProxyChains)); validator = v; } else { validator = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, - Cas20ServiceTicketValidator.class); + this.defaultServiceTicketValidatorClass); } validator.setProxyCallbackUrl(getString(ConfigurationKeys.PROXY_CALLBACK_URL)); validator.setProxyGrantingTicketStorage(this.proxyGrantingTicketStorage); diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyReceivingTicketValidationFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyReceivingTicketValidationFilter.java new file mode 100644 index 0000000..4f11627 --- /dev/null +++ b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyReceivingTicketValidationFilter.java @@ -0,0 +1,40 @@ +/* + * Licensed to Jasig under one or more contributor license + * agreements. See the NOTICE file distributed with this work + * for additional information regarding copyright ownership. + * Jasig licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a + * copy of the License at the following location: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jasig.cas.client.validation; + +import org.jasig.cas.client.Protocol; + +/** + * Creates either a Cas30ProxyTicketValidator or a Cas30ServiceTicketValidator depending on whether any of the + * proxy parameters are set. + *

+ * This filter can also pass additional parameters to the ticket validator. Any init parameter not included in the + * reserved list {@link org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter#RESERVED_INIT_PARAMS}. + * + * @author Jerome Leleu + * @since 3.4.0 + */ +public class Cas30ProxyReceivingTicketValidationFilter extends Cas20ProxyReceivingTicketValidationFilter { + + public Cas30ProxyReceivingTicketValidationFilter() { + super(Protocol.CAS3); + this.defaultServiceTicketValidatorClass = Cas30ServiceTicketValidator.class; + this.defaultProxyTicketValidatorClass = Cas30ProxyTicketValidator.class; + } +} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyTicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyTicketValidator.java new file mode 100644 index 0000000..2cdb641 --- /dev/null +++ b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ProxyTicketValidator.java @@ -0,0 +1,37 @@ +/* + * Licensed to Jasig under one or more contributor license + * agreements. See the NOTICE file distributed with this work + * for additional information regarding copyright ownership. + * Jasig licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a + * copy of the License at the following location: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jasig.cas.client.validation; + +/** + * Service and proxy tickets validation service for the CAS protocol v3. + * + * @author Jerome Leleu + * @since 3.4.0 + */ +public class Cas30ProxyTicketValidator extends Cas20ProxyTicketValidator { + + public Cas30ProxyTicketValidator(String casServerUrlPrefix) { + super(casServerUrlPrefix); + } + + @Override + protected String getUrlSuffix() { + return "p3/proxyValidate"; + } +} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ServiceTicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ServiceTicketValidator.java new file mode 100644 index 0000000..cb155a7 --- /dev/null +++ b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas30ServiceTicketValidator.java @@ -0,0 +1,37 @@ +/* + * Licensed to Jasig under one or more contributor license + * agreements. See the NOTICE file distributed with this work + * for additional information regarding copyright ownership. + * Jasig licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a + * copy of the License at the following location: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jasig.cas.client.validation; + +/** + * Service tickets validation service for the CAS protocol v3. + * + * @author Jerome Leleu + * @since 3.4.0 + */ +public class Cas30ServiceTicketValidator extends Cas20ServiceTicketValidator { + + public Cas30ServiceTicketValidator(String casServerUrlPrefix) { + super(casServerUrlPrefix); + } + + @Override + protected String getUrlSuffix() { + return "p3/serviceValidate"; + } +}