@Override
protected Event doExecute(final RequestContext requestContext) {
val agent = WebUtils.getHttpServletRequestUserAgentFromRequestContext();
val geoLocation = WebUtils.getHttpServletRequestGeoLocationFromRequestContext();
if (geoLocation != null && StringUtils.isNotBlank(agent)
&& !adaptiveAuthenticationPolicy.apply(requestContext, agent, geoLocation)) {
val msg = "Adaptive authentication policy does not allow this request for " + agent + " and " + geoLocation;
val map = CollectionUtils.<String, Throwable>wrap(UnauthorizedAuthenticationException.class.getSimpleName(), new UnauthorizedAuthenticationException(msg));
val error = new AuthenticationException(msg, map, new HashMap<>(0));
return new Event(this, CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE,
new LocalAttributeMap<>(CasWebflowConstants.TRANSITION_ID_ERROR, error));
}
val serviceTicketEvent = this.serviceTicketRequestWebflowEventResolver.resolveSingle(requestContext);
if (serviceTicketEvent != null) {
fireEventHooks(serviceTicketEvent, requestContext);
return serviceTicketEvent;
}
val finalEvent = this.initialAuthenticationAttemptWebflowEventResolver.resolveSingle(requestContext);
fireEventHooks(finalEvent, requestContext);
return finalEvent;
}