【发布时间】:2018-10-02 06:47:15
【问题描述】:
我面临将 WebSSOProfileConsumerImpl 指定到我的 Spring 配置文件的问题。我正在尝试修改此 bean 中的 responseSkew,但在为 WebSSOProfileConsumerImpl 添加配置后,我遇到了 MetadataManager 问题
应用程序启动失败
说明:
org.springframework.security.saml.websso.AbstractProfileBase 中方法 setMetadata 的参数 0 需要一个无法找到的 'org.springframework.security.saml.metadata.MetadataManager' 类型的 bean。
行动:
考虑定义一个 'org.springframework.security.saml.metadata.MetadataManager' 类型的 bean
谁能帮我解决这个问题?
我已经浏览了链接:http://docs.spring.io/spring-security-saml/docs/current/reference/html/configuration-advanced.html,但它没有指定如何在配置中进行设置。
我的代码
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.saml.websso.WebSSOProfileConsumer;
import org.springframework.security.saml.websso.WebSSOProfileConsumerImpl;
@EnableWebSecurity
@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Value("${security.saml2.metadata-url}")
String metadataUrl;
@Value("${server.ssl.key-alias}")
String keyAlias;
@Value("${server.ssl.key-store-password}")
String password;
@Value("${server.port}")
String port;
@Value("${server.ssl.key-store}")
String keyStoreFilePath;
@Value("${security.saml2.responseSkew}")
int responseSkew = 0;
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/saml*").permitAll()
.anyRequest().authenticated()
.and()
.apply(saml())
.serviceProvider()
.keyStore()
.storeFilePath(this.keyStoreFilePath)
.password(this.password)
.keyname(this.keyAlias)
.keyPassword(this.password)
.and()
.protocol("https")
.hostname(String.format("%s:%s", "localhost", this.port))
.basePath("/")
.and()
.identityProvider()
.metadataFilePath(this.metadataUrl).and();
/* Map<? extends Object, Object> sharedObjects = new Map<? extends Object>, Object>(http.getSharedObjects());
sharedObjects.put(WebSSOProfileConsumer.class, webSSOprofileConsumerImpl());*/
}
@Bean
@Qualifier("webSSOprofileConsumer")
public WebSSOProfileConsumer webSSOprofileConsumerImpl() {
WebSSOProfileConsumerImpl consumerImpl = new WebSSOProfileConsumerImpl();
consumerImpl.setResponseSkew(this.responseSkew);
return consumerImpl;
}
}
【问题讨论】:
-
你有没有机会解决这个问题?
标签: spring spring-boot spring-security saml-2.0 spring-saml