Skip to content

Instantly share code, notes, and snippets.

package com.example;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
[Manager]
# Limit maximum of open files
DefaultLimitNOFILE=65535
#<domain> <type> <item> <value>
guido soft nofile 2048
guido hard nofile 10240
@Bean
public static SAMLBootstrap samlBootstrap() {
// return new SAMLBootstrap();
return new SamlBootstrapSha256();
}
public class SamlBootstrapSha256 extends SAMLBootstrap {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
super.postProcessBeanFactory(beanFactory);
BasicSecurityConfiguration config =
(BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
@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);
@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()));
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf()
.disable();
http
.addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.class)
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}"