Class NtsExceptionTranslator
- java.lang.Object
-
- org.nentangso.core.web.rest.errors.ResponseEntityExceptionHandler
-
- org.nentangso.core.web.rest.errors.NtsExceptionTranslator
-
- All Implemented Interfaces:
org.springframework.security.web.server.authorization.ServerAccessDeniedHandler,org.springframework.security.web.server.ServerAuthenticationEntryPoint
@ConditionalOnProperty(prefix="nts.web.rest.exception-translator", name="enabled", havingValue="true", matchIfMissing=true) @ControllerAdvice @ConditionalOnMissingBean(name="exceptionTranslator") public class NtsExceptionTranslator extends ResponseEntityExceptionHandler implements org.springframework.security.web.server.ServerAuthenticationEntryPoint, org.springframework.security.web.server.authorization.ServerAccessDeniedHandlerController advice to translate the server side exceptions to client-friendly json structures. The error response follows RFC7807 - Problem Details for HTTP APIs (RFC7807).
-
-
Field Summary
Fields Modifier and Type Field Description protected StringrealmName-
Fields inherited from class org.nentangso.core.web.rest.errors.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
-
-
Constructor Summary
Constructors Constructor Description NtsExceptionTranslator()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected Map<String,List<String>>buildUnprocessableErrors(Exception ex)reactor.core.publisher.Mono<Void>commence(org.springframework.web.server.ServerWebExchange exchange, org.springframework.security.core.AuthenticationException authException)protected StringcomputeWWWAuthenticateHeaderValue(Map<String,String> parameters)protected Map<String,String>createAccessDeniedParameters(Map<String,String> parameters)protected Map<String,String>createAuthenticationParameters(org.springframework.security.core.AuthenticationException authException)protected StringgenerateAuthenticateHeader(Exception ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)Deprecated.protected org.springframework.http.HttpStatusgetAuthenticationStatus(org.springframework.security.core.AuthenticationException authException)reactor.core.publisher.Mono<Void>handle(org.springframework.web.server.ServerWebExchange exchange, org.springframework.security.access.AccessDeniedException denied)protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>>handleConversionNotSupported(org.springframework.beans.ConversionNotSupportedException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)Customize the response for ConversionNotSupportedException.protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>>handleExceptionInternal(Exception ex, Object body, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)A single place to customize the response body of all exception types.protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>>handleInternalServerError(Exception ex, org.springframework.web.server.ServerWebExchange exchange)protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>>handleMethodArgumentNotValid(org.springframework.web.bind.MethodArgumentNotValidException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)Customize the response for MethodArgumentNotValidException.protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>>handleNtsException(Exception ex, org.springframework.web.server.ServerWebExchange exchange)protected reactor.core.publisher.Mono<Void>respond(org.springframework.web.server.ServerWebExchange exchange, org.springframework.http.HttpStatus status, Map<String,String> parameters, String errors)-
Methods inherited from class org.nentangso.core.web.rest.errors.ResponseEntityExceptionHandler
createResponseEntity, handleBindException, handleException, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleTypeMismatch
-
-
-
-
Field Detail
-
realmName
@Value("${nts.web.rest.exception-translator.realm-name:API Authentication by nentangso.org}") protected String realmName
-
-
Method Detail
-
handleNtsException
@ExceptionHandler({org.springframework.web.server.ResponseStatusException.class,org.springframework.dao.ConcurrencyFailureException.class,org.nentangso.core.service.errors.NotFoundException.class,org.nentangso.core.web.rest.errors.BadRequestAlertException.class,org.nentangso.core.service.errors.FormValidationException.class}) protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>> handleNtsException(Exception ex, org.springframework.web.server.ServerWebExchange exchange)
-
generateAuthenticateHeader
@Deprecated(since="1.1.5") protected String generateAuthenticateHeader(Exception ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)
Deprecated.
-
handleConversionNotSupported
protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>> handleConversionNotSupported(org.springframework.beans.ConversionNotSupportedException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)
Description copied from class:ResponseEntityExceptionHandlerCustomize the response for ConversionNotSupportedException.This method delegates to
ResponseEntityExceptionHandler.handleExceptionInternal(java.lang.Exception, java.lang.Object, org.springframework.http.HttpHeaders, org.springframework.http.HttpStatus, org.springframework.web.server.ServerWebExchange).- Overrides:
handleConversionNotSupportedin classResponseEntityExceptionHandler- Parameters:
ex- the exceptionheaders- the headers to be written to the responsestatus- the selected response statusexchange- the current request and response- Returns:
- a
Monowith theResponseEntityfor the response
-
handleMethodArgumentNotValid
protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>> handleMethodArgumentNotValid(org.springframework.web.bind.MethodArgumentNotValidException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)
Description copied from class:ResponseEntityExceptionHandlerCustomize the response for MethodArgumentNotValidException.This method delegates to
ResponseEntityExceptionHandler.handleExceptionInternal(java.lang.Exception, java.lang.Object, org.springframework.http.HttpHeaders, org.springframework.http.HttpStatus, org.springframework.web.server.ServerWebExchange).- Overrides:
handleMethodArgumentNotValidin classResponseEntityExceptionHandler- Parameters:
ex- the exceptionheaders- the headers to be written to the responsestatus- the selected response statusexchange- the current request and response- Returns:
- a
Monowith theResponseEntityfor the response
-
handleExceptionInternal
protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>> handleExceptionInternal(Exception ex, @Nullable Object body, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.server.ServerWebExchange exchange)
Description copied from class:ResponseEntityExceptionHandlerA single place to customize the response body of all exception types.- Overrides:
handleExceptionInternalin classResponseEntityExceptionHandler- Parameters:
ex- the exceptionbody- the body for the responseheaders- the headers for the responsestatus- the response statusexchange- the current request and response- Returns:
- a
Monowith theResponseEntityfor the response
-
buildUnprocessableErrors
protected Map<String,List<String>> buildUnprocessableErrors(Exception ex)
-
handleInternalServerError
@ExceptionHandler(java.lang.Exception.class) protected reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Object>> handleInternalServerError(Exception ex, org.springframework.web.server.ServerWebExchange exchange)
-
commence
@ExceptionHandler(org.springframework.security.core.AuthenticationException.class) public reactor.core.publisher.Mono<Void> commence(org.springframework.web.server.ServerWebExchange exchange, org.springframework.security.core.AuthenticationException authException)
- Specified by:
commencein interfaceorg.springframework.security.web.server.ServerAuthenticationEntryPoint
-
getAuthenticationStatus
protected org.springframework.http.HttpStatus getAuthenticationStatus(org.springframework.security.core.AuthenticationException authException)
-
createAuthenticationParameters
protected Map<String,String> createAuthenticationParameters(org.springframework.security.core.AuthenticationException authException)
-
respond
protected reactor.core.publisher.Mono<Void> respond(org.springframework.web.server.ServerWebExchange exchange, org.springframework.http.HttpStatus status, Map<String,String> parameters, String errors)
-
computeWWWAuthenticateHeaderValue
protected String computeWWWAuthenticateHeaderValue(Map<String,String> parameters)
-
handle
@ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) public reactor.core.publisher.Mono<Void> handle(org.springframework.web.server.ServerWebExchange exchange, org.springframework.security.access.AccessDeniedException denied)
- Specified by:
handlein interfaceorg.springframework.security.web.server.authorization.ServerAccessDeniedHandler
-
-