org.springframework.security.authentication.AuthenticationManager Java Examples

The following examples show how to use org.springframework.security.authentication.AuthenticationManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserLoginConfigurer.java    From ChengFeng1.5 with MIT License 5 votes vote down vote up
@Override
public void configure(B http) throws Exception {
    authFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
    authFilter.setAuthenticationFailureHandler(new UserLoginFailureHandler());
    authFilter.setSessionAuthenticationStrategy(new NullAuthenticatedSessionStrategy());

    UserInfoAuthenticationFilter filter = postProcess(authFilter);
    http.addFilterAfter(filter, LogoutFilter.class);
}
 
Example #2
Source File: SecurityConfig.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 解决 无法直接注入 AuthenticationManager
 *
 * @return
 * @throws Exception
 */
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception
{
    return super.authenticationManagerBean();
}
 
Example #3
Source File: WebSecurityConfig.java    From Hacktoberfest2019 with Apache License 2.0 5 votes vote down vote up
@Bean
public SpnegoAuthenticationProcessingFilter spnegoAuthenticationProcessingFilter(
        AuthenticationManager authenticationManager) {
    SpnegoAuthenticationProcessingFilter filter = new SpnegoAuthenticationProcessingFilter();
    filter.setAuthenticationManager(authenticationManager);
    return filter;
}
 
Example #4
Source File: JwtUsernameAndPasswordAuthenticationFilter.java    From microservices-spring-boot with MIT License 5 votes vote down vote up
public JwtUsernameAndPasswordAuthenticationFilter(AuthenticationManager authManager, JwtConfig jwtConfig) {
	this.authManager = authManager;
	this.jwtConfig = jwtConfig;
	
	// By default, UsernamePasswordAuthenticationFilter listens to "/login" path. 
	// In our case, we use "/auth". So, we need to override the defaults.
	this.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher(jwtConfig.getUri(), "POST"));
}
 
Example #5
Source File: WxSecurityConfigurer.java    From spring-microservice-exam with MIT License 5 votes vote down vote up
@Override
public void configure(HttpSecurity http) {
    // 微信登录过滤器
    WxAuthenticationFilter wxAuthenticationFilter = new WxAuthenticationFilter();
    wxAuthenticationFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
    wxAuthenticationFilter.setAuthenticationSuccessHandler(wxLoginSuccessHandler);
    wxAuthenticationFilter.setEventPublisher(defaultAuthenticationEventPublisher);
    WxAuthenticationProvider wxAuthenticationProvider = new WxAuthenticationProvider();
    wxAuthenticationProvider.setCustomUserDetailsService(userDetailsService);
    // 增加微信登录的过滤器
    http.authenticationProvider(wxAuthenticationProvider).addFilterAfter(wxAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
}
 
Example #6
Source File: JwtLoginFilter.java    From SpringSecurity-JWT-Vue-Deom with MIT License 5 votes vote down vote up
/**
 * @param defaultFilterProcessesUrl 配置要过滤的地址,即登陆地址
 * @param authenticationManager 认证管理器,校验身份时会用到
 * @param loginCountService */
public JwtLoginFilter(String defaultFilterProcessesUrl, AuthenticationManager authenticationManager,
                      VerifyCodeService verifyCodeService, LoginCountService loginCountService) {
    super(new AntPathRequestMatcher(defaultFilterProcessesUrl));
    this.loginCountService = loginCountService;
    // 为 AbstractAuthenticationProcessingFilter 中的属性赋值
    setAuthenticationManager(authenticationManager);
    this.verifyCodeService = verifyCodeService;
}
 
Example #7
Source File: TokenLoginConfigurer.java    From ChengFeng1.5 with MIT License 5 votes vote down vote up
@Override
public void configure(B http) throws Exception {
	authFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
	authFilter.setAuthenticationFailureHandler(new TokenRefreshFailureHandler());

	TokenAuthenticationFilter filter = postProcess(authFilter);
	http.addFilterBefore(filter, LogoutFilter.class);
}
 
Example #8
Source File: JwtSsoBasedAuthenticationFilter.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
public JwtSsoBasedAuthenticationFilter(AuthenticationManager authenticationManager,
        AuthServerProperties authServerProperties) {
    super(authenticationManager);
    if (log.isDebugEnabled()) {
        log.debug("Filter:{} applied", this.getClass().getSimpleName());
    }

    this.authServerProperties = authServerProperties;

    jwtBuilder = new DefaultJwtBuilder(this.authServerProperties.getJwtToken());
}
 
Example #9
Source File: SmsCodeAuthenticationSecurityConfig.java    From pre with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void configure(HttpSecurity http) throws Exception {
    super.configure(http);
    //自定义SmsCodeAuthenticationFilter过滤器
    SmsCodeAuthenticationFilter smsCodeAuthenticationFilter = new SmsCodeAuthenticationFilter();
    smsCodeAuthenticationFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
    smsCodeAuthenticationFilter.setAuthenticationSuccessHandler(preAuthenticationSuccessHandler);
    smsCodeAuthenticationFilter.setAuthenticationFailureHandler(preAuthenticationFailureHandler);
    //设置自定义SmsCodeAuthenticationProvider的认证器userDetailsService
    SmsCodeAuthenticationProvider smsCodeAuthenticationProvider = new SmsCodeAuthenticationProvider();
    smsCodeAuthenticationProvider.setUserDetailService(userDetailsService);
    //在UsernamePasswordAuthenticationFilter过滤前执行
    http.authenticationProvider(smsCodeAuthenticationProvider).addFilterAfter(smsCodeAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
}
 
Example #10
Source File: SecurityConfig.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public TenantUsernamePasswordAuthenticationFilter tenantAuthenticationFilter(AuthenticationManager authenticationManager) {
	TenantUsernamePasswordAuthenticationFilter filter = new TenantUsernamePasswordAuthenticationFilter();
	filter.setAuthenticationManager(authenticationManager);
	filter.setFilterProcessesUrl(SecurityConstants.OAUTH_LOGIN_PRO_URL);
	filter.setAuthenticationSuccessHandler(authenticationSuccessHandler);
	filter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler(SecurityConstants.LOGIN_FAILURE_PAGE));
	return filter;
}
 
Example #11
Source File: OpenIdOAuth2Configuration.java    From cola with MIT License 5 votes vote down vote up
@Bean
@ConditionalOnBean({AuthenticationManager.class, AuthorizationServerTokenServices.class, ClientDetailsService.class})
public OpenIdTokenGranter openIdTokenGranter(AuthenticationManager authenticationManager,
											 AuthorizationServerTokenServices tokenServices,
											 ClientDetailsService clientDetailsService) {
	return new OpenIdTokenGranter(authenticationManager, tokenServices, clientDetailsService, new DefaultOAuth2RequestFactory(clientDetailsService));
}
 
Example #12
Source File: SecurityConfig.java    From HIS with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #13
Source File: SecurityConfig.java    From HIS with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #14
Source File: JwtAuthorizationFilter.java    From jwt-security with MIT License 4 votes vote down vote up
public JwtAuthorizationFilter(AuthenticationManager authenticationManager) {
    super(authenticationManager);
}
 
Example #15
Source File: AcTokenGranter.java    From cola with MIT License 4 votes vote down vote up
public AcTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
	super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
	this.authenticationManager = authenticationManager;
}
 
