Search in sources :

Example 1 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class AbstractBasicDummyTest method test024Capabilities.

@Test
public void test024Capabilities() throws Exception {
    final String TEST_NAME = "test024Capabilities";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
    // WHEN
    PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
    ResourceType resourceType = resource.asObjectable();
    // THEN
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    // Check native capabilities
    CapabilityCollectionType nativeCapabilities = resourceType.getCapabilities().getNative();
    display("Native capabilities", PrismTestUtil.serializeAnyDataWrapped(nativeCapabilities));
    display("Resource", resourceType);
    List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
    assertNativeCredentialsCapability(capCred);
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
    if (supportsActivation()) {
        assertNotNull("native activation capability not present", capAct);
        assertNotNull("native activation status capability not present", capAct.getStatus());
    } else {
        assertNull("native activation capability sneaked in", capAct);
    }
    TestConnectionCapabilityType capTest = CapabilityUtil.getCapability(nativeCapabilitiesList, TestConnectionCapabilityType.class);
    assertNotNull("native test capability not present", capTest);
    ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class);
    assertNotNull("native script capability not present", capScript);
    assertNotNull("No host in native script capability", capScript.getHost());
    assertFalse("No host in native script capability", capScript.getHost().isEmpty());
    // TODO: better look inside
    capabilitiesCachingMetadataType = resourceType.getCapabilities().getCachingMetadata();
    assertNotNull("No capabilities caching metadata", capabilitiesCachingMetadataType);
    assertNotNull("No capabilities caching metadata timestamp", capabilitiesCachingMetadataType.getRetrievalTimestamp());
    assertNotNull("No capabilities caching metadata serial number", capabilitiesCachingMetadataType.getSerialNumber());
    // Check effective capabilites
    capCred = ResourceTypeUtil.getEffectiveCapability(resourceType, CredentialsCapabilityType.class);
    assertNotNull("password capability not found", capCred.getPassword());
    // Although connector does not support activation, the resource
    // specifies a way how to simulate it.
    // Therefore the following should succeed
    capAct = ResourceTypeUtil.getEffectiveCapability(resourceType, ActivationCapabilityType.class);
    assertNotNull("activation capability not found", capCred.getPassword());
    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resourceType);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    assertSteadyResource();
}
Also used : ScriptCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) TestConnectionCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test)

Example 2 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class TestSanity method test004Capabilities.

@Test
public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage {
    TestUtil.displayTestTile("test004Capabilities");
    // GIVEN
    checkRepoOpenDjResource();
    assertNoRepoCache();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    // WHEN
    modelWeb.getObject(ObjectTypes.RESOURCE.getTypeQName(), RESOURCE_OPENDJ_OID, options, objectHolder, resultHolder);
    ResourceType resource = (ResourceType) objectHolder.value;
    // THEN
    display("Resource", resource);
    assertNoRepoCache();
    CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
    List<Object> capabilities = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", capabilities.isEmpty());
    for (Object capability : nativeCapabilities.getAny()) {
        System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    if (resource.getCapabilities() != null) {
        for (Object capability : resource.getCapabilities().getConfigured().getAny()) {
            System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
        }
    }
    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities, CredentialsCapabilityType.class);
    assertNotNull("password capability not present", capCred.getPassword());
    // Connector cannot do activation, this should be null
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(capabilities, ActivationCapabilityType.class);
    assertNull("Found activation capability while not expecting it", capAct);
    capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    assertNotNull("password capability not found", capCred.getPassword());
    // Although connector does not support activation, the resource specifies a way how to simulate it.
    // Therefore the following should succeed
    capAct = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    assertNotNull("activation capability not found", capAct);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) Holder(javax.xml.ws.Holder) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class MidpointFunctionsImpl method computeProjectionLifecycle.

