Example usage for org.springframework.security.web.access AccessDeniedHandlerImpl setErrorPage

List of usage examples for org.springframework.security.web.access AccessDeniedHandlerImpl setErrorPage

Introduction

In this page you can find the example usage for org.springframework.security.web.access AccessDeniedHandlerImpl setErrorPage.

Prototype

public void setErrorPage(String errorPage) 

Source Link

Document

The error page to use.

Usage

From source file:com.test.config.BackendConsoleConfig.java

@Bean(name = { "defaultAccessDeniedHandler", "accessDeniedHandler" })
protected AccessDeniedHandler defaultAccessDeniedHandler() {
    final AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
    accessDeniedHandler.setErrorPage("/login?error=denied");

    return accessDeniedHandler;
}

From source file:org.lightadmin.core.config.context.LightAdminSecurityConfiguration.java

@Bean
public Filter exceptionTranslationFilter(RequestCache requestCache) {
    AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
    accessDeniedHandler.setErrorPage(applicationUrl("/access-denied"));
    LoginUrlAuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint(
            applicationUrl("/login"));
    ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(
            authenticationEntryPoint, requestCache);
    exceptionTranslationFilter.setAccessDeniedHandler(accessDeniedHandler);
    return exceptionTranslationFilter;
}

From source file:org.socialsignin.springsocial.security.signin.SpringSocialSecurityAccessDeniedHandler.java

@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
        AccessDeniedException accessDeniedException) throws IOException, ServletException {

    // Save the request so we can provide user with a continue link after provider connection
    requestCache.saveRequest(request, response);

    // Attempt to determine a set of provider ids which are required for this request which the current user has not yet connected with
    Set<String> requiredProviderIds = getRequiredProviderIds(request);
    if (requiredProviderIds != null && !requiredProviderIds.isEmpty()) {
        // If we have found a set of provider ids which the user needs to connect with for this request, select one of them and send the user to the connect/<provider> page
        AccessDeniedHandlerImpl providerSpecificAccessDeniedHandler = new AccessDeniedHandlerImpl();
        request.setAttribute(REQUIRED_PROVIDERS_REQUEST_ATTRIBUTE_NAME, requiredProviderIds);
        providerSpecificAccessDeniedHandler
                .setErrorPage(connectWithProviderUrlPrefix + "/" + requiredProviderIds.iterator().next());
        providerSpecificAccessDeniedHandler.handle(request, response, accessDeniedException);
    } else {//w w  w.ja v  a2s.co  m
        if (defaultAccessDeniedUrl != null) {
            AccessDeniedHandlerImpl defaultAccessDeniedHandler = new AccessDeniedHandlerImpl();
            defaultAccessDeniedHandler.setErrorPage(defaultAccessDeniedUrl);
            defaultAccessDeniedHandler.handle(request, response, accessDeniedException);

        } else {
            super.handle(request, response, accessDeniedException);
        }

    }
}