org.springframework.security.extensions.saml2.config.SAMLConfigurer不存在

至少我无法在尚未定义方法saml()的“安全配置”类中导入org.springframework.security.extensions.saml2.config.SAMLConfigurer。

SecurityConfiguration.java的源代码:

    package com.hem.configuration;

    import com.hem.properties.ServerProxy;
    import com.hem.properties.ServerSsl;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    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.extensions.saml2.config.SAMLConfigurer;

    @EnableWebSecurity
    @Configuration
    @EnableGlobalMethodSecurity(securedEnabled = true)
    public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

        private static final String HTTPS = "https";

        @Value("${security.saml2.metadata-url}")
        private String metadataUrl;

        @Value("${saml.entity.id}")
        private String entityId;

        @Autowired
        private ServerProxy serverProxy;

        @Autowired
        private ServerSsl serverSsl;

        @Autowired
        private SAMLUserDetailsServiceImpl samlUserDetailsServiceImpl;

        @Override
        protected void configure(final HttpSecurity http) throws Exception {
            http
                .authorizeRequests()
                    .antMatchers("/saml*").permitAll()
                    .antMatchers("/images/apple-touch-icon.png").permitAll()
                    .anyRequest().authenticated()
                    .and()
                .apply(saml()) //<-can't find this method
                    .userDetailsService(samlUserDetailsServiceImpl)
                    .serviceProvider()
                        .keyStore()
                            .storeFilePath(serverSsl.getKeyStore())
                            .password(serverSsl.getKeyStorePassword())
                            .keyname(serverSsl.getKeyAlias())
                            .keyPassword(serverSsl.getKeyStorePassword())
                            .and()
                        .protocol(HTTPS)
                        .hostname(String.format("%s:%s", serverProxy.getHost(), serverProxy.getPort()))
                        .basePath("/")
                        .entityId(entityId)
                        .and()
                    .identityProvider()
                    .metadataFilePath(this.metadataUrl);
        }
    }




我的pom.xml中的依赖项

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.security.extensions</groupId>
    <artifactId>spring-security-saml2-core</artifactId>
    <version>1.0.3.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security.extensions</groupId>
    <artifactId>spring-security-saml-dsl</artifactId>
    <version>1.0.0.M2</version>
</dependency>


如果您知道如何解决此问题,请分享您的经验。

如果您需要更多信息-我会解决该请求。

最佳答案

请加:

import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;

10-06 02:36