當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。