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

The following examples show how to use org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler. These examples are extracted from open source projects. 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 Project: crnk-example   Source File: SpringSecurityConfiguration.java    License: 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 Project: sshd-shell-spring-boot   Source File: MySecurityConfig.java    License: 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 Project: multitenancy   Source File: CustomSecurityConfig.java    License: Apache License 2.0 4 votes vote down vote up
public SimpleUrlAuthenticationSuccessHandler successHandler() {
    return new SimpleUrlAuthenticationSuccessHandler("/user/index");
}
 
Example 4
Source Project: hawkbit   Source File: SecurityAutoConfiguration.java    License: 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
@Bean
public SimpleUrlAuthenticationSuccessHandler pac4jAuthenticationSuccessHandler() {
	return new Pac4jAuthenticationSuccessHandler();
}