private static Collection<? extends MessageDescriptor> calculateAuthenticationWarningMessages(final RequestContext context) {
        val ticketGrantingTicket = WebUtils.getTicketGrantingTicket(context);
        return Optional.ofNullable(ticketGrantingTicket)
            .filter(AuthenticationAwareTicket.class::isInstance)
            .map(AuthenticationAwareTicket.class::cast)
            .map(tgt -> {
                val authentication = tgt.getAuthentication();
                val messages = authentication.getSuccesses().entrySet();
                val warnings = messages
                    .stream()
                    .map(entry -> entry.getValue().getWarnings())
                    .filter(entry -> !entry.isEmpty())
                    .collect(Collectors.toList());
                warnings.add(authentication.getWarnings());
                return warnings
                    .stream()
                    .flatMap(Collection::stream)
                    .peek(message -> addMessageDescriptorToMessageContext(context.getMessageContext(), message))
                    .collect(Collectors.<MessageDescriptor>toSet());
            })
            .orElseGet(HashSet::new);
    }
Action that handles the {@link TicketGrantingTicket} creation and destruction. If the
action is given a {@link TicketGrantingTicket} and one also already exists, the old
one is destroyed and replaced with the new one conditionally.

@author Scott Battaglia
@since 3.0.0
support/cas-server-support-actions-core/src/main/java/org/apereo/cas/web/flow/login/CreateTicketGrantingTicketAction.java