protected String handleAuthenticationException(final AuthenticationException exception, final RequestContext requestContext) {
        if (exception.getHandlerErrors().containsKey(UnauthorizedServiceForPrincipalException.class.getSimpleName())) {
            val url = WebUtils.getUnauthorizedRedirectUrlFromFlowScope(requestContext);
            if (url != null) {
                LOGGER.warn("Unauthorized service access for principal; CAS will be redirecting to [{}]", url);
                return CasWebflowConstants.STATE_ID_SERVICE_UNAUTHZ_CHECK;
            }
        }
        return errors.translateException(requestContext, exception);
    }
Maps an authentication exception onto a state name equal to the simple class name of the handler errors.
with highest precedence. Also sets an ERROR severity message in the
message context of the form {@code [messageBundlePrefix][exceptionClassSimpleName]}
for for the first handler
error that is configured. If no match is found, {@value CasWebflowExceptionCatalog#UNKNOWN} is returned.

@param exception              Authentication error to handle.
@param requestContext the spring context
@return Name of next flow state to transition to or {@value CasWebflowExceptionCatalog#UNKNOWN}
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/authentication/DefaultCasWebflowAuthenticationExceptionHandler.java