@Override public Set<Event> resolve(final RequestContext context) { LOGGER.trace("Attempting to resolve authentication event using resolver [{}]", getName()); WebUtils.putWarnCookieIfRequestParameterPresent(this.warnCookieGenerator, context); WebUtils.putPublicWorkstationToFlowIfRequestParameterPresent(context); return resolveInternal(context); }
/** * New event based on the id, which contains an error attribute referring to the exception occurred. * * @param id the id * @param error the error * @return the event */ protected Event newEvent(final String id, final Throwable error) { return newEvent(id, new LocalAttributeMap(CasWebflowConstants.TRANSITION_ID_ERROR, error)); }
@Override public Event resolveSingle(final RequestContext context) { val events = resolve(context); if (events == null || events.isEmpty()) { return null; } val event = events.iterator().next(); LOGGER.debug("Resolved single event [{}] via [{}] for this context", event.getId(), event.getSource().getClass().getName()); return event; }
/** * Handle authentication transaction and grant ticket granting ticket. * * @param context the context * @return the set */ protected Set<Event> handleAuthenticationTransactionAndGrantTicketGrantingTicket(final RequestContext context) { val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context); try { val credential = getCredentialFromContext(context); val builderResult = WebUtils.getAuthenticationResultBuilder(context); LOGGER.debug("Handling authentication transaction for credential [{}]", credential); val service = WebUtils.getService(context); val builder = this.authenticationSystemSupport.handleAuthenticationTransaction(service, builderResult, credential); LOGGER.debug("Issuing ticket-granting tickets for service [{}]", service); return CollectionUtils.wrapSet(grantTicketGrantingTicketToAuthenticationResult(context, builder, service)); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); val messageContext = context.getMessageContext(); messageContext.addMessage(new MessageBuilder() .error() .code(DEFAULT_MESSAGE_BUNDLE_PREFIX.concat(e.getClass().getSimpleName())) .build()); response.setStatus(HttpStatus.UNAUTHORIZED.value()); return CollectionUtils.wrapSet(getAuthenticationFailureErrorEvent(context)); } }
/** * Resolve service from authentication request service. * * @param context the context * @return the service */ protected Service resolveServiceFromAuthenticationRequest(final RequestContext context) { val ctxService = WebUtils.getService(context); return resolveServiceFromAuthenticationRequest(ctxService); }
/** * New event event. * * @param id the id * @return the event */ protected Event newEvent(final String id) { return newEvent(id, new LocalAttributeMap<>()); }
/** * Grant ticket granting ticket. * * @param context the context * @param authenticationResultBuilder the authentication result builder * @param service the service * @return the event */ protected Event grantTicketGrantingTicketToAuthenticationResult(final RequestContext context, final AuthenticationResultBuilder authenticationResultBuilder, final Service service) { WebUtils.putAuthenticationResultBuilder(authenticationResultBuilder, context); WebUtils.putServiceIntoFlowScope(context, service); return newEvent(CasWebflowConstants.TRANSITION_ID_SUCCESS); }