| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.acegisecurity.securechannel; |
| 17 |
|
|
| 18 |
|
import org.acegisecurity.ConfigAttribute; |
| 19 |
|
import org.acegisecurity.ConfigAttributeDefinition; |
| 20 |
|
|
| 21 |
|
import org.acegisecurity.intercept.web.FilterInvocation; |
| 22 |
|
|
| 23 |
|
import org.springframework.beans.factory.InitializingBean; |
| 24 |
|
|
| 25 |
|
import org.springframework.util.Assert; |
| 26 |
|
|
| 27 |
|
import java.io.IOException; |
| 28 |
|
|
| 29 |
|
import java.util.Iterator; |
| 30 |
|
|
| 31 |
|
import javax.servlet.ServletException; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
7 |
public class InsecureChannelProcessor implements InitializingBean, ChannelProcessor { |
| 46 |
|
|
| 47 |
|
|
| 48 |
7 |
private ChannelEntryPoint entryPoint = new RetryWithHttpEntryPoint(); |
| 49 |
7 |
private String insecureKeyword = "REQUIRES_INSECURE_CHANNEL"; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
public void afterPropertiesSet() throws Exception { |
| 54 |
4 |
Assert.hasLength(insecureKeyword, "insecureKeyword required"); |
| 55 |
2 |
Assert.notNull(entryPoint, "entryPoint required"); |
| 56 |
1 |
} |
| 57 |
|
|
| 58 |
|
public void decide(FilterInvocation invocation, ConfigAttributeDefinition config) |
| 59 |
|
throws IOException, ServletException { |
| 60 |
3 |
if ((invocation == null) || (config == null)) { |
| 61 |
1 |
throw new IllegalArgumentException("Nulls cannot be provided"); |
| 62 |
|
} |
| 63 |
|
|
| 64 |
2 |
Iterator iter = config.getConfigAttributes(); |
| 65 |
|
|
| 66 |
6 |
while (iter.hasNext()) { |
| 67 |
4 |
ConfigAttribute attribute = (ConfigAttribute) iter.next(); |
| 68 |
|
|
| 69 |
4 |
if (supports(attribute)) { |
| 70 |
2 |
if (invocation.getHttpRequest().isSecure()) { |
| 71 |
1 |
entryPoint.commence(invocation.getRequest(), invocation.getResponse()); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
4 |
} |
| 75 |
2 |
} |
| 76 |
|
|
| 77 |
|
public ChannelEntryPoint getEntryPoint() { |
| 78 |
2 |
return entryPoint; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
public String getInsecureKeyword() { |
| 82 |
8 |
return insecureKeyword; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
public void setEntryPoint(ChannelEntryPoint entryPoint) { |
| 86 |
2 |
this.entryPoint = entryPoint; |
| 87 |
2 |
} |
| 88 |
|
|
| 89 |
|
public void setInsecureKeyword(String secureKeyword) { |
| 90 |
3 |
this.insecureKeyword = secureKeyword; |
| 91 |
3 |
} |
| 92 |
|
|
| 93 |
|
public boolean supports(ConfigAttribute attribute) { |
| 94 |
7 |
if ((attribute != null) && (attribute.getAttribute() != null) |
| 95 |
|
&& attribute.getAttribute().equals(getInsecureKeyword())) { |
| 96 |
3 |
return true; |
| 97 |
|
} else { |
| 98 |
4 |
return false; |
| 99 |
|
} |
| 100 |
|
} |
| 101 |
|
} |