Here are the examples of the java api org.springframework.security.access.AccessDeniedException taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
175 Examples
19
View Source File : DefaultExceptionAdvice.java
License : Apache License 2.0
Project Creator : zlt2000
License : Apache License 2.0
Project Creator : zlt2000
/**
* AccessDeniedException异常处理返回json
* 返回状态码:403
*/
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler({ AccessDeniedException.clreplaced })
public Result badMethodExpressException(AccessDeniedException e) {
return defHandler("没有权限请求当前方法", e);
}
19
View Source File : ExceptionTranslatingServerInterceptor.java
License : MIT License
Project Creator : yidongnan
License : MIT License
Project Creator : yidongnan
/**
* Close the call with {@link Status#PERMISSION_DENIED}.
*
* @param call The call to close.
* @param aex The exception that was the cause.
*/
protected void closeCallAccessDenied(final ServerCall<?, ?> call, final AccessDeniedException aex) {
log.debug(ACCESS_DENIED_DESCRIPTION, aex);
call.close(Status.PERMISSION_DENIED.withCause(aex).withDescription(ACCESS_DENIED_DESCRIPTION), new Metadata());
}
19
View Source File : ExceptionTranslator.java
License : Apache License 2.0
Project Creator : viz-centric
License : Apache License 2.0
Project Creator : viz-centric
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(HttpStatus.FORBIDDEN)
@ResponseBody
public ErrorVM processAccessDeniedException(AccessDeniedException e) {
return new ErrorVM(ErrorConstants.ERR_ACCESS_DENIED, e.getMessage());
}
19
View Source File : GlobalExceptionHandler.java
License : GNU Lesser General Public License v3.0
Project Creator : somowhere
License : GNU Lesser General Public License v3.0
Project Creator : somowhere
/**
* validation Exception
*
* @param exception
* @return R
*/
@ExceptionHandler({ AccessDeniedException.clreplaced })
@ResponseStatus(HttpStatus.FORBIDDEN)
public Result bodyValidExceptionHandler(AccessDeniedException exception) {
log.warn("AccessDeniedException:{}", exception);
return Result.buildFail("权限不足");
}
18
View Source File : RestAccessDeniedHandler.java
License : Apache License 2.0
Project Creator : Xlinlin
License : Apache License 2.0
Project Creator : Xlinlin
/**
* 登陆状态下,权限不足执行该方法
*
* @param httpServletRequest
* @param response
* @param e
* @exception IOException
* @exception ServletException
*/
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse response, AccessDeniedException e) throws IOException {
log.error("权限不足:" + e.getMessage());
// 浏览器方式
webBrowser(response);
// API接口方式
// api(response, e);
}
18
View Source File : GlobalDefaultExceptionHandler.java
License : Apache License 2.0
Project Creator : suricate-io
License : Apache License 2.0
Project Creator : suricate-io
/**
* Manage the AccessDeniedException exception.
* Throw when a user try access a resource that he can't.
*
* @param exception the exception
* @return The related response enreplacedy
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<ApiErrorDto> handleAccessDeniedException(AccessDeniedException exception) {
GlobalDefaultExceptionHandler.LOGGER.debug("An exception has occurred in the API controllers part", exception);
return ResponseEnreplacedy.status(ApiErrorEnum.FORBIDDEN.getStatus()).body(new ApiErrorDto(ApiErrorEnum.FORBIDDEN));
}
18
View Source File : ApiAuthenticationFailureHandler.java
License : Apache License 2.0
Project Creator : suricate-io
License : Apache License 2.0
Project Creator : suricate-io
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
resolveException(httpServletRequest, httpServletResponse, e);
}
18
View Source File : SimpleAccessDeniedHandler.java
License : MIT License
Project Creator : rubytomato
License : MIT License
Project Creator : rubytomato
private void dump(AccessDeniedException e) {
if (e instanceof AuthorizationServiceException) {
log.debug("AuthorizationServiceException : {}", e.getMessage());
} else if (e instanceof CsrfException) {
log.debug("org.springframework.security.web.csrf.CsrfException : {}", e.getMessage());
} else if (e instanceof org.springframework.security.web.server.csrf.CsrfException) {
log.debug("org.springframework.security.web.server.csrf.CsrfException : {}", e.getMessage());
} else {
log.debug("AccessDeniedException : {}", e.getMessage());
}
}
18
View Source File : OAuth2BearerTokenAccessDeniedHandler.java
License : Apache License 2.0
Project Creator : penggle
License : Apache License 2.0
Project Creator : penggle
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
delegateAccessDeniedHandler.handle(request, response, accessDeniedException);
postHandle(request, response, accessDeniedException);
}
18
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : PearAdmin
License : MIT License
Project Creator : PearAdmin
/**
* 权 限 异 常 处 理
*/
@ExceptionHandler({ AccessDeniedException.clreplaced })
public Object access(HttpServletRequest request, AccessDeniedException e) {
e.printStackTrace();
if (ServletUtil.isAjax(request)) {
return Result.failure("暂无权限");
} else {
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("errorMessage", e.getMessage());
modelAndView.setViewName("error/403");
return modelAndView;
}
}
18
View Source File : TestAbstractAuthenticationEvaluator.java
License : Apache License 2.0
Project Creator : Pardus-Engerek
License : Apache License 2.0
Project Creator : Pardus-Engerek
private void replacedertDeniedException(AccessDeniedException e, String principal) {
replacedertEquals("Wrong exception meessage (key)", "web.security.provider.access.denied", e.getMessage());
}
18
View Source File : SecurityAuthenticationEntryPoint.java
License : Apache License 2.0
Project Creator : KeRan213539
License : Apache License 2.0
Project Creator : KeRan213539
@Override
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException denied) {
return sendJsonStr(exchange.getResponse(), JSON.toJSONString(JsonResult.sendFailedResult(CommonResultCodeEnum.NO_PRIVILEGES)));
}
18
View Source File : BearerTokenAccessDeniedHandler.java
License : Apache License 2.0
Project Creator : jzheaux
License : Apache License 2.0
Project Creator : jzheaux
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
if (accessDeniedException instanceof OAuth2AccessDeniedException) {
OAuth2Error error = ((OAuth2AccessDeniedException) accessDeniedException).getError();
if (error instanceof BearerTokenError) {
this.handle(request, response, (BearerTokenError) error);
} else if (error instanceof InsufficientScopeError) {
this.handle(request, response, (InsufficientScopeError) error);
} else {
this.handle(request, response, error);
}
} else {
this.handler.handle(request, response, HttpStatus.FORBIDDEN);
}
}
18
View Source File : ApplicationSecurityConfig.java
License : Apache License 2.0
Project Creator : didclab
License : Apache License 2.0
Project Creator : didclab
private Mono<Void> accessDeniedHandler(ServerWebExchange serverWebExchange, AccessDeniedException e) {
return Mono.fromRunnable(() -> {
serverWebExchange.getResponse().setStatusCode(HttpStatus.FORBIDDEN);
});
}
18
View Source File : ExceptionWrappingManager.java
License : Creative Commons Zero v1.0 Universal
Project Creator : CDCgov
License : Creative Commons Zero v1.0 Universal
Project Creator : CDCgov
@ExceptionHandler(AccessDeniedException.clreplaced)
public GraphQLError wrapSecurityExceptions(AccessDeniedException e) {
// Add This to `application-local.yaml` to debug what's gone wrong.
// logging:
// level:
// org.springframework.security: TRACE
return new ThrowableGraphQLError(e, "Current user does not have permission for this action");
}
17
View Source File : JsonAccessDeniedHandler.java
License : Apache License 2.0
Project Creator : zlt2000
License : Apache License 2.0
Project Creator : zlt2000
@Override
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException e) {
return WebfluxResponseUtil.responseFailed(exchange, HttpStatus.FORBIDDEN.value(), e.getMessage());
}
17
View Source File : ExceptionsHandler.java
License : Apache License 2.0
Project Creator : WeBankFinTech
License : Apache License 2.0
Project Creator : WeBankFinTech
/**
* catch:AccessDeniedException.
*/
@ResponseBody
@ExceptionHandler(value = AccessDeniedException.clreplaced)
@ResponseStatus(value = HttpStatus.UNAUTHORIZED)
public BaseResponse accessDeniedExceptionHandler(AccessDeniedException exception) throws Exception {
log.warn("catch accessDenied exception", exception);
BaseResponse bre = new BaseResponse(ConstantCode.ACCESS_DENIED);
log.warn("accessDenied exception return:{}", JsonTools.toJSONString(bre));
return bre;
}
17
View Source File : GlobalBizExceptionHandler.java
License : GNU Lesser General Public License v3.0
Project Creator : somowhere
License : GNU Lesser General Public License v3.0
Project Creator : somowhere
/**
* AccessDeniedException
*
* @param e the e
* @return R
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(HttpStatus.FORBIDDEN)
public Result handleAccessDeniedException(AccessDeniedException e) {
String msg = SpringSecurityMessageSource.getAccessor().getMessage("AbstractAccessDecisionManager.accessDenied", e.getMessage());
log.error("拒绝授权异常信息 ex={}", msg, e);
return Result.buildFail(e.getLocalizedMessage());
}
17
View Source File : CustomExceptionHandler.java
License : MIT License
Project Creator : socialsoftware
License : MIT License
Project Creator : socialsoftware
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(HttpStatus.FORBIDDEN)
public TutorExceptionDto accessDeniedException(AccessDeniedException e) {
myLogger.error(e.getMessage());
return new TutorExceptionDto(ACCESS_DENIED);
}
17
View Source File : OAuth2BearerTokenAccessDeniedHandler.java
License : Apache License 2.0
Project Creator : penggle
License : Apache License 2.0
Project Creator : penggle
@Override
protected Mono<HttpStatus> resolveOAuth2ErrorHttpStatus(ServerWebExchange exchange, AccessDeniedException exception) {
return Mono.just(HttpStatus.FORBIDDEN);
}
17
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : paascloud
License : Apache License 2.0
Project Creator : paascloud
/**
* 无权限访问.
*
* @param e the e
*
* @return the wrapper
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public Wrapper unAuthorizedException(AccessDeniedException e) {
log.error("业务异常={}", e.getMessage(), e);
return WrapMapper.wrap(ErrorCodeEnum.GL99990401.code(), ErrorCodeEnum.GL99990401.msg());
}
17
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : opendx
License : MIT License
Project Creator : opendx
/**
* 权限不足
*
* @return
*/
@ResponseBody
@ExceptionHandler(AccessDeniedException.clreplaced)
public void handleAccessDeniedException(AccessDeniedException e) {
// handleException会优先拦截到AccessDeniedException,导致WebSecurityConfig accessDeniedHandler无法执行
// 在这里拦截AccessDeniedException再抛出
throw e;
}
17
View Source File : ExceptionHandlerAdvice.java
License : Apache License 2.0
Project Creator : open-capacity-platform
License : Apache License 2.0
Project Creator : open-capacity-platform
/**
* AccessDeniedException异常处理返回json
* 状态码:403
* @param exception
* @return
*/
@ExceptionHandler({ AccessDeniedException.clreplaced })
@ResponseStatus(HttpStatus.FORBIDDEN)
public Map<String, Object> badMethodExpressException(AccessDeniedException exception) {
Map<String, Object> data = new HashMap<>();
data.put("resp_code", HttpStatus.FORBIDDEN.value());
data.put("resp_msg", exception.getMessage());
return data;
}
17
View Source File : ExceptionControllerAdvice.java
License : MIT License
Project Creator : mostafa-eltaher
License : MIT License
Project Creator : mostafa-eltaher
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public String exception(AccessDeniedException e) {
return "{\"status\":\"access denied\"}";
}
17
View Source File : BaseExceptionHandler.java
License : Apache License 2.0
Project Creator : matevip
License : Apache License 2.0
Project Creator : matevip
/**
* NullPointerException 空指针异常捕获处理
* @param ex 自定义NullPointerException异常类型
* @return Result
*/
@ExceptionHandler
@ResponseStatus(HttpStatus.FORBIDDEN)
public Result<?> handleException(AccessDeniedException ex) {
log.error("程序异常:{}" + ex.toString());
return Result.fail(HttpStatus.FORBIDDEN.value(), ex.getMessage());
}
17
View Source File : BExceptionHandler.java
License : GNU General Public License v3.0
Project Creator : LiHaodong888
License : GNU General Public License v3.0
Project Creator : LiHaodong888
@ExceptionHandler(AccessDeniedException.clreplaced)
public R handleAuthorizationException(AccessDeniedException e) {
log.error(e.getMessage());
return R.error(403, "没有权限,请联系管理员授权");
}
17
View Source File : AccessDeniedExceptionMapper.java
License : Apache License 2.0
Project Creator : katharsis-project
License : Apache License 2.0
Project Creator : katharsis-project
@Override
public ErrorResponse toErrorResponse(AccessDeniedException exception) {
return ExceptionMapperHelper.toErrorResponse(exception, ACCESS_DENIED, META_TYPE_VALUE);
}
17
View Source File : ExceptionHandler.java
License : Apache License 2.0
Project Creator : kaimz
License : Apache License 2.0
Project Creator : kaimz
@org.springframework.web.bind.annotation.ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<String> handleException(AccessDeniedException e) {
LOGGER.debug(e.getMessage(), e);
return ResponseEnreplacedy.status(UNAUTHORIZED).body("不允许访问");
}
17
View Source File : ErrorControllerAdvice.java
License : MIT License
Project Creator : InnovateUKGitHub
License : MIT License
Project Creator : InnovateUKGitHub
// 403
@ResponseStatus(value = HttpStatus.FORBIDDEN)
@ExceptionHandler(value = AccessDeniedException.clreplaced)
public ModelAndView accessDeniedException(HttpServletRequest req, AccessDeniedException e) {
LOG.debug("ErrorController actionNotAllowed", e);
return createErrorModelAndViewWithStatusAndView(e, req, emptyList(), HttpStatus.FORBIDDEN, "forbidden");
}
17
View Source File : AccessDeniedExceptionHandler.java
License : MIT License
Project Creator : gzmuSoft
License : MIT License
Project Creator : gzmuSoft
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
JSONObject result = new JSONObject();
result.put("error", accessDeniedException.getClreplaced().getSimpleName());
result.put("error_description", accessDeniedException.getLocalizedMessage());
log.debug("Access Denied Failed!");
response.setContentType("application/json;charset=utf-8");
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.getWriter().write(result.toJSONString());
}
17
View Source File : GlobalDefaultExceptionHandler.java
License : Apache License 2.0
Project Creator : garyxiong123
License : Apache License 2.0
Project Creator : garyxiong123
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<Map<String, Object>> accessDeny(HttpServletRequest request, AccessDeniedException ex) {
return handleError(request, FORBIDDEN, ex);
}
17
View Source File : RestCtrlExceptionHandler.java
License : GNU General Public License v3.0
Project Creator : Exrick
License : GNU General Public License v3.0
Project Creator : Exrick
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(value = HttpStatus.OK)
public Result<Object> handleAccessDeniedException(AccessDeniedException e) {
String errorMsg = "AccessDeniedException exception";
if (e != null) {
errorMsg = e.getMessage();
log.warn(e.getMessage(), e);
}
return new ResultUtil<>().setErrorMsg(500, errorMsg);
}
17
View Source File : InventoryExceptionHandler.java
License : Apache License 2.0
Project Creator : EdgeGallery
License : Apache License 2.0
Project Creator : EdgeGallery
/**
* Returns error when access is denied.
*
* @param ex exception while processing request
* @return response enreplacedy with error code and message
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<InventoryExceptionResponse> handleAccessDeniedException(AccessDeniedException ex) {
InventoryExceptionResponse response = new InventoryExceptionResponse(LocalDateTime.now(), "Forbidden", Collections.singletonList("User is not authorized to perform this operation"));
LOGGER.info("User is not authorized to perform this operation", response);
return new ResponseEnreplacedy<>(response, HttpStatus.FORBIDDEN);
}
17
View Source File : AppoExceptionHandler.java
License : Apache License 2.0
Project Creator : EdgeGallery
License : Apache License 2.0
Project Creator : EdgeGallery
/**
* Returns error when access is denied.
*
* @param ex exception while processing request
* @return response enreplacedy with error code and message
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<AppoExceptionResponse> handleAccessDeniedException(AccessDeniedException ex) {
AppoExceptionResponse response = new AppoExceptionResponse(LocalDateTime.now(), "Forbidden", Collections.singletonList("User is not authorized to perform this operation"));
LOGGER.info("User is not authorized to perform this operation {}", response.getMessage());
return new ResponseEnreplacedy<>(response, HttpStatus.FORBIDDEN);
}
17
View Source File : ApmExceptionHandler.java
License : Apache License 2.0
Project Creator : EdgeGallery
License : Apache License 2.0
Project Creator : EdgeGallery
/**
* Returns error when access is denied.
*
* @param ex exception while processing request
* @return response enreplacedy with error code and message
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<ApmExceptionResponse> handleAccessDeniedException(AccessDeniedException ex) {
ApmExceptionResponse response = new ApmExceptionResponse(LocalDateTime.now(), "Forbidden", Collections.singletonList("User is not authorized to perform this operation"));
LOGGER.info("User is not authorized to perform this operation", response);
return new ResponseEnreplacedy<>(response, HttpStatus.FORBIDDEN);
}
17
View Source File : BaseController.java
License : Apache License 2.0
Project Creator : dangdangdotcom
License : Apache License 2.0
Project Creator : dangdangdotcom
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(code = HttpStatus.FORBIDDEN)
public void AccessDeniedExceptionHandler(final AccessDeniedException e) {
}
17
View Source File : BaseServiceTest.java
License : Creative Commons Zero v1.0 Universal
Project Creator : CDCgov
License : Creative Commons Zero v1.0 Universal
Project Creator : CDCgov
protected static void replacedertSecurityError(Executable e) {
AccessDeniedException exception = replacedertThrows(AccessDeniedException.clreplaced, e);
replacedertEquals(SPRING_SECURITY_DENIED, exception.getMessage());
}
17
View Source File : OpaFilter.java
License : Apache License 2.0
Project Creator : Bisnode
License : Apache License 2.0
Project Creator : Bisnode
private void denyAccess(AccessDecision accessDecision) {
String rejectionMessage = String.format("Access request rejected by OPA because: %s", accessDecision.getReason());
log.debug(rejectionMessage);
AccessDeniedException accessDeniedException = new AccessDeniedException(rejectionMessage);
AuthorizationFailureEvent event = new AuthorizationFailureEvent(this, List.of(), SecurityContextHolder.getContext().getAuthentication(), accessDeniedException);
eventPublisher.publishEvent(event);
throw accessDeniedException;
}
16
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : zhuangjinming16
License : Apache License 2.0
Project Creator : zhuangjinming16
@ExceptionHandler(AccessDeniedException.clreplaced)
public Result handleAccessDeniedException(AccessDeniedException e) {
log.error(e.getMessage(), e);
return Result.error("没有权限,请联系管理员授权");
}
16
View Source File : UmsAccessDeniedHandlerImpl.java
License : MIT License
Project Creator : ZeroOrInfinity
License : MIT License
Project Creator : ZeroOrInfinity
private void responseWithJson(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
if (accessDeniedException instanceof CsrfException) {
CsrfException deniedException = ((CsrfException) accessDeniedException);
JsonUtil.responseWithJson(response, HttpStatus.FORBIDDEN.value(), toJsonString(ResponseResult.fail(deniedException.getMessage(), ErrorCodeEnum.CSRF_ERROR, request.getRequestURI())));
return;
}
JsonUtil.responseWithJson(response, HttpStatus.FORBIDDEN.value(), toJsonString(ResponseResult.fail(ErrorCodeEnum.PERMISSION_DENY, request.getRequestURI())));
}
16
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : yangzongzhuan
License : MIT License
Project Creator : yangzongzhuan
@ExceptionHandler(AccessDeniedException.clreplaced)
public AjaxResult handleAuthorizationException(AccessDeniedException e) {
log.error(e.getMessage());
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
}
16
View Source File : ExceptionTranslator.java
License : Apache License 2.0
Project Creator : xm-online
License : Apache License 2.0
Project Creator : xm-online
@ExceptionHandler(AccessDeniedException.clreplaced)
@ResponseStatus(HttpStatus.FORBIDDEN)
@ResponseBody
public ErrorVM processAccessDeniedException(AccessDeniedException e) {
log.debug("Access denied", e);
return new ErrorVM(ErrorConstants.ERR_ACCESS_DENIED, localizationErrorMessageService.getMessage(ErrorConstants.ERR_ACCESS_DENIED));
}
16
View Source File : GlobalExceptionHandler.java
License : MIT License
Project Creator : witmy
License : MIT License
Project Creator : witmy
@ExceptionHandler(AccessDeniedException.clreplaced)
public Result handleAuthorizationException(AccessDeniedException e) {
log.error(e.getMessage());
return Result.error().code(ResultCode.FORBIDDEN).message("没有权限,请联系管理员授权");
}
16
View Source File : RestAuthenticationHandler.java
License : Apache License 2.0
Project Creator : spot-next
License : Apache License 2.0
Project Creator : spot-next
/**
* {@inheritDoc} Called when access to resource is denied.
*/
@Override
public void handle(final HttpServletRequest request, final HttpServletResponse response, final AccessDeniedException exception) throws IOException, ServletException {
onAuthenticationFailure(request, response, new InsufficientAuthenticationException(StringUtils.isNotBlank(exception.getMessage()) ? exception.getMessage() : "Not authenticated", exception));
}
16
View Source File : RestExceptionHandler.java
License : GNU General Public License v3.0
Project Creator : sermore
License : GNU General Public License v3.0
Project Creator : sermore
@ExceptionHandler(AccessDeniedException.clreplaced)
protected ResponseEnreplacedy<Object> handleMethodArgumentTypeMismatch(AccessDeniedException ex, WebRequest request) {
ApiError apiError = new ApiError(UNAUTHORIZED);
apiError.setMessage(ex.getMessage());
apiError.setDebugMessage(ex.getMessage());
return buildResponseEnreplacedy(apiError);
}
16
View Source File : CustomAccessDeniedHandler.java
License : GNU General Public License v3.0
Project Creator : sermore
License : GNU General Public License v3.0
Project Creator : sermore
@Override
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) {
throw e;
}
16
View Source File : GlobalExceptionHandler.java
License : Apache License 2.0
Project Creator : sanyueruanjian
License : Apache License 2.0
Project Creator : sanyueruanjian
/**
* description: security的角色权限不足异常
*
* @param e 权限不足异常
* @return 200状态码 403自定义code
* @author RenShiWei
* Date: 2020/8/7 19:52
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<Result<String>> handleAccessDeniedException(AccessDeniedException e) {
log.error(e.getMessage(), e);
return ResponseEnreplacedy.status(HttpStatus.FORBIDDEN).body(Result.error(ResultEnum.IDENreplacedY_NOT_POW.getCode(), ResultEnum.IDENreplacedY_NOT_POW.getMsg()));
}
16
View Source File : APIExceptionHandler.java
License : Mozilla Public License 2.0
Project Creator : SafeExamBrowser
License : Mozilla Public License 2.0
Project Creator : SafeExamBrowser
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy<Object> handleUnexpected(final AccessDeniedException ex, final WebRequest request) {
log.warn("Access denied: ", ex);
return APIMessage.ErrorMessage.FORBIDDEN.createErrorResponse(ex.getMessage());
}
16
View Source File : RestExceptionHandler.java
License : Apache License 2.0
Project Creator : rancho00
License : Apache License 2.0
Project Creator : rancho00
/**
* 处理accessDeniedException异常
* @param accessDeniedException
* @return
*/
@ExceptionHandler(AccessDeniedException.clreplaced)
public ResponseEnreplacedy handleAccessDeniedException(AccessDeniedException accessDeniedException) {
log.error("没有权限异常-------->:{}", accessDeniedException.getMessage());
return ResponseEnreplacedy.status(HttpStatus.FORBIDDEN).body(CommonResult.forbidden());
}
16
View Source File : RadarCovidHandler.java
License : Mozilla Public License 2.0
Project Creator : RadarCOVID
License : Mozilla Public License 2.0
Project Creator : RadarCOVID
@ExceptionHandler({ AccessDeniedException.clreplaced, AuthenticationException.clreplaced, InsufficientAuthenticationException.clreplaced })
public ResponseEnreplacedy<MessageResponseDto> handleAccessDeniedException(AccessDeniedException ex, WebRequest wr) {
log.error("Access denied: {}", wr.getDescription(false));
return buildResponseMessage(HttpStatus.FORBIDDEN, "Access denied to " + wr.getContextPath());
}
See More Examples