Search in sources :

Example 1 with ConsentDecision

use of org.apereo.cas.consent.ConsentDecision in project cas by apereo.

the class AbstractConsentAction method prepareConsentForRequestContext.

/**
 * Prepare consent for request context.
 *
 * @param requestContext the request context
 */
protected void prepareConsentForRequestContext(final RequestContext requestContext) {
    final ConsentProperties consentProperties = casProperties.getConsent();
    final Service service = this.authenticationRequestServiceSelectionStrategies.resolveService(WebUtils.getService(requestContext));
    final RegisteredService registeredService = getRegisteredServiceForConsent(requestContext, service);
    final Authentication authentication = WebUtils.getAuthentication(requestContext);
    final Map<String, Object> attributes = consentEngine.resolveConsentableAttributesFrom(authentication, service, registeredService);
    requestContext.getFlowScope().put("attributes", attributes);
    requestContext.getFlowScope().put("principal", authentication.getPrincipal().getId());
    requestContext.getFlashScope().put("service", service);
    final ConsentDecision decision = consentEngine.findConsentDecision(service, registeredService, authentication);
    requestContext.getFlowScope().put("option", decision == null ? ConsentOptions.ATTRIBUTE_NAME.getValue() : decision.getOptions().getValue());
    final long reminder = decision == null ? consentProperties.getReminder() : decision.getReminder();
    requestContext.getFlowScope().put("reminder", Long.valueOf(reminder));
    requestContext.getFlowScope().put("reminderTimeUnit", decision == null ? consentProperties.getReminderTimeUnit().name() : decision.getReminderTimeUnit().name());
}
Also used : RegisteredService(org.apereo.cas.services.RegisteredService) Authentication(org.apereo.cas.authentication.Authentication) ConsentProperties(org.apereo.cas.configuration.model.support.consent.ConsentProperties) RegisteredService(org.apereo.cas.services.RegisteredService) Service(org.apereo.cas.authentication.principal.Service) ConsentDecision(org.apereo.cas.consent.ConsentDecision)

Aggregations

Authentication (org.apereo.cas.authentication.Authentication)1 Service (org.apereo.cas.authentication.principal.Service)1 ConsentProperties (org.apereo.cas.configuration.model.support.consent.ConsentProperties)1 ConsentDecision (org.apereo.cas.consent.ConsentDecision)1 RegisteredService (org.apereo.cas.services.RegisteredService)1