本文整理了Java中org.springframework.security.config.annotation.web.configurers.X509Configurer
类的一些代码示例,展示了X509Configurer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509Configurer
类的具体详情如下:
包路径:org.springframework.security.config.annotation.web.configurers.X509Configurer
类名称:X509Configurer
[英]Adds X509 based pre authentication to an application. Since validating the certificate happens when the client connects, the requesting and validation of the client certificate should be performed by the container. Spring Security will then use the certificate to look up the Authentication for the user. Security Filters
The following Filters are populated
Shared Objects Created
The following shared objects are created
Shared Objects Used
The following shared objects are used:
代码示例来源:origin: spring-projects/spring-security
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getAuthenticationUserDetailsService(
H http) {
if (authenticationUserDetailsService == null) {
userDetailsService(http.getSharedObject(UserDetailsService.class));
}
return authenticationUserDetailsService;
}
代码示例来源:origin: spring-projects/spring-security
/**
* Shortcut for invoking
* {@link #authenticationUserDetailsService(AuthenticationUserDetailsService)} with a
* {@link UserDetailsByNameServiceWrapper}.
*
* @param userDetailsService the {@link UserDetailsService} to use
* @return the {@link X509Configurer} for further customizations
*/
public X509Configurer<H> userDetailsService(UserDetailsService userDetailsService) {
UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService = new UserDetailsByNameServiceWrapper<>();
authenticationUserDetailsService.setUserDetailsService(userDetailsService);
return authenticationUserDetailsService(authenticationUserDetailsService);
}
代码示例来源:origin: spring-projects/spring-security
/**
* Configures X509 based pre authentication.
*
* <h2>Example Configuration</h2>
*
* The following configuration will attempt to extract the username from the X509
* certificate. Remember that the Servlet Container will need to be configured to
* request client certificates in order for this to work.
*
* <pre>
* @Configuration
* @EnableWebSecurity
* public class X509SecurityConfig extends WebSecurityConfigurerAdapter {
*
* @Override
* protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and()
* // Example x509() configuration
* .x509();
* }
* }
* </pre>
*
* @return the {@link X509Configurer} for further customizations
* @throws Exception
*/
public X509Configurer<HttpSecurity> x509() throws Exception {
return getOrApply(new X509Configurer<>());
}
代码示例来源:origin: SpringOne2GX-2014/microservice-security
@Override
protected void configure(HttpSecurity http) throws Exception {
UserDetailsService userDetails = new InMemoryUserDetailsManager(
Arrays.<UserDetails> asList(new User("rod", "N/A", AuthorityUtils
.commaSeparatedStringToAuthorityList("ROLE_USER"))));
http.authorizeRequests().anyRequest().authenticated().and().x509()
.userDetailsService(userDetails).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER).and().csrf()
.disable();
}
代码示例来源:origin: org.opensingular/singular-support
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher(REST_ANT_PATTERN)
.authorizeRequests().anyRequest().authenticated()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf().disable()
.x509()
.subjectPrincipalRegex(restUserDetailsService.getSubjectPrincipalRegex())
.userDetailsService(restUserDetailsService);
}
代码示例来源:origin: spring-projects/spring-security
@Override
public void init(H http) throws Exception {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));
http
.authenticationProvider(authenticationProvider)
.setSharedObject(AuthenticationEntryPoint.class, new Http403ForbiddenEntryPoint());
}
// @formatter:on
代码示例来源:origin: spring-projects/spring-security
@Override
public void configure(H http) throws Exception {
X509AuthenticationFilter filter = getFilter(http
.getSharedObject(AuthenticationManager.class));
http.addFilter(filter);
}
代码示例来源:origin: spring-projects/spring-security
private X509AuthenticationFilter getFilter(AuthenticationManager authenticationManager) {
if (x509AuthenticationFilter == null) {
x509AuthenticationFilter = new X509AuthenticationFilter();
x509AuthenticationFilter.setAuthenticationManager(authenticationManager);
if (x509PrincipalExtractor != null) {
x509AuthenticationFilter.setPrincipalExtractor(x509PrincipalExtractor);
}
if (authenticationDetailsSource != null) {
x509AuthenticationFilter
.setAuthenticationDetailsSource(authenticationDetailsSource);
}
x509AuthenticationFilter = postProcess(x509AuthenticationFilter);
}
return x509AuthenticationFilter;
}
代码示例来源:origin: com.netflix.genie/genie-web
.anyRequest().hasRole(USER_ROLE)
.and()
.x509().authenticationUserDetailsService(x509UserDetailsService)
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
代码示例来源:origin: org.springframework.security/spring-security-config
@Override
public void init(H http) throws Exception {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));
http
.authenticationProvider(authenticationProvider)
.setSharedObject(AuthenticationEntryPoint.class, new Http403ForbiddenEntryPoint());
}
// @formatter:on
代码示例来源:origin: org.springframework.security/spring-security-config
@Override
public void configure(H http) throws Exception {
X509AuthenticationFilter filter = getFilter(http
.getSharedObject(AuthenticationManager.class));
http.addFilter(filter);
}
代码示例来源:origin: org.springframework.security/spring-security-config
private X509AuthenticationFilter getFilter(AuthenticationManager authenticationManager) {
if (x509AuthenticationFilter == null) {
x509AuthenticationFilter = new X509AuthenticationFilter();
x509AuthenticationFilter.setAuthenticationManager(authenticationManager);
if (x509PrincipalExtractor != null) {
x509AuthenticationFilter.setPrincipalExtractor(x509PrincipalExtractor);
}
if (authenticationDetailsSource != null) {
x509AuthenticationFilter
.setAuthenticationDetailsSource(authenticationDetailsSource);
}
x509AuthenticationFilter = postProcess(x509AuthenticationFilter);
}
return x509AuthenticationFilter;
}
代码示例来源:origin: org.springframework.security/spring-security-config
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getAuthenticationUserDetailsService(
H http) {
if (authenticationUserDetailsService == null) {
userDetailsService(http.getSharedObject(UserDetailsService.class));
}
return authenticationUserDetailsService;
}
代码示例来源:origin: org.springframework.security/spring-security-config
/**
* Shortcut for invoking
* {@link #authenticationUserDetailsService(AuthenticationUserDetailsService)} with a
* {@link UserDetailsByNameServiceWrapper}.
*
* @param userDetailsService the {@link UserDetailsService} to use
* @return the {@link X509Configurer} for further customizations
*/
public X509Configurer<H> userDetailsService(UserDetailsService userDetailsService) {
UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService = new UserDetailsByNameServiceWrapper<>();
authenticationUserDetailsService.setUserDetailsService(userDetailsService);
return authenticationUserDetailsService(authenticationUserDetailsService);
}
代码示例来源:origin: org.springframework.security/spring-security-javaconfig
@Override
public void init(H http) throws Exception {
PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
authenticationProvider.setPreAuthenticatedUserDetailsService(getAuthenticationUserDetailsService(http));
http
.authenticationProvider(authenticationProvider)
.setSharedObject(AuthenticationEntryPoint.class,new Http403ForbiddenEntryPoint());
}
代码示例来源:origin: org.springframework.security/spring-security-javaconfig
@Override
public void configure(H http) throws Exception {
X509AuthenticationFilter filter = getFilter(http.getAuthenticationManager());
http.addFilter(filter);
}
代码示例来源:origin: apache/servicemix-bundles
private X509AuthenticationFilter getFilter(AuthenticationManager authenticationManager) {
if (x509AuthenticationFilter == null) {
x509AuthenticationFilter = new X509AuthenticationFilter();
x509AuthenticationFilter.setAuthenticationManager(authenticationManager);
if (x509PrincipalExtractor != null) {
x509AuthenticationFilter.setPrincipalExtractor(x509PrincipalExtractor);
}
if (authenticationDetailsSource != null) {
x509AuthenticationFilter
.setAuthenticationDetailsSource(authenticationDetailsSource);
}
x509AuthenticationFilter = postProcess(x509AuthenticationFilter);
}
return x509AuthenticationFilter;
}
代码示例来源:origin: org.springframework.security/spring-security-config
/**
* Configures X509 based pre authentication.
*
* <h2>Example Configuration</h2>
*
* The following configuration will attempt to extract the username from the X509
* certificate. Remember that the Servlet Container will need to be configured to
* request client certificates in order for this to work.
*
* <pre>
* @Configuration
* @EnableWebSecurity
* public class X509SecurityConfig extends WebSecurityConfigurerAdapter {
*
* @Override
* protected void configure(HttpSecurity http) throws Exception {
* http.authorizeRequests().antMatchers("/**").hasRole("USER").and()
* // Example x509() configuration
* .x509();
* }
* }
* </pre>
*
* @return the {@link X509Configurer} for further customizations
* @throws Exception
*/
public X509Configurer<HttpSecurity> x509() throws Exception {
return getOrApply(new X509Configurer<>());
}
代码示例来源:origin: org.springframework.security/spring-security-javaconfig
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getAuthenticationUserDetailsService(H http) {
if(authenticationUserDetailsService == null) {
userDetailsService(http.getSharedObject(UserDetailsService.class));
}
return authenticationUserDetailsService;
}
代码示例来源:origin: org.springframework.security/spring-security-javaconfig
/**
* Shortcut for invoking {@link #authenticationUserDetailsService(AuthenticationUserDetailsService)} with a {@link UserDetailsByNameServiceWrapper}.
*
* @param userDetailsService the {@link UserDetailsService} to use
* @return the {@link X509Configurer} for further customizations
*/
public X509Configurer<H> userDetailsService(
UserDetailsService userDetailsService) {
UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken> authenticationUserDetailsService = new UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken>();
authenticationUserDetailsService.setUserDetailsService(userDetailsService);
return authenticationUserDetailsService(authenticationUserDetailsService);
}
内容来源于网络,如有侵权,请联系作者删除!