/** * 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)); } }