Search in sources :

Example 1 with SavedRequestAwareAuthenticationSuccessHandler

use of org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler in project spring-security by spring-projects.

the class AbstractAuthenticationFilterConfigurer method defaultSuccessUrl.

/**
	 * Specifies where users will go after authenticating successfully if they have not
	 * visited a secured page prior to authenticating or {@code alwaysUse} is true. This
	 * is a shortcut for calling {@link #successHandler(AuthenticationSuccessHandler)}.
	 *
	 * @param defaultSuccessUrl the default success url
	 * @param alwaysUse true if the {@code defaultSuccesUrl} should be used after
	 * authentication despite if a protected page had been previously visited
	 * @return the {@link FormLoginConfigurer} for additional customization
	 */
public final T defaultSuccessUrl(String defaultSuccessUrl, boolean alwaysUse) {
    SavedRequestAwareAuthenticationSuccessHandler handler = new SavedRequestAwareAuthenticationSuccessHandler();
    handler.setDefaultTargetUrl(defaultSuccessUrl);
    handler.setAlwaysUseDefaultTargetUrl(alwaysUse);
    return successHandler(handler);
}
Also used : SavedRequestAwareAuthenticationSuccessHandler(org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler)

Example 2 with SavedRequestAwareAuthenticationSuccessHandler

use of org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler in project spring-security by spring-projects.

the class OpenIDAuthenticationFilterTests method setUp.

@Before
public void setUp() throws Exception {
    filter = new OpenIDAuthenticationFilter();
    filter.setConsumer(new MockOpenIDConsumer(REDIRECT_URL));
    SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
    filter.setAuthenticationSuccessHandler(new SavedRequestAwareAuthenticationSuccessHandler());
    successHandler.setDefaultTargetUrl(DEFAULT_TARGET_URL);
    filter.setAuthenticationManager(new AuthenticationManager() {

        public Authentication authenticate(Authentication a) {
            return a;
        }
    });
    filter.afterPropertiesSet();
}
Also used : AuthenticationManager(org.springframework.security.authentication.AuthenticationManager) Authentication(org.springframework.security.core.Authentication) SavedRequestAwareAuthenticationSuccessHandler(org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler) Before(org.junit.Before)

Aggregations

SavedRequestAwareAuthenticationSuccessHandler (org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler)2 Before (org.junit.Before)1 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)1 Authentication (org.springframework.security.core.Authentication)1