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