parent
ef520c834f
commit
c12836c9d6
|
|
@ -76,29 +76,33 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<version>${spring.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<artifactId>spring-mock</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<spring.version>2.0.8</spring.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal
|
|||
if (CommonUtils.isNotBlank(allowAnyProxy) || CommonUtils.isNotBlank(allowedProxyChains)) {
|
||||
final Cas20ProxyTicketValidator v = new Cas20ProxyTicketValidator(casServerUrlPrefix);
|
||||
v.setAcceptAnyProxy(Boolean.parseBoolean(allowAnyProxy));
|
||||
v.setAllowedProxyChains(constructListOfProxies(allowedProxyChains));
|
||||
v.setAllowedProxyChains(new ProxyList(constructListOfProxies(allowedProxyChains)));
|
||||
validator = v;
|
||||
} else {
|
||||
validator = new Cas20ServiceTicketValidator(casServerUrlPrefix);
|
||||
|
|
@ -119,7 +119,7 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal
|
|||
|
||||
final String[] splitProxies = proxies.split("\n");
|
||||
final List items = Arrays.asList(splitProxies);
|
||||
final ProxyListPropertyEditor editor = new ProxyListPropertyEditor();
|
||||
final ProxyListEditor editor = new ProxyListEditor();
|
||||
editor.setValue(items);
|
||||
return (List) editor.getValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ package org.jasig.cas.client.validation;
|
|||
|
||||
import org.jasig.cas.client.util.XmlUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -24,12 +21,16 @@ public final class Cas20ProxyTicketValidator extends Cas20ServiceTicketValidator
|
|||
private boolean acceptAnyProxy;
|
||||
|
||||
/** This should be a list of an array of Strings */
|
||||
private List allowedProxyChains = new ArrayList();
|
||||
private ProxyList allowedProxyChains = new ProxyList();
|
||||
|
||||
public Cas20ProxyTicketValidator(final String casServerUrlPrefix) {
|
||||
super(casServerUrlPrefix);
|
||||
}
|
||||
|
||||
public ProxyList getAllowedProxyChains() {
|
||||
return this.allowedProxyChains;
|
||||
}
|
||||
|
||||
protected String getUrlSuffix() {
|
||||
return "proxyValidate";
|
||||
}
|
||||
|
|
@ -43,10 +44,8 @@ public final class Cas20ProxyTicketValidator extends Cas20ServiceTicketValidator
|
|||
return;
|
||||
}
|
||||
|
||||
for (Iterator iter = this.allowedProxyChains.iterator(); iter.hasNext();) {
|
||||
if (Arrays.equals(proxiedList, (String[]) iter.next())) {
|
||||
return;
|
||||
}
|
||||
if (allowedProxyChains.contains(proxiedList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidProxyChainTicketValidationException("Invalid proxy chain: " + proxies.toString());
|
||||
|
|
@ -56,7 +55,7 @@ public final class Cas20ProxyTicketValidator extends Cas20ServiceTicketValidator
|
|||
this.acceptAnyProxy = acceptAnyProxy;
|
||||
}
|
||||
|
||||
public void setAllowedProxyChains(final List allowedProxyChains) {
|
||||
public void setAllowedProxyChains(final ProxyList allowedProxyChains) {
|
||||
this.allowedProxyChains = allowedProxyChains;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license
|
||||
* distributed with this file and available online at
|
||||
* http://www.ja-sig.org/products/cas/overview/license/index.html
|
||||
*/
|
||||
package org.jasig.cas.client.validation;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.beans.SimpleBeanInfo;
|
||||
|
||||
import org.springframework.beans.propertyeditors.CustomBooleanEditor;
|
||||
|
||||
/**
|
||||
* BeanInfo support for using this class with Spring. Configures a ProxyListPropertyEditor to be used with the
|
||||
* Cas20ProxyTicketValidator when Spring is used to configure the CAS client.
|
||||
*
|
||||
* @author Scott Battaglia
|
||||
* @version $Revision$ $Date$
|
||||
* @since 3.1
|
||||
*/
|
||||
public final class Cas20ProxyTicketValidatorBeanInfo extends SimpleBeanInfo {
|
||||
|
||||
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||
try {
|
||||
final PropertyDescriptor descriptor = new PropertyDescriptor("allowedProxyChains", Cas20ProxyTicketValidator.class, null, "setAllowedProxyChains") {
|
||||
public PropertyEditor createPropertyEditor(final Object bean) {
|
||||
return new ProxyListPropertyEditor();
|
||||
}
|
||||
};
|
||||
|
||||
final PropertyDescriptor acceptAnyProxy = new PropertyDescriptor("acceptAnyProxy", Cas20ProxyTicketValidator.class, null, "setAcceptAnyProxy") {
|
||||
public PropertyEditor createPropertyEditor(final Object bean) {
|
||||
return new CustomBooleanEditor(true);
|
||||
}
|
||||
};
|
||||
|
||||
return new PropertyDescriptor[] {descriptor, acceptAnyProxy};
|
||||
} catch (final IntrospectionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license
|
||||
* distributed with this file and available online at
|
||||
* http://www.ja-sig.org/products/cas/overview/license/index.html
|
||||
*/
|
||||
package org.jasig.cas.client.validation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Holding class for the proxy list to make Spring configuration easier.
|
||||
*
|
||||
* @author Scott Battaglia
|
||||
* @version $Revision$ $Date$
|
||||
* @since 3.1.3
|
||||
*/
|
||||
public final class ProxyList {
|
||||
|
||||
private final List proxyChains;
|
||||
|
||||
public ProxyList(final List proxyChains) {
|
||||
this.proxyChains = proxyChains;
|
||||
}
|
||||
|
||||
public ProxyList() {
|
||||
this(new ArrayList());
|
||||
}
|
||||
|
||||
public boolean contains(String[] proxiedList) {
|
||||
for (Iterator iter = this.proxyChains.iterator(); iter.hasNext();) {
|
||||
if (Arrays.equals(proxiedList, (String[]) iter.next())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
package org.jasig.cas.client.validation;
|
||||
|
||||
import org.jasig.cas.client.util.CommonUtils;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
|
@ -12,8 +14,6 @@ import java.io.StringReader;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jasig.cas.client.util.CommonUtils;
|
||||
|
||||
/**
|
||||
* Convert a String-formatted list of acceptable proxies to an array.
|
||||
*
|
||||
|
|
@ -22,7 +22,7 @@ import org.jasig.cas.client.util.CommonUtils;
|
|||
* @since 3.1
|
||||
*
|
||||
*/
|
||||
public final class ProxyListPropertyEditor extends PropertyEditorSupport {
|
||||
public final class ProxyListEditor extends PropertyEditorSupport {
|
||||
|
||||
public void setAsText(final String text) throws IllegalArgumentException {
|
||||
final BufferedReader reader = new BufferedReader(new StringReader(text));
|
||||
|
|
@ -9,7 +9,6 @@ import org.jasig.cas.client.PublicTestHttpServer;
|
|||
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage;
|
||||
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl;
|
||||
import org.jasig.cas.client.proxy.ProxyRetriever;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
|
@ -41,7 +40,7 @@ public final class Cas20ProxyTicketValidatorTests extends
|
|||
this.ticketValidator.setProxyCallbackUrl("test");
|
||||
this.ticketValidator.setProxyGrantingTicketStorage(getProxyGrantingTicketStorage());
|
||||
this.ticketValidator.setProxyRetriever(getProxyRetriever());
|
||||
this.ticketValidator.setAllowedProxyChains(list);
|
||||
this.ticketValidator.setAllowedProxyChains(new ProxyList(list));
|
||||
}
|
||||
|
||||
private ProxyGrantingTicketStorage getProxyGrantingTicketStorage() {
|
||||
|
|
@ -92,8 +91,8 @@ public final class Cas20ProxyTicketValidatorTests extends
|
|||
|
||||
public void testConstructionFromSpringBean() throws TicketValidationException,
|
||||
UnsupportedEncodingException {
|
||||
final ApplicationContext context = new ClassPathXmlApplicationContext("classpath:cas20ProxyTicketValidator.xml");
|
||||
final Cas20ProxyTicketValidator v = (Cas20ProxyTicketValidator) context.getBean("proxyTicketValidator");
|
||||
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:cas20ProxyTicketValidator.xml");
|
||||
final Cas20ProxyTicketValidator v = (Cas20ProxyTicketValidator) context.getBean("proxyTicketValidator");
|
||||
final Cas20ProxyTicketValidator v2 = (Cas20ProxyTicketValidator) context.getBean("proxyTicketValidatorWithAllowAnyProxy");
|
||||
|
||||
final String USERNAME = "username";
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
proxy1 proxy2 proxy3
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
<property name="proxyCallbackUrl" value="https://localhost:8443/test" />
|
||||
<property name="renew" value="true" />
|
||||
</bean>
|
||||
|
||||
<bean id="proxyTicketValidatorWithAllowAnyProxy"
|
||||
class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"
|
||||
|
|
|
|||
Loading…
Reference in New Issue