I still new with Spring especially spring security. This application is Restful application.
Following is snippet from @RestController
:
You may be able to create a custom filter that can catch an AccessDeniedException
and add the filter after ExceptionTranslationFilter
in the configuration file in the following way:
http.addFilterAfter(customExceptionTranslationFilter, ExceptionTranslationFilter.class)
After catching the exception, you can use the response object to respond in the way you'd like.
You can then also add the ability to work with other exception you may want to throw in your Controllers.