use of org.springframework.security.web.access.channel.ChannelProcessingFilter in project motech by motech.
the class SecurityRuleBuilder method addSecureChannel.
private void addSecureChannel(List<Filter> filters, Protocol protocol) {
ChannelProcessingFilter channelProcessingFilter = new ChannelProcessingFilter();
channelProcessingFilter.setChannelDecisionManager(channelDecisionManager);
RequestMatcher anyRequest = AnyRequestMatcher.INSTANCE;
LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<>();
Collection<ConfigAttribute> configAtts = new ArrayList<>();
switch(protocol) {
case HTTP:
configAtts.add(new SecurityConfig("ANY_CHANNEL"));
break;
case HTTPS:
configAtts.add(new SecurityConfig("REQUIRES_SECURE_CHANNEL"));
break;
default:
}
requestMap.put(anyRequest, configAtts);
FilterInvocationSecurityMetadataSource securityMetadataSource = new DefaultFilterInvocationSecurityMetadataSource(requestMap);
channelProcessingFilter.setSecurityMetadataSource(securityMetadataSource);
filters.add(channelProcessingFilter);
}
Aggregations