View SamlBootstrapInit.java
@Bean
public static SAMLBootstrap samlBootstrap() {
// return new SAMLBootstrap();
return new SamlBootstrapSha256();
}
View SamlBootstrapSha256.java
public class SamlBootstrapSha256 extends SAMLBootstrap {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
super.postProcessBeanFactory(beanFactory);
BasicSecurityConfiguration config =
(BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
View SamlKeyStore.java
@Bean
public KeyManager keyManager() {
DefaultResourceLoader loader = new DefaultResourceLoader();
Resource storeFile = loader.getResource("classpath:/saml/samlKeystore.jks");
String storePass = "secure";
Map<String, String> passwords = new HashMap<>();
passwords.put("samuraj", "secure");
String defaultKey = "samuraj";
return new JKSKeyManager(storeFile, storePass, passwords, defaultKey);
View SamlMetadataFilterChainComplete.java
@Bean
public FilterChainProxy samlFilter() throws Exception {
List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
chains.add(new DefaultSecurityFilterChain(
new AntPathRequestMatcher("/saml/login/**"),
samlEntryPoint()));
chains.add(new DefaultSecurityFilterChain(
new AntPathRequestMatcher("/saml/logout/**"),
samlLogoutFilter()));
View SamlHttpSecurity.java
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf()
.disable();
http
.addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.class)
View saml-dependencies-build.gradle
ext {
springVersion = '5.0.2.RELEASE'
springSecurityVersion = '5.0.0.RELEASE'
springSamlVersion = '1.0.3.RELEASE'
}
dependencies {
implementation "org.springframework:spring-webmvc:${springVersion}"
implementation "org.springframework.security:spring-security-web:${springSecurityVersion}"
implementation "org.springframework.security:spring-security-config:${springSecurityVersion}"
View SamlMetadataFilterChainExample.java
@Bean
public FilterChainProxy samlFilter() throws Exception {
List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
chains.add(new DefaultSecurityFilterChain(
new AntPathRequestMatcher("/saml/metadata/**"), metadataDisplayFilter()));
return new FilterChainProxy(chains);
}
View MetadataGeneratorFilterExample.java
@Bean
public MetadataGeneratorFilter metadataGeneratorFilter() {
MetadataGenerator metadataGenerator = new MetadataGenerator();
metadataGenerator.setEntityId("cz:swsamuraj:wicket:spring:sp");
metadataGenerator.setKeyManager(keyManager());
return new MetadataGeneratorFilter(metadataGenerator);
}
View AdfsMetadataProviderExample.java
@Bean
public MetadataProvider metadataProvider()
throws ResourceException, MetadataProviderException {
ClasspathResource resource =
new ClasspathResource("/metadata/FederationMetadata.xml");
ResourceBackedMetadataProvider provider = new
ResourceBackedMetadataProvider(timer, resource);
provider.setParserPool(parserPool());
View off-log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Loggers>
<Root level="off"/>
</Loggers>
</Configuration>