Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Spring配置文件中设置WebSoProfileConsumerImpl_Spring_Spring Boot_Spring Security_Saml 2.0_Spring Saml - Fatal编程技术网

如何在Spring配置文件中设置WebSoProfileConsumerImpl

如何在Spring配置文件中设置WebSoProfileConsumerImpl,spring,spring-boot,spring-security,saml-2.0,spring-saml,Spring,Spring Boot,Spring Security,Saml 2.0,Spring Saml,我面临将WebsProfileConsumerImpl指定到Spring配置文件的问题。我试图修改这个bean中的responseSkew,但是在添加了WebsProfileConsumerImpl的配置之后,我遇到了MetadataManager问题 应用程序无法启动 说明: org.springframework.security.saml.webso.AbstractProfileBase中方法setMetadata的参数0需要一个类型为“org.springframework.sec

我面临将WebsProfileConsumerImpl指定到Spring配置文件的问题。我试图修改这个bean中的responseSkew,但是在添加了WebsProfileConsumerImpl的配置之后,我遇到了MetadataManager问题


应用程序无法启动


说明:

org.springframework.security.saml.webso.AbstractProfileBase中方法setMetadata的参数0需要一个类型为“org.springframework.security.saml.metadata.MetadataManager”的bean,但找不到该bean

行动:

考虑定义“org.springframework.security.saml.metadata.MetadataManager”类型的bean

有人能帮我解决这个问题吗

我已经浏览了这个链接:但是它没有指定如何在配置中设置它

我的代码

    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;
    } 

}
import static org.springframework.security.extensions.saml2.config.samlconfiguer.saml;
导入org.springframework.beans.factory.annotation.Qualifier;
导入org.springframework.beans.factory.annotation.Value;
导入org.springframework.context.annotation.Bean;
导入org.springframework.context.annotation.Configuration;
导入org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
导入org.springframework.security.config.annotation.web.builders.HttpSecurity;
导入org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
导入org.springframework.security.config.annotation.web.configuration.websecurityConfigureAdapter;
导入org.springframework.security.saml.webso.websoprofileconsumer;
导入org.springframework.security.saml.websso.websoprofileConsumerImpl;
@启用Web安全性
@配置
@EnableGlobalMethodSecurity(securedEnabled=true)
公共类安全配置扩展了WebSecurity配置适配器{
@值(${security.saml2.metadata url}”)
字符串元数据URL;
@值(${server.ssl.key别名}”)
字符串键别名;
@值(${server.ssl.key store password}”)
字符串密码;
@值(“${server.port}”)
字符串端口;
@值(${server.ssl.key store}”)
字符串keystrefilepath;
@值(${security.saml2.responseSkew}”)
int responseSkew=0;
@凌驾
受保护的void configure(最终HttpSecurity http)引发异常{
http
.授权请求()
.antMatchers(“/saml*”).permitAll()
.anyRequest().authenticated()
.及()
.apply(saml())
.serviceProvider()
.keyStore()
.storeFilePath(此.keystrefilepath)
.password(此.password)
.keyname(此.keyAlias)
.keyPassword(此.password)
.及()
.协议(“https”)
.hostname(String.format(“%s:%s”,“localhost”,this.port))
.basePath(“/”)
.及()
.identityProvider()
.metadataFilePath(this.metadataUrl).and();

/*映射如果不需要WebsProfileConsumer作为bean访问应用程序的其余部分,可以在configure方法中创建它,如下所示:

@Override
protected void configure(final HttpSecurity http) throws Exception {
    WebSSOProfileConsumerImpl consumerImpl = new WebSSOProfileConsumerImpl();
    consumerImpl.setResponseSkew(this.responseSkew);

    http
        .authorizeRequests()
            .antMatchers("/saml*").permitAll()
            .anyRequest().authenticated()
            .and()
        .apply(saml())
            .serviceProvider()
                .ssoProfileConsumer(consumerImpl)  // <-- added here
                .keyStore()
                // Your method continues as before
@覆盖
受保护的void configure(最终HttpSecurity http)引发异常{
websoprofileconsumeripl consumeripl=新的websoprofileconsumeripl();
consumerImpl.setResponseSkew(this.responseSkew);
http
.授权请求()
.antMatchers(“/saml*”).permitAll()
.anyRequest().authenticated()
.及()
.apply(saml())
.serviceProvider()

.ssoProfileConsumer(consumeripl)//你有没有可能解决这个问题?我没有办法找到serviceProvider的“ssoProfileConsumer”方法。对此有什么见解吗?