无法导入springframework.security.extensions并找到saml()方法

阿尔特姆·费多托夫(Artem Fedotov)

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>

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

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

dcba dcba

pom.xml文件中添加以下Maven依赖项

<dependencies>
<dependency>
    <groupId>org.springframework.security.extensions</groupId>
    <artifactId>spring-security-saml-dsl</artifactId>
    <version>1.0.0.M3</version>
</dependency>
</dependencies>

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/libs-milestone</url>
    </repository>
</repositories>

并在上面的类中添加下面的静态导入

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

导入org.springframework.security无法解析

Spring Security-无法找到:org.springframework.ldap.core.support.BaseLdapPathContextSource

无法找到 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' 类型的 Bean。- 春季安全

Spring Security无法找到NamespaceHandler

Spring 3.0-无法找到XML模式名称空间的Spring NamespaceHandler [http://www.springframework.org/schema/security]

使用 spring 4 获取“无法为 XML 架构命名空间 [http://www.springframework.org/schema/security] 找到 Spring NamespaceHandler”

无法从SpEL中找到Spring Security主体

导入sun.security.ec无法解析

Spring Security SAML实施

javax.security.auth.login.LoginException:无法找到LoginModule类:org.jboss.security.ClientLoginModule

在哪里可以找到org.springframework.security.oauth2.provider.DefaultOAuth2RequestFactory类?

无法在 springframework 数据 4 中找到“UpdateQueryBuilder”

Spring Security SAML signingKey / encryptionKey

Angular无法找到接口导入

GitHub导入:无法找到Gemfile

“导入org.springframework无法解析。”

Symfony Security的getUser方法无法获取我的用户存储库

无法自动连线栏位:专用org.springframework.security.crypto.password.PasswordEncoder;

无法自动连线栏位:私人org.springframework.security.authentication.AuthenticationManager

java.lang.ClassCastException:类org.springframework.security.core.userdetails.User无法转换为class

org.springframework.security.core.userdetails.User无法转换为MyUserDetails

无法解析 org.springframework.security.core.GrantedAuthority 即使它已下载/显示在项目库下

设置bean属性'sourceList'时无法解析对bean'org.springframework.security.web.DefaultSecurityFilterChain#0'的引用

添加spring-security-oauth2后无法实例化接口org.springframework.context.ApplicationListener

无法解析org.springframework.security.authentication.AuthenticationManager类型。从所需的.class文件间接引用它

Spring 安全应用程序没有为 org.springframework.security.authentication.UsernamePasswordAuthenticationToken 找到 AuthenticationProvider

spring ws 无法验证请求:未找到 WS-Security 标头

Symfony 2.8 无法找到模板“FOSUserBundle:Security:login.html.twig”

无法导入 aws_security_group.sg_name,会与现有资源发生冲突