无法导入 springframework.security.extensions 并找到 saml() 方法
Can't import springframework.security.extensions and find saml() method
org.springframework.security.extensions.saml2.config.SAMLConfigurer不存在
至少我不能在我的安全配置中导入 org.springframework.security.extensions.saml2.config.SAMLConfigurer class 方法 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>
如果您知道如何解决此问题,请分享您的经验。
如果您需要更多信息 - 我会解决这个问题。
请补充:
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;
在 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>
并在上面添加下面的静态导入 class
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;
org.springframework.security.extensions.saml2.config.SAMLConfigurer不存在
至少我不能在我的安全配置中导入 org.springframework.security.extensions.saml2.config.SAMLConfigurer class 方法 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>
如果您知道如何解决此问题,请分享您的经验。
如果您需要更多信息 - 我会解决这个问题。
请补充:
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;
在 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>
并在上面添加下面的静态导入 class
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;