@@ -0,0 +1,712 @@
+package com.mostafa.security.controllers;%0D%0A%0D%0Aimport org.springframework.http.HttpStatus;%0D%0Aimport org.springframework.security.access.AccessDeniedException;%0D%0Aimport org.springframework.web.bind.annotation.ControllerAdvice;%0D%0Aimport org.springframework.web.bind.annotation.ExceptionHandler;%0D%0Aimport org.springframework.web.bind.annotation.ResponseBody;%0D%0Aimport org.springframework.web.bind.annotation.ResponseStatus;%0D%0A%0D%0A@ControllerAdvice %0D%0Apublic class ExceptionControllerAdvice %7B%0D%0A%0D%0A    @ExceptionHandler(AccessDeniedException.class)%0D%0A    @ResponseStatus(HttpStatus.UNAUTHORIZED)%0D%0A    @ResponseBody%0D%0A    public String exception(AccessDeniedException e) %7B%0D%0A        return %22%7B%5C%22status%5C%22:%5C%22access denied%5C%22%7D%22;%0D%0A    %7D%0D%0A%7D

Add AccessDenied REST handler