本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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());
}
};
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}