| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.acegisecurity.providers.cas.proxy; |
| 17 |
|
|
| 18 |
|
import org.acegisecurity.AcegiMessageSource; |
| 19 |
|
|
| 20 |
|
import org.acegisecurity.providers.cas.CasProxyDecider; |
| 21 |
|
import org.acegisecurity.providers.cas.ProxyUntrustedException; |
| 22 |
|
|
| 23 |
|
import org.apache.commons.logging.Log; |
| 24 |
|
import org.apache.commons.logging.LogFactory; |
| 25 |
|
|
| 26 |
|
import org.springframework.beans.factory.InitializingBean; |
| 27 |
|
|
| 28 |
|
import org.springframework.context.MessageSource; |
| 29 |
|
import org.springframework.context.MessageSourceAware; |
| 30 |
|
import org.springframework.context.support.MessageSourceAccessor; |
| 31 |
|
|
| 32 |
|
import org.springframework.util.Assert; |
| 33 |
|
|
| 34 |
|
import java.util.List; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
6 |
public class NamedCasProxyDecider implements CasProxyDecider, InitializingBean, MessageSourceAware { |
| 42 |
|
|
| 43 |
|
|
| 44 |
2 |
private static final Log logger = LogFactory.getLog(NamedCasProxyDecider.class); |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
private List validProxies; |
| 49 |
6 |
protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
public void afterPropertiesSet() throws Exception { |
| 54 |
3 |
Assert.notNull(this.validProxies, "A validProxies list must be set"); |
| 55 |
2 |
Assert.notNull(this.messages, "A message source must be set"); |
| 56 |
2 |
} |
| 57 |
|
|
| 58 |
|
public void confirmProxyListTrusted(List proxyList) |
| 59 |
|
throws ProxyUntrustedException { |
| 60 |
4 |
Assert.notNull(proxyList, "proxyList cannot be null"); |
| 61 |
|
|
| 62 |
3 |
if (logger.isDebugEnabled()) { |
| 63 |
0 |
logger.debug("Proxy list: " + proxyList.toString()); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
3 |
if (proxyList.size() == 0) { |
| 67 |
|
|
| 68 |
1 |
return; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
2 |
if (!validProxies.contains(proxyList.get(0))) { |
| 72 |
1 |
throw new ProxyUntrustedException(messages.getMessage("NamedCasProxyDecider.untrusted", |
| 73 |
|
new Object[] {proxyList.get(0)}, "Nearest proxy {0} is untrusted")); |
| 74 |
|
} |
| 75 |
1 |
} |
| 76 |
|
|
| 77 |
|
public List getValidProxies() { |
| 78 |
1 |
return validProxies; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
public void setMessageSource(MessageSource messageSource) { |
| 82 |
0 |
this.messages = new MessageSourceAccessor(messageSource); |
| 83 |
0 |
} |
| 84 |
|
|
| 85 |
|
public void setValidProxies(List validProxies) { |
| 86 |
3 |
this.validProxies = validProxies; |
| 87 |
3 |
} |
| 88 |
|
} |