@Override
public <F extends FocusType> String computeProjectionLifecycle(F focus, ShadowType shadow, ResourceType resource) {
    if (focus == null || shadow == null) {
        return null;
    }
    if (!(focus instanceof UserType)) {
        return null;
    }
    if (shadow.getKind() != null && shadow.getKind() != ShadowKindType.ACCOUNT) {
        return null;
    }
    ProtectedStringType focusPasswordPs = FocusTypeUtil.getPasswordValue((UserType) focus);
    if (focusPasswordPs != null && focusPasswordPs.canGetCleartext()) {
        return null;
    }
    CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    if (credentialsCapabilityType == null) {
        return null;
    }
    PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword();
    if (passwordCapabilityType == null) {
        return null;
    }
    if (passwordCapabilityType.isEnabled() == Boolean.FALSE) {
        return null;
    }
    return SchemaConstants.LIFECYCLE_PROPOSED;
}
Also used : PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 4 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class ConnIdCapabilitiesAndSchemaParser method updateCapabilitiesFromSchema.

private void updateCapabilitiesFromSchema(@NotNull Schema connIdSchema, SpecialAttributes specialAttributes) {
    ActivationCapabilityType capAct = null;
    if (specialAttributes.enableAttributeInfo != null) {
        capAct = new ActivationCapabilityType();
        ActivationStatusCapabilityType capActStatus = new ActivationStatusCapabilityType();
        capAct.setStatus(capActStatus);
        if (!specialAttributes.enableAttributeInfo.isReturnedByDefault()) {
            capActStatus.setReturnedByDefault(false);
        }
    }
    if (specialAttributes.enableDateAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationValidityCapabilityType capValidFrom = new ActivationValidityCapabilityType();
        capAct.setValidFrom(capValidFrom);
        if (!specialAttributes.enableDateAttributeInfo.isReturnedByDefault()) {
            capValidFrom.setReturnedByDefault(false);
        }
    }
    if (specialAttributes.disableDateAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationValidityCapabilityType capValidTo = new ActivationValidityCapabilityType();
        capAct.setValidTo(capValidTo);
        if (!specialAttributes.disableDateAttributeInfo.isReturnedByDefault()) {
            capValidTo.setReturnedByDefault(false);
        }
    }
    if (specialAttributes.lockoutAttributeInfo != null) {
        if (capAct == null) {
            capAct = new ActivationCapabilityType();
        }
        ActivationLockoutStatusCapabilityType capActStatus = new ActivationLockoutStatusCapabilityType();
        capAct.setLockoutStatus(capActStatus);
        if (!specialAttributes.lockoutAttributeInfo.isReturnedByDefault()) {
            capActStatus.setReturnedByDefault(false);
        }
    }
    // TODO: activation and credentials should be per-objectclass capabilities
    if (capAct != null) {
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createActivation(capAct));
    }
    if (specialAttributes.passwordAttributeInfo != null) {
        CredentialsCapabilityType capCred = new CredentialsCapabilityType();
        PasswordCapabilityType capPass = new PasswordCapabilityType();
        if (!specialAttributes.passwordAttributeInfo.isReturnedByDefault()) {
            capPass.setReturnedByDefault(false);
        }
        if (specialAttributes.passwordAttributeInfo.isReadable()) {
            capPass.setReadable(true);
        }
        capCred.setPassword(capPass);
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createCredentials(capCred));
    }
    if (specialAttributes.auxiliaryObjectClassAttributeInfo != null) {
        AuxiliaryObjectClassesCapabilityType capAux = new AuxiliaryObjectClassesCapabilityType();
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createAuxiliaryObjectClasses(capAux));
    }
    boolean canPageSize = false;
    boolean canPageOffset = false;
    boolean canSort = false;
    boolean supportsReturnDefaultAttributes = false;
    for (OperationOptionInfo searchOption : connIdSchema.getSupportedOptionsByOperation(SearchApiOp.class)) {
        switch(searchOption.getName()) {
            case OperationOptions.OP_PAGE_SIZE:
                canPageSize = true;
                break;
            case OperationOptions.OP_PAGED_RESULTS_OFFSET:
                canPageOffset = true;
                break;
            case OperationOptions.OP_SORT_KEYS:
                canSort = true;
                break;
            case OperationOptions.OP_RETURN_DEFAULT_ATTRIBUTES:
                supportsReturnDefaultAttributes = true;
                break;
        }
    }
    if (canPageSize || canPageOffset || canSort) {
        PagedSearchCapabilityType capPage = new PagedSearchCapabilityType();
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createPagedSearch(capPage));
    }
    if (connIdSupportedOperations.contains(GetApiOp.class) || connIdSupportedOperations.contains(SearchApiOp.class)) {
        ReadCapabilityType capRead = new ReadCapabilityType();
        capRead.setReturnDefaultAttributesOption(supportsReturnDefaultAttributes);
        capabilities.add(CAPABILITY_OBJECT_FACTORY.createRead(capRead));
    }
    if (connIdSupportedOperations.contains(UpdateDeltaApiOp.class)) {
        processUpdateOperationOptions(connIdSchema.getSupportedOptionsByOperation(UpdateDeltaApiOp.class));
    } else if (connIdSupportedOperations.contains(UpdateApiOp.class)) {
        processUpdateOperationOptions(connIdSchema.getSupportedOptionsByOperation(UpdateApiOp.class));
    }
}
Also used : UpdateApiOp(org.identityconnectors.framework.api.operations.UpdateApiOp) ActivationLockoutStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType) ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) GetApiOp(org.identityconnectors.framework.api.operations.GetApiOp) SearchApiOp(org.identityconnectors.framework.api.operations.SearchApiOp) AuxiliaryObjectClassesCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AuxiliaryObjectClassesCapabilityType) PagedSearchCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType) OperationOptionInfo(org.identityconnectors.framework.common.objects.OperationOptionInfo) ActivationValidityCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) UpdateDeltaApiOp(org.identityconnectors.framework.api.operations.UpdateDeltaApiOp) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)

