当前位置: 首页>>代码示例>>Java>>正文


Java SimpleUrlAuthenticationFailureHandler类代码示例

本文整理汇总了Java中org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler的典型用法代码示例。如果您正苦于以下问题:Java SimpleUrlAuthenticationFailureHandler类的具体用法?Java SimpleUrlAuthenticationFailureHandler怎么用?Java SimpleUrlAuthenticationFailureHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleUrlAuthenticationFailureHandler类属于org.springframework.security.web.authentication包,在下文中一共展示了SimpleUrlAuthenticationFailureHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestHeaderAuthenticationFilter

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter() throws Exception {
    RequestHeaderAuthenticationFilter f = new RequestHeaderAuthenticationFilter();
    f.setPrincipalRequestHeader("X-Forwarded-User");
    f.setCredentialsRequestHeader("X-Forwarded-Access-Token");
    f.setAuthenticationManager(authenticationManager());
    f.setAuthenticationDetailsSource(
        (AuthenticationDetailsSource<HttpServletRequest, PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails>)
            (request) ->new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(
                request,
                AuthorityUtils.createAuthorityList("ROLE_AUTHENTICATED")
            )
    );
    f.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler());
    f.setExceptionIfHeaderMissing(false);
    return f;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:SecurityConfiguration.java

示例2: domainUsernamePasswordAuthenticationFilter

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
/**
 *
 * @return
 * @throws Exception
 */
@Bean
public DomainUsernamePasswordAuthenticationFilter domainUsernamePasswordAuthenticationFilter()
        throws Exception {
    DomainUsernamePasswordAuthenticationFilter dupaf = new DomainUsernamePasswordAuthenticationFilter(
                                                            super.authenticationManagerBean());
    dupaf.setFilterProcessesUrl("/login");
    dupaf.setUsernameParameter("username");
    dupaf.setPasswordParameter("password");

    dupaf.setAuthenticationSuccessHandler(
            new SavedRequestAwareAuthenticationSuccessHandler(){{
                setDefaultTargetUrl("/default");
            }}
    );

    dupaf.setAuthenticationFailureHandler(
            new SimpleUrlAuthenticationFailureHandler(){{
                setDefaultFailureUrl("/login/form?error");
            }}
    );

    dupaf.afterPropertiesSet();

    return dupaf;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:31,代码来源:SecurityConfig.java

示例3: GoogleAuthenticationProcessingFilter

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
public GoogleAuthenticationProcessingFilter(GooglePublicKeysManager googlePublicKeysManager,
		DataService dataService, UserDetailsService userDetailsService,
		AuthenticationSettings authenticationSettings, UserFactory userFactory,
		GroupMemberFactory groupMemberFactory)
{
	super(new AntPathRequestMatcher(GOOGLE_AUTHENTICATION_URL, POST.toString()));
	this.userFactory = requireNonNull(userFactory);
	this.groupMemberFactory = requireNonNull(groupMemberFactory);

	setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler("/login?error"));

	this.googlePublicKeysManager = requireNonNull(googlePublicKeysManager);
	this.dataService = requireNonNull(dataService);
	this.userDetailsService = requireNonNull(userDetailsService);
	this.authenticationSettings = requireNonNull(authenticationSettings);
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:17,代码来源:GoogleAuthenticationProcessingFilter.java

示例4: init

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
public void init() {
	System.err.println(" ---------------AuthenticationFilter init--------------- ");
	this.setUsernameParameter(USERNAME);
	this.setPasswordParameter(PASSWORD);
	// 验证成功,跳转的页面
	SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
	successHandler.setDefaultTargetUrl(successUrl);
	this.setAuthenticationSuccessHandler(successHandler);

	// 验证失败,跳转的页面
	SimpleUrlAuthenticationFailureHandler failureHandler = new SimpleUrlAuthenticationFailureHandler();
	failureHandler.setDefaultFailureUrl(errorUrl);
	this.setAuthenticationFailureHandler(failureHandler);
}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:15,代码来源:MainAuthenticationFilter.java

示例5: getSimpleRestAuthenticationFilter

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
/**
 * Create a simple authentication filter for REST logins that reads user-credentials from a json-parameter and returns
 * status 200 instead of redirect after login.
 *
 * @return the {@link JsonUsernamePasswordAuthenticationFilter}.
 * @throws Exception if something goes wrong.
 */
protected JsonUsernamePasswordAuthenticationFilter getSimpleRestAuthenticationFilter() throws Exception {

  JsonUsernamePasswordAuthenticationFilter jsonFilter =
      new JsonUsernamePasswordAuthenticationFilter(new AntPathRequestMatcher("/services/rest/login"));
  jsonFilter.setPasswordParameter("j_password");
  jsonFilter.setUsernameParameter("j_username");
  jsonFilter.setAuthenticationManager(authenticationManager());
  // set failurehandler that uses no redirect in case of login failure; just HTTP-status: 401
  jsonFilter.setAuthenticationManager(authenticationManagerBean());
  jsonFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler());
  // set successhandler that uses no redirect in case of login success; just HTTP-status: 200
  jsonFilter.setAuthenticationSuccessHandler(new AuthenticationSuccessHandlerSendingOkHttpStatusCode());
  return jsonFilter;
}
 
开发者ID:oasp,项目名称:oasp-tutorial-sources,代码行数:22,代码来源:BaseWebSecurityConfig.java

