org.springframework.security.extensions.saml2.config.SAMLConfigurer不存在
至少我无法在安全配置类中导入 org.springframework.security.extensions.saml2.config.SAMLConfigurer ,方法 saml()尚未被导入定义。
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>
如果您知道如何解决此问题,请分享您的经验。
如果您需要更多信息-我会解决该请求。
答案 0 :(得分:2)
在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;
答案 1 :(得分:1)
请添加:
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;