Example 5 with CredentialsCapabilityType

use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType in project midpoint by Evolveum.

the class AbstractManualConnectorInstance method fetchCapabilities.

@Override
public Collection<Object> fetchCapabilities(OperationResult parentResult) {
    Collection<Object> capabilities = new ArrayList<>();
    InternalMonitor.recordConnectorOperation("capabilities");
    // caching-only read capabilities
    ReadCapabilityType readCap = new ReadCapabilityType();
    readCap.setCachingOnly(true);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createRead(readCap));
    CreateCapabilityType createCap = new CreateCapabilityType();
    setManual(createCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createCreate(createCap));
    UpdateCapabilityType updateCap = new UpdateCapabilityType();
    updateCap.setAddRemoveAttributeValues(true);
    setManual(updateCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(updateCap));
    DeleteCapabilityType deleteCap = new DeleteCapabilityType();
    setManual(deleteCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createDelete(deleteCap));
    ActivationCapabilityType activationCap = new ActivationCapabilityType();
    ActivationStatusCapabilityType activationStatusCap = new ActivationStatusCapabilityType();
    activationCap.setStatus(activationStatusCap);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createActivation(activationCap));
    CredentialsCapabilityType credentialsCap = new CredentialsCapabilityType();
    PasswordCapabilityType passwordCapabilityType = new PasswordCapabilityType();
    credentialsCap.setPassword(passwordCapabilityType);
    capabilities.add(CAPABILITY_OBJECT_FACTORY.createCredentials(credentialsCap));
    return capabilities;
}
Also used : UpdateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType) ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) DeleteCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType) PasswordCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ArrayList(java.util.ArrayList) PrismObject(com.evolveum.midpoint.prism.PrismObject) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType) CreateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)

Aggregations

CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)11 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)8 PasswordCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PasswordCapabilityType)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 Test (org.testng.annotations.Test)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)5 Task (com.evolveum.midpoint.task.api.Task)3 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)3 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 PagedSearchCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.PagedSearchCapabilityType)2 ReadCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 NonEmptyLoadableModel (com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel)1 WebModelServiceUtils (com.evolveum.midpoint.gui.api.util.WebModelServiceUtils)1 ModelService (com.evolveum.midpoint.model.api.ModelService)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 CloneUtil (com.evolveum.midpoint.prism.util.CloneUtil)1