Error logging enhancement - log handled exceptions on WARN level
This commit is contained in:
committed by
Arnold Gálovics
parent
9c8239a9b1
commit
05dc8f9380
+3
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
@@ -37,6 +38,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class AccessDeniedExceptionMapper implements ExceptionMapper<AccessDeniedException> {
|
public class AccessDeniedExceptionMapper implements ExceptionMapper<AccessDeniedException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -44,6 +46,7 @@ public class AccessDeniedExceptionMapper implements ExceptionMapper<AccessDenied
|
|||||||
// Status code 403 really reads as:
|
// Status code 403 really reads as:
|
||||||
// "Authenticated - but not authorized":
|
// "Authenticated - but not authorized":
|
||||||
final String defaultUserMessage = exception.getMessage();
|
final String defaultUserMessage = exception.getMessage();
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage);
|
||||||
return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage))
|
return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage))
|
||||||
.type(MediaType.APPLICATION_JSON).build();
|
.type(MediaType.APPLICATION_JSON).build();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
@@ -38,10 +39,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class BadCredentialsExceptionMapper implements ExceptionMapper<BadCredentialsException> {
|
public class BadCredentialsExceptionMapper implements ExceptionMapper<BadCredentialsException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(@SuppressWarnings("unused") final BadCredentialsException exception) {
|
public Response toResponse(@SuppressWarnings("unused") final BadCredentialsException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON)
|
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||||
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
|
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -34,13 +35,14 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class InvalidJsonExceptionMapper implements ExceptionMapper<InvalidJsonException> {
|
public class InvalidJsonExceptionMapper implements ExceptionMapper<InvalidJsonException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(@SuppressWarnings("unused") final InvalidJsonException exception) {
|
public Response toResponse(@SuppressWarnings("unused") final InvalidJsonException exception) {
|
||||||
|
|
||||||
final String globalisationMessageCode = "error.msg.invalid.request.body";
|
final String globalisationMessageCode = "error.msg.invalid.request.body";
|
||||||
final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing.";
|
final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing.";
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage);
|
||||||
|
|
||||||
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
|
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -23,25 +23,28 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentiferException;
|
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentifierException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link ExceptionMapper} to map {@link InvalidTenantIdentiferException} thrown by platform during authentication
|
* An {@link ExceptionMapper} to map {@link InvalidTenantIdentifierException} thrown by platform during authentication
|
||||||
* into a HTTP API friendly format.
|
* into a HTTP API friendly format.
|
||||||
*
|
*
|
||||||
* The {@link InvalidTenantIdentiferException} is thrown by spring security on platform when a request contains an
|
* The {@link InvalidTenantIdentifierException} is thrown by spring security on platform when a request contains an
|
||||||
* invalid tenant identifier.
|
* invalid tenant identifier.
|
||||||
*/
|
*/
|
||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
public class InvalidTenantIdentifierExceptionMapper implements ExceptionMapper<InvalidTenantIdentiferException> {
|
@Slf4j
|
||||||
|
public class InvalidTenantIdentifierExceptionMapper implements ExceptionMapper<InvalidTenantIdentifierException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(@SuppressWarnings("unused") final InvalidTenantIdentiferException e) {
|
public Response toResponse(@SuppressWarnings("unused") final InvalidTenantIdentifierException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.invalidTenantIdentifier())
|
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.invalidTenantIdentifier())
|
||||||
.type(MediaType.APPLICATION_JSON).build();
|
.type(MediaType.APPLICATION_JSON).build();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -24,6 +24,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -34,13 +35,14 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class JsonSyntaxExceptionMapper implements ExceptionMapper<JsonSyntaxException> {
|
public class JsonSyntaxExceptionMapper implements ExceptionMapper<JsonSyntaxException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final JsonSyntaxException exception) {
|
public Response toResponse(final JsonSyntaxException exception) {
|
||||||
|
|
||||||
final String globalisationMessageCode = "error.msg.invalid.request.body";
|
final String globalisationMessageCode = "error.msg.invalid.request.body";
|
||||||
final String defaultUserMessage = "The JSON syntax provided in the body of the request is invalid: " + exception.getMessage();
|
final String defaultUserMessage = "The JSON syntax provided in the body of the request is invalid: " + exception.getMessage();
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage);
|
||||||
|
|
||||||
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
|
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -24,6 +24,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -34,13 +35,14 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class MalformedJsonExceptionMapper implements ExceptionMapper<MalformedJsonException> {
|
public class MalformedJsonExceptionMapper implements ExceptionMapper<MalformedJsonException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(@SuppressWarnings("unused") final MalformedJsonException exception) {
|
public Response toResponse(@SuppressWarnings("unused") final MalformedJsonException exception) {
|
||||||
|
|
||||||
final String globalisationMessageCode = "error.msg.invalid.request.body";
|
final String globalisationMessageCode = "error.msg.invalid.request.body";
|
||||||
final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing.";
|
final String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing.";
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage);
|
||||||
|
|
||||||
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
|
final ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage);
|
||||||
|
|
||||||
|
|||||||
+3
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.security.exception.NoAuthorizationException;
|
import org.apache.fineract.infrastructure.security.exception.NoAuthorizationException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -38,6 +39,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class NoAuthorizationExceptionMapper implements ExceptionMapper<NoAuthorizationException> {
|
public class NoAuthorizationExceptionMapper implements ExceptionMapper<NoAuthorizationException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,6 +47,7 @@ public class NoAuthorizationExceptionMapper implements ExceptionMapper<NoAuthori
|
|||||||
// Status code 403 really reads as:
|
// Status code 403 really reads as:
|
||||||
// "Authenticated - but not authorized":
|
// "Authenticated - but not authorized":
|
||||||
final String defaultUserMessage = exception.getMessage();
|
final String defaultUserMessage = exception.getMessage();
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultUserMessage);
|
||||||
return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage))
|
return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized(defaultUserMessage))
|
||||||
.type(MediaType.APPLICATION_JSON).build();
|
.type(MediaType.APPLICATION_JSON).build();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -23,16 +23,18 @@ import java.io.IOException;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class OAuth2ExceptionEntryPoint implements AuthenticationEntryPoint {
|
public class OAuth2ExceptionEntryPoint implements AuthenticationEntryPoint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
|
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
log.warn("Exception: {}, Message: {}", authException.getClass().getName(), authException.getMessage());
|
||||||
ApiGlobalErrorResponse errorResponse = ApiGlobalErrorResponse.unAuthenticated();
|
ApiGlobalErrorResponse errorResponse = ApiGlobalErrorResponse.unAuthenticated();
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -38,11 +39,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class PlatformApiDataValidationExceptionMapper implements ExceptionMapper<PlatformApiDataValidationException> {
|
public class PlatformApiDataValidationExceptionMapper implements ExceptionMapper<PlatformApiDataValidationException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final PlatformApiDataValidationException exception) {
|
public Response toResponse(final PlatformApiDataValidationException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}, Errors: {}", exception.getClass().getName(), exception.getMessage(), exception.getErrors());
|
||||||
final ApiGlobalErrorResponse dataValidationErrorResponse = ApiGlobalErrorResponse
|
final ApiGlobalErrorResponse dataValidationErrorResponse = ApiGlobalErrorResponse
|
||||||
.badClientRequest(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getErrors());
|
.badClientRequest(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getErrors());
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -38,11 +39,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class PlatformDataIntegrityExceptionMapper implements ExceptionMapper<PlatformDataIntegrityException> {
|
public class PlatformDataIntegrityExceptionMapper implements ExceptionMapper<PlatformDataIntegrityException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final PlatformDataIntegrityException exception) {
|
public Response toResponse(final PlatformDataIntegrityException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
final ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.dataIntegrityError(exception.getGlobalisationMessageCode(),
|
final ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.dataIntegrityError(exception.getGlobalisationMessageCode(),
|
||||||
exception.getDefaultUserMessage(), exception.getParameterName(), exception.getDefaultUserMessageArgs());
|
exception.getDefaultUserMessage(), exception.getParameterName(), exception.getDefaultUserMessageArgs());
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -38,11 +39,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class PlatformDomainRuleExceptionMapper implements ExceptionMapper<AbstractPlatformDomainRuleException> {
|
public class PlatformDomainRuleExceptionMapper implements ExceptionMapper<AbstractPlatformDomainRuleException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final AbstractPlatformDomainRuleException exception) {
|
public Response toResponse(final AbstractPlatformDomainRuleException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(
|
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(
|
||||||
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
||||||
// request understood but not carried out due to it violating some
|
// request understood but not carried out due to it violating some
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformInternalServerException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformInternalServerException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -37,11 +38,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class PlatformInternalServerExceptionMapper implements ExceptionMapper<PlatformInternalServerException> {
|
public class PlatformInternalServerExceptionMapper implements ExceptionMapper<PlatformInternalServerException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final PlatformInternalServerException exception) {
|
public Response toResponse(final PlatformInternalServerException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.serverSideError(exception.getGlobalisationMessageCode(),
|
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.serverSideError(exception.getGlobalisationMessageCode(),
|
||||||
exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
||||||
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build();
|
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build();
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -38,11 +39,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class PlatformResourceNotFoundExceptionMapper implements ExceptionMapper<AbstractPlatformResourceNotFoundException> {
|
public class PlatformResourceNotFoundExceptionMapper implements ExceptionMapper<AbstractPlatformResourceNotFoundException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final AbstractPlatformResourceNotFoundException exception) {
|
public Response toResponse(final AbstractPlatformResourceNotFoundException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(),
|
final ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(),
|
||||||
exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
||||||
return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build();
|
return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build();
|
||||||
|
|||||||
+3
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformServiceUnavailableException;
|
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformServiceUnavailableException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -39,10 +40,12 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class PlatformServiceUnavailableExceptionMapper implements ExceptionMapper<AbstractPlatformServiceUnavailableException> {
|
public class PlatformServiceUnavailableExceptionMapper implements ExceptionMapper<AbstractPlatformServiceUnavailableException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final AbstractPlatformServiceUnavailableException exception) {
|
public Response toResponse(final AbstractPlatformServiceUnavailableException exception) {
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
final ApiGlobalErrorResponse serviceUnavailableExceptionResponse = ApiGlobalErrorResponse.serviceUnavailable(
|
final ApiGlobalErrorResponse serviceUnavailableExceptionResponse = ApiGlobalErrorResponse.serviceUnavailable(
|
||||||
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs());
|
||||||
return Response.status(Status.SERVICE_UNAVAILABLE).entity(serviceUnavailableExceptionResponse).type(MediaType.APPLICATION_JSON)
|
return Response.status(Status.SERVICE_UNAVAILABLE).entity(serviceUnavailableExceptionResponse).type(MediaType.APPLICATION_JSON)
|
||||||
|
|||||||
+3
@@ -23,6 +23,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.useradministration.exception.UnAuthenticatedUserException;
|
import org.apache.fineract.useradministration.exception.UnAuthenticatedUserException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -35,11 +36,13 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class UnAuthenticatedUserExceptionMapper implements ExceptionMapper<UnAuthenticatedUserException> {
|
public class UnAuthenticatedUserExceptionMapper implements ExceptionMapper<UnAuthenticatedUserException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(@SuppressWarnings("unused") final UnAuthenticatedUserException exception) {
|
public Response toResponse(@SuppressWarnings("unused") final UnAuthenticatedUserException exception) {
|
||||||
// Status code 401 really reads as: "Unauthenticated":
|
// Status code 401 really reads as: "Unauthenticated":
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), exception.getMessage());
|
||||||
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON)
|
return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -25,6 +25,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||||
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
|
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||||
@@ -41,11 +42,11 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class UnrecognizedQueryParamExceptionMapper implements ExceptionMapper<UnrecognizedQueryParamException> {
|
public class UnrecognizedQueryParamExceptionMapper implements ExceptionMapper<UnrecognizedQueryParamException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final UnrecognizedQueryParamException exception) {
|
public Response toResponse(final UnrecognizedQueryParamException exception) {
|
||||||
|
|
||||||
final String parameterName = exception.getQueryParamKey();
|
final String parameterName = exception.getQueryParamKey();
|
||||||
final String parameterValue = exception.getQueryParamValue();
|
final String parameterValue = exception.getQueryParamValue();
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ public class UnrecognizedQueryParamExceptionMapper implements ExceptionMapper<Un
|
|||||||
.append(parameterName) //
|
.append(parameterName) //
|
||||||
.append(" has an unsupported value of: ") //
|
.append(" has an unsupported value of: ") //
|
||||||
.append(parameterValue);
|
.append(parameterValue);
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultEnglishMessage);
|
||||||
|
|
||||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
parameterName, parameterName, parameterValue, exception.getSupportedParams());
|
parameterName, parameterName, parameterValue, exception.getSupportedParams());
|
||||||
|
|||||||
+3
-1
@@ -25,6 +25,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.commands.exception.UnsupportedCommandException;
|
import org.apache.fineract.commands.exception.UnsupportedCommandException;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||||
@@ -38,16 +39,17 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class UnsupportedCommandExceptionMapper implements ExceptionMapper<UnsupportedCommandException> {
|
public class UnsupportedCommandExceptionMapper implements ExceptionMapper<UnsupportedCommandException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final UnsupportedCommandException exception) {
|
public Response toResponse(final UnsupportedCommandException exception) {
|
||||||
|
|
||||||
final List<ApiParameterError> errors = new ArrayList<>();
|
final List<ApiParameterError> errors = new ArrayList<>();
|
||||||
|
|
||||||
final StringBuilder validationErrorCode = new StringBuilder("error.msg.command.unsupported");
|
final StringBuilder validationErrorCode = new StringBuilder("error.msg.command.unsupported");
|
||||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The command ").append(exception.getUnsupportedCommandName())
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The command ").append(exception.getUnsupportedCommandName())
|
||||||
.append(" is not supported.");
|
.append(" is not supported.");
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), defaultEnglishMessage);
|
||||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName());
|
exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName());
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -25,6 +25,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
import org.apache.fineract.infrastructure.core.data.ApiGlobalErrorResponse;
|
||||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||||
import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException;
|
import org.apache.fineract.infrastructure.core.exception.UnsupportedParameterException;
|
||||||
@@ -38,11 +39,11 @@ import org.springframework.stereotype.Component;
|
|||||||
@Provider
|
@Provider
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
|
@Slf4j
|
||||||
public class UnsupportedParameterExceptionMapper implements ExceptionMapper<UnsupportedParameterException> {
|
public class UnsupportedParameterExceptionMapper implements ExceptionMapper<UnsupportedParameterException> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final UnsupportedParameterException exception) {
|
public Response toResponse(final UnsupportedParameterException exception) {
|
||||||
|
|
||||||
final List<ApiParameterError> errors = new ArrayList<>();
|
final List<ApiParameterError> errors = new ArrayList<>();
|
||||||
|
|
||||||
for (final String parameterName : exception.getUnsupportedParameters()) {
|
for (final String parameterName : exception.getUnsupportedParameters()) {
|
||||||
@@ -54,6 +55,7 @@ public class UnsupportedParameterExceptionMapper implements ExceptionMapper<Unsu
|
|||||||
|
|
||||||
errors.add(error);
|
errors.add(error);
|
||||||
}
|
}
|
||||||
|
log.warn("Exception: {}, Message: {}", exception.getClass().getName(), errors);
|
||||||
|
|
||||||
final ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse
|
final ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse
|
||||||
.badClientRequest("validation.msg.validation.errors.exist", "Validation errors exist.", errors);
|
.badClientRequest("validation.msg.validation.errors.exist", "Validation errors exist.", errors);
|
||||||
|
|||||||
+3
-3
@@ -25,13 +25,13 @@ import org.springframework.dao.EmptyResultDataAccessException;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InvalidTenantIdentiferException extends RuntimeException {
|
public class InvalidTenantIdentifierException extends RuntimeException {
|
||||||
|
|
||||||
public InvalidTenantIdentiferException(final String message) {
|
public InvalidTenantIdentifierException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidTenantIdentiferException(String message, EmptyResultDataAccessException e) {
|
public InvalidTenantIdentifierException(String message, EmptyResultDataAccessException e) {
|
||||||
super(message, e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -35,7 +35,7 @@ import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
|||||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||||
import org.apache.fineract.infrastructure.security.data.PlatformRequestLog;
|
import org.apache.fineract.infrastructure.security.data.PlatformRequestLog;
|
||||||
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentiferException;
|
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentifierException;
|
||||||
import org.apache.fineract.infrastructure.security.service.BasicAuthTenantDetailsService;
|
import org.apache.fineract.infrastructure.security.service.BasicAuthTenantDetailsService;
|
||||||
import org.apache.fineract.notification.service.NotificationReadPlatformService;
|
import org.apache.fineract.notification.service.NotificationReadPlatformService;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
@@ -116,7 +116,7 @@ public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tenantIdentifier == null && this.exceptionIfHeaderMissing) {
|
if (tenantIdentifier == null && this.exceptionIfHeaderMissing) {
|
||||||
throw new InvalidTenantIdentiferException("No tenant identifier found: Add request header of '"
|
throw new InvalidTenantIdentifierException("No tenant identifier found: Add request header of '"
|
||||||
+ this.tenantRequestHeader + "' or add the parameter 'tenantIdentifier' to query string of request URL.");
|
+ this.tenantRequestHeader + "' or add the parameter 'tenantIdentifier' to query string of request URL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.doFilterInternal(request, response, filterChain);
|
super.doFilterInternal(request, response, filterChain);
|
||||||
} catch (final InvalidTenantIdentiferException e) {
|
} catch (final InvalidTenantIdentifierException e) {
|
||||||
// deal with exception at low level
|
// deal with exception at low level
|
||||||
SecurityContextHolder.getContext().setAuthentication(null);
|
SecurityContextHolder.getContext().setAuthentication(null);
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -40,7 +40,7 @@ import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
|||||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||||
import org.apache.fineract.infrastructure.security.data.PlatformRequestLog;
|
import org.apache.fineract.infrastructure.security.data.PlatformRequestLog;
|
||||||
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentiferException;
|
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentifierException;
|
||||||
import org.apache.fineract.infrastructure.security.service.BasicAuthTenantDetailsService;
|
import org.apache.fineract.infrastructure.security.service.BasicAuthTenantDetailsService;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
@@ -107,7 +107,7 @@ public class TenantAwareTenantIdentifierFilter extends GenericFilterBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tenantIdentifier == null && this.exceptionIfHeaderMissing) {
|
if (tenantIdentifier == null && this.exceptionIfHeaderMissing) {
|
||||||
throw new InvalidTenantIdentiferException("No tenant identifier found: Add request header of '"
|
throw new InvalidTenantIdentifierException("No tenant identifier found: Add request header of '"
|
||||||
+ this.tenantRequestHeader + "' or add the parameter 'tenantIdentifier' to query string of request URL.");
|
+ this.tenantRequestHeader + "' or add the parameter 'tenantIdentifier' to query string of request URL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public class TenantAwareTenantIdentifierFilter extends GenericFilterBean {
|
|||||||
}
|
}
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
} catch (final InvalidTenantIdentiferException e) {
|
} catch (final InvalidTenantIdentifierException e) {
|
||||||
// deal with exception at low level
|
// deal with exception at low level
|
||||||
SecurityContextHolder.getContext().setAuthentication(null);
|
SecurityContextHolder.getContext().setAuthentication(null);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ package org.apache.fineract.infrastructure.security.service;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||||
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentiferException;
|
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentifierException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@@ -52,7 +52,7 @@ public class BasicAuthTenantDetailsServiceJdbc implements BasicAuthTenantDetails
|
|||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { tenantIdentifier }); // NOSONAR
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { tenantIdentifier }); // NOSONAR
|
||||||
} catch (final EmptyResultDataAccessException e) {
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.", e);
|
throw new InvalidTenantIdentifierException("The tenant identifier: " + tenantIdentifier + " is not valid.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,7 @@ package org.apache.fineract.infrastructure.security.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||||
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentiferException;
|
import org.apache.fineract.infrastructure.security.exception.InvalidTenantIdentifierException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@@ -52,7 +52,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
|||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { tenantIdentifier }); // NOSONAR
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { tenantIdentifier }); // NOSONAR
|
||||||
} catch (final EmptyResultDataAccessException e) {
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.", e);
|
throw new InvalidTenantIdentifierException("The tenant identifier: " + tenantIdentifier + " is not valid.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user