本文整理了Java中org.springframework.security.access.AccessDeniedException.getMessage()
方法的一些代码示例,展示了AccessDeniedException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AccessDeniedException.getMessage()
方法的具体详情如下:
包路径:org.springframework.security.access.AccessDeniedException
类名称:AccessDeniedException
方法名:getMessage
暂无
代码示例来源:origin: macrozheng/mall
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
response.setHeader("Content-Type", "application/json;charset=utf-8");
response.getWriter().print("{\"code\":401,\"message\":\""+"未认证:"+accessDeniedException.getMessage()+"\"}");
response.getWriter().flush();
}
}
代码示例来源:origin: macrozheng/mall
@Override
public void handle(HttpServletRequest request,
HttpServletResponse response,
AccessDeniedException e) throws IOException, ServletException {
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.getWriter().println(JsonUtil.objectToJson(new CommonResult().forbidden(e.getMessage())));
response.getWriter().flush();
}
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
private void onAuthorizationFailureEvent(AuthorizationFailureEvent event) {
Map<String, Object> data = new HashMap<>();
data.put("type", event.getAccessDeniedException().getClass().getName());
data.put("message", event.getAccessDeniedException().getMessage());
if (event.getAuthentication().getDetails() != null) {
data.put("details", event.getAuthentication().getDetails());
}
publish(new AuditEvent(event.getAuthentication().getName(), AUTHORIZATION_FAILURE,
data));
}
代码示例来源:origin: devicehive/devicehive-java-server
@Override
public Response toResponse(AccessDeniedException exception) {
return Response.status(Response.Status.FORBIDDEN)
.type(MediaType.APPLICATION_JSON_TYPE)
.entity(new ErrorResponse(Response.Status.FORBIDDEN.getStatusCode(), exception.getMessage()))
.build();
}
代码示例来源:origin: com.stormpath.spring/stormpath-spring-security-webmvc
@ExceptionHandler(AccessDeniedException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public Error processAccessDeniedException(AccessDeniedException e) {
return new Error(ErrorConstants.ERR_ACCESS_DENIED, e.getMessage());
}
}
代码示例来源:origin: fuhaiwei/springboot_security_restful_api
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
responseText(response, errorMessage(accessDeniedException.getMessage()));
}
}
代码示例来源:origin: synyx/urlaubsverwaltung
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(AccessDeniedException.class)
public ModelAndView handleException(AccessDeniedException exception) {
LOG.debug("An exception was thrown: " + exception.getClass().getName());
LOG.debug("An error occurred: " + exception.getMessage());
return ExceptionHandlerControllerAdvice.getErrorPage(exception, HttpStatus.FORBIDDEN);
}
代码示例来源:origin: org.apache.syncope.core/syncope-core-spring
@Override
public void handle(final HttpServletRequest request, final HttpServletResponse response,
final AccessDeniedException accessDeniedException) throws IOException, ServletException {
response.addHeader(RESTHeaders.ERROR_INFO, accessDeniedException.getMessage());
super.handle(request, response, accessDeniedException);
}
代码示例来源:origin: apache/syncope
@Override
public void handle(final HttpServletRequest request, final HttpServletResponse response,
final AccessDeniedException accessDeniedException) throws IOException, ServletException {
response.addHeader(RESTHeaders.ERROR_INFO, accessDeniedException.getMessage());
super.handle(request, response, accessDeniedException);
}
}
代码示例来源:origin: stormpath/stormpath-sdk-java
@ExceptionHandler(AccessDeniedException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public Error processAccessDeniedException(AccessDeniedException e) {
return new Error(ErrorConstants.ERR_ACCESS_DENIED, e.getMessage());
}
}
代码示例来源:origin: org.finra.herd/herd-service
/**
* Constructs a new access denied exception by concatenating the given list of exceptions.
*
* @param accessDeniedExceptions List of exceptions to concatenate
*
* @return A new AccessDeniedException
*/
public AccessDeniedException getAccessDeniedException(List<AccessDeniedException> accessDeniedExceptions)
{
StringBuilder errorMessageBuilder = new StringBuilder();
for (AccessDeniedException accessDeniedException : accessDeniedExceptions)
{
errorMessageBuilder.append(String.format("%s%n", accessDeniedException.getMessage()));
}
return new AccessDeniedException(errorMessageBuilder.toString().trim());
}
代码示例来源:origin: FINRAOS/herd
/**
* Constructs a new access denied exception by concatenating the given list of exceptions.
*
* @param accessDeniedExceptions List of exceptions to concatenate
*
* @return A new AccessDeniedException
*/
public AccessDeniedException getAccessDeniedException(List<AccessDeniedException> accessDeniedExceptions)
{
StringBuilder errorMessageBuilder = new StringBuilder();
for (AccessDeniedException accessDeniedException : accessDeniedExceptions)
{
errorMessageBuilder.append(String.format("%s%n", accessDeniedException.getMessage()));
}
return new AccessDeniedException(errorMessageBuilder.toString().trim());
}
代码示例来源:origin: theotherp/nzbhydra2
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
logger.warn("Access denied to IP {}: {}", SessionStorage.IP.get(), accessDeniedException.getMessage());
attemptService.accessFailed(SessionStorage.IP.get());
super.handle(request, response, accessDeniedException);
}
代码示例来源:origin: org.molgenis/molgenis-core-ui
@ExceptionHandler(AccessDeniedException.class)
@ResponseStatus(value = HttpStatus.FORBIDDEN)
@ResponseBody
private ErrorMessageResponse handleAccessDeniedException(AccessDeniedException e) {
LOG.warn("Access denied", e);
return new ErrorMessageResponse(Collections.singletonList(new ErrorMessage(e.getMessage())));
}
代码示例来源:origin: jkazama/sample-boot-micro
/** 権限例外 */
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity<Map<String, String[]>> handleAccessDeniedException(AccessDeniedException e) {
log.warn(e.getMessage());
return new ErrorHolder(msg, locale(), ErrorKeys.AccessDenied).result(HttpStatus.UNAUTHORIZED);
}
代码示例来源:origin: com.erudika/para
@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
AccessDeniedException accessDeniedException) throws IOException, ServletException {
if (isRestRequest(request)) {
RestUtils.returnStatusResponse(response, HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage());
} else {
super.handle(request, response, accessDeniedException);
}
}
代码示例来源:origin: Erudika/para
@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
AccessDeniedException accessDeniedException) throws IOException, ServletException {
if (isRestRequest(request)) {
RestUtils.returnStatusResponse(response, HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage());
} else {
super.handle(request, response, accessDeniedException);
}
}
代码示例来源:origin: com.erudika/para-server
@Override
public void handle(HttpServletRequest request, HttpServletResponse response,
AccessDeniedException accessDeniedException) throws IOException, ServletException {
if (isRestRequest(request)) {
RestUtils.returnStatusResponse(response, HttpServletResponse.SC_FORBIDDEN, accessDeniedException.getMessage());
} else {
super.handle(request, response, accessDeniedException);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException e) {
return Mono.defer(() -> Mono.just(exchange.getResponse()))
.flatMap(response -> {
response.setStatusCode(this.httpStatus);
response.getHeaders().setContentType(MediaType.TEXT_PLAIN);
DataBufferFactory dataBufferFactory = response.bufferFactory();
DataBuffer buffer = dataBufferFactory.wrap(e.getMessage().getBytes(
Charset.defaultCharset()));
return response.writeWith(Mono.just(buffer))
.doOnError( error -> DataBufferUtils.release(buffer));
});
}
}
代码示例来源:origin: 1and1/cosmo
public void handle(ServletRequest request,
ServletResponse response,
AccessDeniedException exception) throws IOException, ServletException {
if(!(response instanceof HttpServletResponse)){
throw new IllegalStateException( "Expected response of type: ["
+ HttpServletResponse.class.getName() + "], received :["
+ response.getClass().getName() + "]");
}
StandardDavResponse sdr = new StandardDavResponse((HttpServletResponse) response);
NeedsPrivilegesException toSend = null;
if (exception instanceof DavAccessDeniedException) {
DavAccessDeniedException e = (DavAccessDeniedException) exception;
toSend =
new NeedsPrivilegesException(e.getHref(), e.getPrivilege());
} else {
toSend = new NeedsPrivilegesException(exception.getMessage());
}
sdr.sendDavError(toSend);
}
内容来源于网络,如有侵权,请联系作者删除!