Search in sources :

Example 1 with RegistrationsPolicyType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.RegistrationsPolicyType in project midpoint by Evolveum.

the class AuthUtil method isPostAuthenticationEnabled.

public static boolean isPostAuthenticationEnabled(TaskManager taskManager, ModelInteractionService modelInteractionService) {
    MidPointPrincipal midpointPrincipal = getPrincipalUser();
    if (midpointPrincipal != null) {
        FocusType focus = midpointPrincipal.getFocus();
        Task task = taskManager.createTaskInstance(OPERATION_LOAD_FLOW_POLICY);
        OperationResult parentResult = new OperationResult(OPERATION_LOAD_FLOW_POLICY);
        RegistrationsPolicyType registrationPolicyType;
        try {
            registrationPolicyType = modelInteractionService.getFlowPolicy(focus.asPrismObject(), task, parentResult);
            if (registrationPolicyType == null) {
                return false;
            }
            SelfRegistrationPolicyType postAuthenticationPolicy = registrationPolicyType.getPostAuthentication();
            if (postAuthenticationPolicy == null) {
                return false;
            }
            String requiredLifecycleState = postAuthenticationPolicy.getRequiredLifecycleState();
            if (StringUtils.isNotBlank(requiredLifecycleState) && requiredLifecycleState.equals(focus.getLifecycleState())) {
                return true;
            }
        } catch (CommonException e) {
            LoggingUtils.logException(LOGGER, "Cannot determine post authentication policies", e);
        }
    }
    return false;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RegistrationsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.RegistrationsPolicyType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) SelfRegistrationPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelfRegistrationPolicyType) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)1 RegistrationsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.RegistrationsPolicyType)1 SelfRegistrationPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelfRegistrationPolicyType)1