Search in sources :

Example 1 with FlowSession

use of org.springframework.webflow.execution.FlowSession in project cas by apereo.

the class WebUtils method putTicketGrantingTicketInScopes.

/**
 * Put ticket granting ticket in request and flow scopes.
 *
 * @param context     the context
 * @param ticketValue the ticket value
 */
public static void putTicketGrantingTicketInScopes(final RequestContext context, final String ticketValue) {
    putTicketGrantingTicketIntoMap(context.getRequestScope(), ticketValue);
    putTicketGrantingTicketIntoMap(context.getFlowScope(), ticketValue);
    FlowSession session = context.getFlowExecutionContext().getActiveSession().getParent();
    while (session != null) {
        putTicketGrantingTicketIntoMap(session.getScope(), ticketValue);
        session = session.getParent();
    }
}
Also used : FlowSession(org.springframework.webflow.execution.FlowSession)

Example 2 with FlowSession

use of org.springframework.webflow.execution.FlowSession in project cas by apereo.

the class WebUtils method getCredential.

/**
 * Gets credential from the context.
 *
 * @param context the context
 * @return the credential, or null if it cant be found in the context or if it has no id.
 */
public static Credential getCredential(final RequestContext context) {
    final Credential cFromRequest = (Credential) context.getRequestScope().get(PARAMETER_CREDENTIAL);
    final Credential cFromFlow = (Credential) context.getFlowScope().get(PARAMETER_CREDENTIAL);
    final Credential cFromConversation = (Credential) context.getConversationScope().get(PARAMETER_CREDENTIAL);
    Credential credential = cFromRequest;
    if (credential == null || StringUtils.isBlank(credential.getId())) {
        credential = cFromFlow;
    }
    if (credential == null || StringUtils.isBlank(credential.getId())) {
        credential = cFromConversation;
        if (credential != null && !StringUtils.isBlank(credential.getId())) {
            // aup and some other modules look only in flow scope via expressions, push down if needed
            context.getFlowScope().put(PARAMETER_CREDENTIAL, credential);
        }
    }
    if (credential == null) {
        final FlowSession session = context.getFlowExecutionContext().getActiveSession();
        credential = session.getScope().get(PARAMETER_CREDENTIAL, Credential.class);
    }
    if (credential != null && StringUtils.isBlank(credential.getId())) {
        return null;
    }
    return credential;
}
Also used : Credential(org.apereo.cas.authentication.Credential) FlowSession(org.springframework.webflow.execution.FlowSession)

Aggregations

FlowSession (org.springframework.webflow.execution.FlowSession)2 Credential (org.apereo.cas.authentication.Credential)1