argos/dmp-backend/web/src/main/java/eu/eudat/controllers/controllerhandler/ControllerUnauthorisedHandl...

36 lines
1.1 KiB
Java
Raw Normal View History

2018-06-27 12:29:21 +02:00
package eu.eudat.controllers.controllerhandler;
import eu.eudat.exceptions.security.UnauthorisedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2018-06-27 12:29:21 +02:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
2018-06-27 12:29:21 +02:00
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
2018-09-18 14:41:24 +02:00
import javax.annotation.Priority;
2018-06-27 12:29:21 +02:00
/**
* Created by ikalyvas on 6/12/2018.
*/
@ControllerAdvice
@Order(4)
2018-06-27 12:29:21 +02:00
public class ControllerUnauthorisedHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerUnauthorisedHandler.class);
2018-06-27 12:29:21 +02:00
@Autowired
2020-06-29 12:00:34 +02:00
public ControllerUnauthorisedHandler() {
2018-06-27 12:29:21 +02:00
}
@ExceptionHandler(UnauthorisedException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public void processValidationError(UnauthorisedException ex) {
logger.error(ex.getMessage(), ex);
2018-06-27 12:29:21 +02:00
return;
}
}