/** * Shortcut to specify the {@link AccessDeniedHandler} to be used is a specific error * page * * @param accessDeniedUrl the URL to the access denied page (i.e. /errors/401) * @return the {@link ExceptionHandlingConfigurer} for further customization * @see AccessDeniedHandlerImpl * @see #accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler) */ public ExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) { AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl(); accessDeniedHandler.setErrorPage(accessDeniedUrl); return accessDeniedHandler(accessDeniedHandler); }
if (StringUtils.hasText(failurePage)) { AccessDeniedHandlerImpl failureHandler = new AccessDeniedHandlerImpl(); failureHandler.setErrorPage(failurePage); consumerContextFilterBean.addPropertyValue("OAuthFailureHandler", failureHandler);
accessDeniedHandler.setErrorPage(authConfig.getAccessDeniedErrorPage()); else LOGGER.warning("Cannot find: " + authConfig.getAccessDeniedErrorPage());
/** * Shortcut to specify the {@link AccessDeniedHandler} to be used is a specific error * page * * @param accessDeniedUrl the URL to the access denied page (i.e. /errors/401) * @return the {@link ExceptionHandlingConfigurer} for further customization * @see AccessDeniedHandlerImpl * @see #accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler) */ public ExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) { AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl(); accessDeniedHandler.setErrorPage(accessDeniedUrl); return accessDeniedHandler(accessDeniedHandler); }
/** * Shortcut to specify the {@link AccessDeniedHandler} to be used is a specific error page * * @param accessDeniedUrl the URL to the access denied page (i.e. /errors/401) * @return the {@link ExceptionHandlingConfigurer} for further customization * @see AccessDeniedHandlerImpl * @see {@link #accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler)} */ public ExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) { AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl(); accessDeniedHandler.setErrorPage(accessDeniedUrl); return accessDeniedHandler(accessDeniedHandler); }
/** * Shortcut to specify the {@link AccessDeniedHandler} to be used is a specific error * page * * @param accessDeniedUrl the URL to the access denied page (i.e. /errors/401) * @return the {@link ExceptionHandlingConfigurer} for further customization * @see AccessDeniedHandlerImpl * @see #accessDeniedHandler(org.springframework.security.web.access.AccessDeniedHandler) */ public ExceptionHandlingConfigurer<H> accessDeniedPage(String accessDeniedUrl) { AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl(); accessDeniedHandler.setErrorPage(accessDeniedUrl); return accessDeniedHandler(accessDeniedHandler); }
public class MyAccessDeniedHandler implements AccessDeniedHandler { private AccessDeniedHandlerImpl accessDeniedHandlerImpl = new AccessDeniedHandlerImpl(); public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { //Some CSRF related code // Then call accessDeniedHandlerImpl.handle to handle request accessDeniedHandlerImpl.handle(request, response, accessDeniedException); } /** * The error page to use. Must begin with a "/" and is interpreted relative to the current context root. * * @param errorPage the dispatcher path to display * * @throws IllegalArgumentException if the argument doesn't comply with the above limitations * @see AccessDeniedHandlerImpl#setErrorPage(String) */ public void setErrorPage(String errorPage) { // You can set custom error page here accessDeniedHandlerImpl.setErrorPage(errorPage); } }
= new AccessDeniedHandlerImpl(); request.setAttribute(REQUIRED_PROVIDERS_REQUEST_ATTRIBUTE_NAME, requiredProviderIds); providerSpecificAccessDeniedHandler.setErrorPage(connectWithProviderUrlPrefix + "/" + requiredProviderIds.iterator().next()); providerSpecificAccessDeniedHandler.handle(request, response, accessDeniedException); defaultAccessDeniedHandler.setErrorPage(defaultAccessDeniedUrl); defaultAccessDeniedHandler.handle(request, response, accessDeniedException);
new LoginUrlAuthenticationEntryPoint("/login")); AccessDeniedHandlerImpl accessDeniedHandlerImpl = new AccessDeniedHandlerImpl(); accessDeniedHandlerImpl.setErrorPage("/exception"); exceptionTranslationFilter .setAccessDeniedHandler(accessDeniedHandlerImpl);