Search in sources :

Example 1 with ConsentProperties

use of org.apereo.cas.configuration.model.support.consent.ConsentProperties in project cas by apereo.

the class CasConsentCoreConfiguration method consentCipherExecutor.

@ConditionalOnMissingBean(name = "consentCipherExecutor")
@Bean
@RefreshScope
public CipherExecutor consentCipherExecutor() {
    final ConsentProperties consent = casProperties.getConsent();
    final EncryptionJwtSigningJwtCryptographyProperties crypto = consent.getCrypto();
    if (crypto.isEnabled()) {
        return new AttributeReleaseConsentCipherExecutor(crypto.getEncryption().getKey(), crypto.getSigning().getKey(), crypto.getAlg());
    }
    LOGGER.debug("Consent attributes stored by CAS are not signed/encrypted.");
    return CipherExecutor.noOp();
}
Also used : ConsentProperties(org.apereo.cas.configuration.model.support.consent.ConsentProperties) AttributeReleaseConsentCipherExecutor(org.apereo.cas.consent.AttributeReleaseConsentCipherExecutor) EncryptionJwtSigningJwtCryptographyProperties(org.apereo.cas.configuration.model.core.util.EncryptionJwtSigningJwtCryptographyProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with ConsentProperties

use of org.apereo.cas.configuration.model.support.consent.ConsentProperties 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

ConsentProperties (org.apereo.cas.configuration.model.support.consent.ConsentProperties)2 Authentication (org.apereo.cas.authentication.Authentication)1 Service (org.apereo.cas.authentication.principal.Service)1 EncryptionJwtSigningJwtCryptographyProperties (org.apereo.cas.configuration.model.core.util.EncryptionJwtSigningJwtCryptographyProperties)1 AttributeReleaseConsentCipherExecutor (org.apereo.cas.consent.AttributeReleaseConsentCipherExecutor)1 ConsentDecision (org.apereo.cas.consent.ConsentDecision)1 RegisteredService (org.apereo.cas.services.RegisteredService)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1