Search in sources :

Example 46 with ActivationType

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

the class UserProfileServiceMock method initializePrincipalFromAssignments.

private void initializePrincipalFromAssignments(MidPointPrincipal principal, PrismObject<SystemConfigurationType> systemConfiguration) {
    OperationResult result = new OperationResult(UserProfileServiceMock.class.getName() + ".addAuthorizations");
    principal.setApplicableSecurityPolicy(locateSecurityPolicy(principal, systemConfiguration, result));
    if (systemConfiguration != null) {
        principal.setAdminGuiConfiguration(systemConfiguration.asObjectable().getAdminGuiConfiguration());
    }
    AuthorizationType authorizationType = new AuthorizationType();
    authorizationType.getAction().add("FAKE");
    principal.getAuthorities().add(new Authorization(authorizationType));
    ActivationType activation = principal.getUser().getActivation();
    if (activation != null) {
        activationComputer.computeEffective(principal.getUser().getLifecycleState(), activation);
    }
}
Also used : Authorization(com.evolveum.midpoint.security.api.Authorization) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuthorizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType)

Example 47 with ActivationType

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

the class TestOpenLdap method test700CheckBarbossaLockoutStatus.

@Test
public void test700CheckBarbossaLockoutStatus() throws Exception {
    final String TEST_NAME = "test700CheckBarbossaLockoutStatus";
    TestUtil.displayTestTile(this, TEST_NAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObject<ShadowType> shadow = getShadowModel(accountBarbossaOid);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    display("Shadow (model)", shadow);
    ActivationType activation = shadow.asObjectable().getActivation();
    if (activation != null) {
        LockoutStatusType lockoutStatus = shadow.asObjectable().getActivation().getLockoutStatus();
        if (lockoutStatus != null && lockoutStatus != LockoutStatusType.NORMAL) {
            AssertJUnit.fail("Barbossa is locked!");
        }
    }
    assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_PASSWORD_2);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) LockoutStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 48 with ActivationType

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

the class TestOpenLdap method test702LockOutBarbossa.

@Test
public void test702LockOutBarbossa() throws Exception {
    final String TEST_NAME = "test702LockOutBarbossa";
    TestUtil.displayTestTile(this, TEST_NAME);
    Entry entry = getLdapAccountByUid(USER_BARBOSSA_USERNAME);
    display("LDAP Entry before", entry);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    for (int i = 0; i < 10; i++) {
        LdapNetworkConnection conn;
        try {
            conn = ldapConnect(null, entry.getDn().toString(), "this password is wrong");
        } catch (SecurityException e) {
            // Good bad attempt
            continue;
        }
        assertNotReached();
    }
    // THEN
    TestUtil.displayThen(TEST_NAME);
    entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
    display("LDAP Entry after", entry);
    PrismObject<ShadowType> shadow = getShadowModel(accountBarbossaOid);
    display("Shadow (model)", shadow);
    ActivationType activation = shadow.asObjectable().getActivation();
    assertNotNull("No activation", activation);
    LockoutStatusType lockoutStatus = shadow.asObjectable().getActivation().getLockoutStatus();
    assertEquals("Wrong lockout status", LockoutStatusType.LOCKED, lockoutStatus);
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) LockoutStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) Test(org.testng.annotations.Test)

Example 49 with ActivationType

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

the class ActivationComputer method computeEffective.

public void computeEffective(String lifecycleStatus, ActivationType activationType, XMLGregorianCalendar referenceTime) {
    ActivationStatusType effectiveStatus = null;
    if (lifecycleStatus != null && !lifecycleStatus.equals(SchemaConstants.LIFECYCLE_ACTIVE) && !lifecycleStatus.equals(SchemaConstants.LIFECYCLE_DEPRECATED)) {
        effectiveStatus = ActivationStatusType.DISABLED;
    }
    if (SchemaConstants.LIFECYCLE_ARCHIVED.equals(lifecycleStatus)) {
        effectiveStatus = ActivationStatusType.ARCHIVED;
    }
    ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
    if (effectiveStatus == null && administrativeStatus != null) {
        // Explicit administrative status overrides everything 
        effectiveStatus = administrativeStatus;
    }
    TimeIntervalStatusType validityStatus = getValidityStatus(activationType);
    if (effectiveStatus == null) {
        if (validityStatus == null) {
            // No administrative status, no validity. Defaults to enabled.
            effectiveStatus = ActivationStatusType.ENABLED;
        } else {
            switch(validityStatus) {
                case AFTER:
                case BEFORE:
                    effectiveStatus = ActivationStatusType.DISABLED;
                    break;
                case IN:
                    effectiveStatus = ActivationStatusType.ENABLED;
                    break;
            }
        }
    }
    activationType.setEffectiveStatus(effectiveStatus);
    activationType.setValidityStatus(validityStatus);
}
Also used : TimeIntervalStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Example 50 with ActivationType

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

the class TestActivationComputer method createActivationType.

private ActivationType createActivationType(ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo) {
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(administrativeStatus);
    activationType.setValidFrom(validFrom);
    activationType.setValidTo(validTo);
    return activationType;
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)59 Test (org.testng.annotations.Test)34 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)22 Task (com.evolveum.midpoint.task.api.Task)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)13 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)12 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)9 ObjectWrapperFactory (com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory)5 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)5 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)4 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)4 QName (javax.xml.namespace.QName)4 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)3 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)3 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)3