List of usage examples for org.springframework.security.web WebAttributes ACCESS_DENIED_403
String ACCESS_DENIED_403
To view the source code for org.springframework.security.web WebAttributes ACCESS_DENIED_403.
Click Source Link
From source file:com.sshdemo.common.web.AccessDeniedAction.java
@Override public String execute() { HttpServletRequest request = ServletActionContext.getRequest(); AccessDeniedException exception = (AccessDeniedException) request .getAttribute(WebAttributes.ACCESS_DENIED_403); this.errorDetails = exception.getMessage(); this.errorTrace = exception.toString(); return SUCCESS; }
From source file:de.blizzy.documentr.web.access.AccessController.java
@RequestMapping(value = "/login/forbidden", method = RequestMethod.GET) @PreAuthorize("permitAll") public String loginForbidden(HttpServletRequest request, Model model) { AccessDeniedException exception = (AccessDeniedException) request .getAttribute(WebAttributes.ACCESS_DENIED_403); String msg = getMessage(exception); if (StringUtils.isNotBlank(msg)) { model.addAttribute("errorMessage", msg); //$NON-NLS-1$ }//www. j a v a2s . co m return "/login"; //$NON-NLS-1$ }
From source file:jeeves.config.springutil.JeevesAccessDeniedHandler.java
@Override public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { if (!response.isCommitted()) { if (matcher != null && matcher.matches(request)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage()); }//from w w w. ja va 2s . c om if (_errorPage != null) { request.setAttribute(WebAttributes.ACCESS_DENIED_403, accessDeniedException); response.setStatus(HttpServletResponse.SC_FORBIDDEN); final String referer = _escaper.escape(request.getRequestURI()); RequestDispatcher dispatcher = request.getRequestDispatcher(_errorPage + "?referer=" + referer); dispatcher.forward(request, response); } else { response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage()); } } }
From source file:cn.imethan.common.security.handle.AccessDeniedHandlerImpl.java
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { if (!response.isCommitted()) { if (errorPage != null) { // Put exception into request scope (perhaps of use to a view) request.setAttribute(WebAttributes.ACCESS_DENIED_403, accessDeniedException); // Set the 403 status code. response.setStatus(HttpServletResponse.SC_FORBIDDEN); // forward to error page. RequestDispatcher dispatcher = request.getRequestDispatcher(errorPage); dispatcher.forward(request, response); } else {/*w w w. ja v a 2s.c o m*/ response.sendError(HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage()); } } }
From source file:grails.plugin.springsecurity.web.access.AjaxAwareAccessDeniedHandler.java
public void handle(final HttpServletRequest request, final HttpServletResponse response, final AccessDeniedException e) throws IOException, ServletException { if (e != null && isLoggedIn() && authenticationTrustResolver.isRememberMe(getAuthentication())) { // user has a cookie but is getting bounced because of IS_AUTHENTICATED_FULLY, // so Spring Security won't save the original request requestCache.saveRequest(request, response); }// ww w.j av a 2s . c om if (response.isCommitted()) { return; } boolean ajaxError = ajaxErrorPage != null && SpringSecurityUtils.isAjax(request); if (errorPage == null && !ajaxError) { response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); return; } if (useForward && (errorPage != null || ajaxError)) { // Put exception into request scope (perhaps of use to a view) request.setAttribute(WebAttributes.ACCESS_DENIED_403, e); response.setStatus(HttpServletResponse.SC_FORBIDDEN); request.getRequestDispatcher(ajaxError ? ajaxErrorPage : errorPage).forward(request, response); return; } String redirectUrl; String serverURL = ReflectionUtils.getGrailsServerURL(); if (serverURL == null) { boolean includePort = true; String scheme = request.getScheme(); String serverName = request.getServerName(); int serverPort = portResolver.getServerPort(request); String contextPath = request.getContextPath(); boolean inHttp = "http".equals(scheme.toLowerCase()); boolean inHttps = "https".equals(scheme.toLowerCase()); if (inHttp && (serverPort == 80)) { includePort = false; } else if (inHttps && (serverPort == 443)) { includePort = false; } redirectUrl = scheme + "://" + serverName + ((includePort) ? (":" + serverPort) : "") + contextPath; } else { redirectUrl = serverURL; } if (ajaxError) { redirectUrl += ajaxErrorPage; } else if (errorPage != null) { redirectUrl += errorPage; } response.sendRedirect(response.encodeRedirectURL(redirectUrl)); }
From source file:org.cloudfoundry.identity.uaa.security.CsrfAwareEntryPointAndDeniedHandler.java
@Override public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { request.setAttribute(WebAttributes.ACCESS_DENIED_403, accessDeniedException); //if we get any other access denied we end up here internalHandle(request, response, accessDeniedException); }
From source file:org.springframework.security.web.access.AccessDeniedHandlerImpl.java
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { if (!response.isCommitted()) { if (errorPage != null) { // Put exception into request scope (perhaps of use to a view) request.setAttribute(WebAttributes.ACCESS_DENIED_403, accessDeniedException); // Set the 403 status code. response.setStatus(HttpStatus.FORBIDDEN.value()); // forward to error page. RequestDispatcher dispatcher = request.getRequestDispatcher(errorPage); dispatcher.forward(request, response); } else {//from w ww.j a va2 s . c o m response.sendError(HttpStatus.FORBIDDEN.value(), HttpStatus.FORBIDDEN.getReasonPhrase()); } } }