Handle Access Denied 404 with spring boot and Okta

If any user which is not assigned to the application and tries to access that application I get HttpClientErrorException 404 in my logs. How we can handle this and we can redirect user to the default error page with the response we got from Okta eg. (User+is+not+assigned+to+the+client+application.) I am implementing it in Spring boot app