示例6: configure

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {

    http
            .csrf()
            .disable();
    http
            .addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.class)
            .addFilterAfter(samlFilter(), BasicAuthenticationFilter.class);
    http
            .authorizeRequests()
            .antMatchers("/").permitAll()
            .antMatchers("/error").permitAll()
            .antMatchers("/saml/**").permitAll()
            .antMatchers("/css/**").permitAll()
            .anyRequest().authenticated();

    http
            .exceptionHandling().accessDeniedHandler(new AccessDeniedHandlerImpl())
            .authenticationEntryPoint(getAuthEntryPoint())
            .and()
            .formLogin()
            .loginProcessingUrl("/authenticate")
            .usernameParameter("username")
            .passwordParameter("password")
            .successHandler(new FormAuthSuccessHandler())
            .failureHandler(new SimpleUrlAuthenticationFailureHandler())
            .and()
            .logout()
            .logoutUrl("/logout")
            .logoutSuccessUrl("/")
            .permitAll();
}
 
开发者ID:lhartikk,项目名称:spring-tsers-auth,代码行数:34,代码来源:WebSecurityConfig.java

示例7: authenticationFailureHandler

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Bean
public SimpleUrlAuthenticationFailureHandler authenticationFailureHandler() {
    SimpleUrlAuthenticationFailureHandler failureHandler =
            new SimpleUrlAuthenticationFailureHandler();
    failureHandler.setUseForward(true);
    failureHandler.setDefaultFailureUrl("/login");
    return failureHandler;
}
 
开发者ID:lhartikk,项目名称:spring-tsers-auth,代码行数:9,代码来源:WebSecurityConfig.java

示例8: failureRedirectHandler

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Bean
public SimpleUrlAuthenticationFailureHandler failureRedirectHandler() {
    SimpleUrlAuthenticationFailureHandler failureHandler = new SimpleUrlAuthenticationFailureHandler();

    // The precondition on `setDefaultFailureUrl(..)` will cause an exception if the value is null.
    // So, only set this value if it is not null
    if (!samlConfigBean().getFailedLoginDefaultUrl().isEmpty()) {
        failureHandler.setDefaultFailureUrl(samlConfigBean().getFailedLoginDefaultUrl());
    }

    return failureHandler;
}
 
开发者ID:choonchernlim,项目名称:spring-security-adfs-saml2,代码行数:13,代码来源:SAMLWebSecurityConfigurerAdapter.java

示例9: failureHandler

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
/**
 * Failed login handler, returning a 401 code instead of a login page
 *
 * @return
 */
@Bean
public AuthenticationFailureHandler failureHandler() {
	return new SimpleUrlAuthenticationFailureHandler() {
		@Override
		public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
			LOG.warn("LOGIN >>> authentication failure");
			response.sendError(HttpServletResponse.SC_UNAUTHORIZED, exception.getMessage());
		}
	};
}
 
开发者ID:alextremp,项目名称:stateless-rest-jwtcookie-demo,代码行数:16,代码来源:SecurityInternalConfig.java

示例10: authenticationFailureHandler

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Bean
public SimpleUrlAuthenticationFailureHandler authenticationFailureHandler() {
	SimpleUrlAuthenticationFailureHandler failureHandler =
        new SimpleUrlAuthenticationFailureHandler();
	failureHandler.setUseForward(true);
	failureHandler.setDefaultFailureUrl("/error");
	return failureHandler;
}
 
开发者ID:takesection,项目名称:spring-boot-saml2,代码行数:9,代码来源:WebSecurityConfig.java

示例11: authenticationFailureHandler

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Bean
public SimpleUrlAuthenticationFailureHandler authenticationFailureHandler() {
    SimpleUrlAuthenticationFailureHandler handler = new SimpleUrlAuthenticationFailureHandler();
    handler.setUseForward(false);
    //handler.setDefaultFailureUrl("/error");
    return handler;
}
 
开发者ID:ulisesbocchio,项目名称:spring-boot-security-saml-samples,代码行数:8,代码来源:SAMLConfig.java

示例12: configure

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
	http
	.csrf().disable()
	.exceptionHandling()
	.authenticationEntryPoint(entryPoint)
	.and().authorizeRequests()
	.antMatchers("/api/1/**").authenticated()
	.and().formLogin()
	.successHandler(successHandler)
	.failureHandler(new SimpleUrlAuthenticationFailureHandler())
	.and().logout();
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:14,代码来源:WebSecurityConfig.java

示例13: setUp

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Before
public void setUp() {
    SuperflySelectRoleAuthenticationProcessingFilter procFilter = new SuperflySelectRoleAuthenticationProcessingFilter();
    procFilter.setAuthenticationManager(authenticationManager);
    procFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler("/login-failed"));
    procFilter.afterPropertiesSet();
    filter = procFilter;
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:9,代码来源:SuperflySelectRoleAuthenticationProcessingFilterTest.java

示例14: setUp

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Before
public void setUp() {
    SuperflyUsernamePasswordAuthenticationProcessingFilter procFilter = new SuperflyUsernamePasswordAuthenticationProcessingFilter();
    procFilter.setAuthenticationManager(authenticationManager);
    procFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler("/login-failed"));
    procFilter.setSubsystemIdentifier("my-subsystem");
    procFilter.afterPropertiesSet();
    filter = procFilter;
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:10,代码来源:SuperflyUsernamePasswordAuthenticationProcessingFilterTest.java

示例15: setUp

import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; //导入依赖的package包/类
@Before
public void setUp() {
    SuperflySSOAuthenticationProcessingFilter procFilter = new SuperflySSOAuthenticationProcessingFilter();
    procFilter.setAuthenticationManager(authenticationManager);
    procFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler("/login-failed"));
    procFilter.afterPropertiesSet();
    filter = procFilter;
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:9,代码来源:SuperflySSOAuthenticationProcessingFilterTest.java


注:本文中的org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。