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());
}
Aggregations