org.apereo.cas.web.flow.ConfirmConsentAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cas-server-support-consent-webflow Show documentation
Show all versions of cas-server-support-consent-webflow Show documentation
cas-server-support-consent-webflow
The newest version!
package org.apereo.cas.web.flow;
import org.apereo.cas.authentication.AuthenticationServiceSelectionPlan;
import org.apereo.cas.authentication.attribute.AttributeDefinitionStore;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.consent.ConsentEngine;
import org.apereo.cas.consent.ConsentReminderOptions;
import org.apereo.cas.services.ServicesManager;
import org.apereo.cas.util.function.FunctionUtils;
import org.apereo.cas.web.support.WebUtils;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.webflow.action.EventFactorySupport;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
import java.time.temporal.ChronoUnit;
import java.util.Locale;
/**
* This is {@link ConfirmConsentAction}.
*
* @author Misagh Moayyed
* @since 5.1.0
*/
@Slf4j
public class ConfirmConsentAction extends AbstractConsentAction {
public ConfirmConsentAction(final ServicesManager servicesManager,
final AuthenticationServiceSelectionPlan strategies,
final ConsentEngine consentEngine,
final CasConfigurationProperties casProperties,
final AttributeDefinitionStore attributeDefinitionStore,
final ConfigurableApplicationContext applicationContext) {
super(casProperties, servicesManager, strategies, consentEngine, attributeDefinitionStore, applicationContext);
}
@Override
protected Event doExecuteInternal(final RequestContext requestContext) {
return FunctionUtils.doUnchecked(() -> {
val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);
val webService = WebUtils.getService(requestContext);
val service = this.authenticationRequestServiceSelectionStrategies.resolveService(webService);
val registeredService = getRegisteredServiceForConsent(requestContext, service);
val authentication = WebUtils.getAuthentication(requestContext);
val optionValue = Integer.parseInt(request.getParameter("option"));
val option = ConsentReminderOptions.valueOf(optionValue);
val reminder = Long.parseLong(request.getParameter("reminder"));
val reminderTimeUnit = request.getParameter("reminderTimeUnit");
val unit = ChronoUnit.valueOf(reminderTimeUnit.toUpperCase(Locale.ENGLISH));
LOGGER.debug("Storing consent decision for service [{}]", service);
consentEngine.storeConsentDecision(service, registeredService, authentication, reminder, unit, option);
return new EventFactorySupport().success(this);
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy