org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler Java Examples

The following examples show how to use org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler. 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: SpringSecurityConfiguration.java    From crnk-example with Apache License 2.0 6 votes vote down vote up
private OAuth2ClientAuthenticationProcessingFilter ssoFilter(ClientResources client, String path) {
	OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client.getClient(), oauth2ClientContext);

	UserInfoTokenServices tokenServices = new UserInfoTokenServices(client.getResource().getUserInfoUri(),
			client.getClient().getClientId());
	tokenServices.setRestTemplate(oAuth2RestTemplate);

	OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter =
			new OAuth2ClientAuthenticationProcessingFilter(path);
	oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);
	oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
	oAuth2ClientAuthenticationFilter.setAuthenticationSuccessHandler(new SimpleUrlAuthenticationSuccessHandler() {
		@Override
		public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
				Authentication authentication) throws IOException, ServletException {
			// TODO switch to tokens or find a way to return to last page on client
			this.setDefaultTargetUrl("/");
			super.onAuthenticationSuccess(request, response, authentication);
		}
	});

	return oAuth2ClientAuthenticationFilter;
}
 
Example #2
Source File: MySecurityConfig.java    From sshd-shell-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
    SimpleUrlAuthenticationSuccessHandler authSuccessHandler = new SimpleUrlAuthenticationSuccessHandler();
    authSuccessHandler.setUseReferer(true);
    http.authorizeRequests()
            .antMatchers("/login").permitAll()
            .anyRequest().authenticated()
            .and().formLogin().defaultSuccessUrl("/test", true);
}
 
Example #3
Source File: CustomSecurityConfig.java    From multitenancy with Apache License 2.0 4 votes vote down vote up
public SimpleUrlAuthenticationSuccessHandler successHandler() {
    return new SimpleUrlAuthenticationSuccessHandler("/user/index");
}
 
Example #4
Source File: SecurityAutoConfiguration.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @return {@link AuthenticationSuccessHandler} bean
 */
@Bean
@ConditionalOnMissingBean
public AuthenticationSuccessHandler authenticationSuccessHandler() {
    return new SimpleUrlAuthenticationSuccessHandler();
}
 
Example #5
Source File: MavenArtifactNotifierWebappSecurityConfig.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@Bean
public SimpleUrlAuthenticationSuccessHandler pac4jAuthenticationSuccessHandler() {
	return new Pac4jAuthenticationSuccessHandler();
}