Example #16
Source File: JWTLoginFilter.java    From opscenter with Apache License 2.0 4 votes vote down vote up
public JWTLoginFilter(String url, AuthenticationManager authManager) {
       super(new AntPathRequestMatcher(url));
       setAuthenticationManager(authManager);
}
 
Example #17
Source File: SecurityConfig.java    From mall-learning with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #18
Source File: WebSecurityConfiguration.java    From spring-security with Apache License 2.0 4 votes vote down vote up
/**
 * 这一步的配置是必不可少的,否则SpringBoot会自动配置一个AuthenticationManager,覆盖掉内存中的用户
 */
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #19
Source File: LoginAuthenticationFilter.java    From mall4j with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
@Autowired
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
    super.setAuthenticationManager(authenticationManager);
}
 
Example #20
Source File: SecurityConfiguration.java    From cymbal with Apache License 2.0 4 votes vote down vote up
@Bean
public AuthenticationManager authenticationManager(final CasAuthenticationProvider provider) {
    List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(provider);
    return new ProviderManager(providers);
}
 
Example #21
Source File: LoginAuthenticationFilter.java    From mall4j with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
@Autowired
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
    super.setAuthenticationManager(authenticationManager);
}
 
Example #22
Source File: SecurityConfig.java    From macrozheng with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #23
Source File: SecurityConfig.java    From spring-microservice-exam with MIT License 4 votes vote down vote up
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #24
Source File: WebSecurityConfig.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #25
Source File: WebSecurityConfig.java    From spring-cloud-study with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #26
Source File: WebSecurityConfig.java    From mogu_blog_v2 with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #27
Source File: SecurityConfig.java    From mall-tiny with Apache License 2.0 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #28
Source File: WebSecurityConfig.java    From TASK-Management-System with MIT License 4 votes vote down vote up
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}
 
Example #29
Source File: SecurityConfig.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
/**
 * 这一步的配置是必不可少的,否则SpringBoot会自动配置一个AuthenticationManager,覆盖掉内存中的用户
 * @return 认证管理对象
 */
@Bean
   @Override
public AuthenticationManager authenticationManagerBean() throws Exception {
	return super.authenticationManagerBean();
}
 
Example #30
Source File: WebSecurityConfig.java    From mall4j with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
@Bean
@SneakyThrows
public AuthenticationManager authenticationManagerBean() {
    return super.authenticationManagerBean();
}