Search in sources :

Example 1 with DummyObjectClass

use of com.evolveum.icf.dummy.resource.DummyObjectClass in project midpoint by Evolveum.

the class DummyConnector method createAccountObjectClass.

private ObjectClassInfo createAccountObjectClass(boolean supportsActivation) throws SchemaViolationException, ConflictException {
    // __ACCOUNT__ objectclass
    DummyObjectClass dummyAccountObjectClass;
    try {
        dummyAccountObjectClass = resource.getAccountObjectClass();
    } catch (ConnectException e) {
        throw new ConnectionFailedException(e.getMessage(), e);
    } catch (FileNotFoundException e) {
        throw new ConnectorIOException(e.getMessage(), e);
    } catch (IllegalArgumentException e) {
        throw new ConnectorException(e.getMessage(), e);
    }
    // DO NOT catch IllegalStateException, let it pass
    ObjectClassInfoBuilder objClassBuilder = createCommonObjectClassBuilder(getAccountObjectClassName(), dummyAccountObjectClass, supportsActivation);
    // __PASSWORD__ attribute
    AttributeInfo passwordAttrInfo;
    switch(configuration.getPasswordReadabilityMode()) {
        case DummyConfiguration.PASSWORD_READABILITY_MODE_READABLE:
        case DummyConfiguration.PASSWORD_READABILITY_MODE_INCOMPLETE:
            AttributeInfoBuilder aib = new AttributeInfoBuilder();
            aib.setName(OperationalAttributes.PASSWORD_NAME);
            aib.setType(GuardedString.class);
            aib.setMultiValued(false);
            aib.setReadable(true);
            aib.setReturnedByDefault(false);
            passwordAttrInfo = aib.build();
            break;
        default:
            passwordAttrInfo = OperationalAttributeInfos.PASSWORD;
            break;
    }
    objClassBuilder.addAttributeInfo(passwordAttrInfo);
    return objClassBuilder.build();
}
Also used : DummyObjectClass(com.evolveum.icf.dummy.resource.DummyObjectClass) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) FileNotFoundException(java.io.FileNotFoundException) ConnectionFailedException(org.identityconnectors.framework.common.exceptions.ConnectionFailedException) ConnectException(java.net.ConnectException)

Example 2 with DummyObjectClass

use of com.evolveum.icf.dummy.resource.DummyObjectClass in project midpoint by Evolveum.

the class DummyConnector method convertToConnectorObject.

private ConnectorObject convertToConnectorObject(DummyAccount account, Collection<String> attributesToGet) throws SchemaViolationException {
    DummyObjectClass objectClass;
    try {
        objectClass = resource.getAccountObjectClass();
    } catch (ConnectException e) {
        log.error(e, e.getMessage());
        throw new ConnectionFailedException(e.getMessage(), e);
    } catch (FileNotFoundException e) {
        log.error(e, e.getMessage());
        throw new ConnectorIOException(e.getMessage(), e);
    } catch (ConflictException e) {
        log.error(e, e.getMessage());
        throw new AlreadyExistsException(e);
    }
    ConnectorObjectBuilder builder = createConnectorObjectBuilderCommon(account, objectClass, attributesToGet, true);
    builder.setObjectClass(ObjectClass.ACCOUNT);
    // Password is not returned by default (hardcoded ICF specification)
    if (account.getPassword() != null && attributesToGet != null && attributesToGet.contains(OperationalAttributes.PASSWORD_NAME)) {
        switch(configuration.getPasswordReadabilityMode()) {
            case DummyConfiguration.PASSWORD_READABILITY_MODE_READABLE:
                GuardedString gs = new GuardedString(account.getPassword().toCharArray());
                builder.addAttribute(OperationalAttributes.PASSWORD_NAME, gs);
                break;
            case DummyConfiguration.PASSWORD_READABILITY_MODE_INCOMPLETE:
                AttributeBuilder ab = new AttributeBuilder();
                ab.setName(OperationalAttributes.PASSWORD_NAME);
                ab.setAttributeValueCompleteness(AttributeValueCompleteness.INCOMPLETE);
                builder.addAttribute(ab.build());
                break;
            default:
        }
    }
    if (account.isLockout() != null) {
        builder.addAttribute(OperationalAttributes.LOCK_OUT_NAME, account.isLockout());
    }
    return builder.build();
}
Also used : DummyObjectClass(com.evolveum.icf.dummy.resource.DummyObjectClass) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) AlreadyExistsException(org.identityconnectors.framework.common.exceptions.AlreadyExistsException) ObjectAlreadyExistsException(com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException) ConflictException(com.evolveum.icf.dummy.resource.ConflictException) FileNotFoundException(java.io.FileNotFoundException) GuardedString(org.identityconnectors.common.security.GuardedString) ConnectionFailedException(org.identityconnectors.framework.common.exceptions.ConnectionFailedException) ConnectException(java.net.ConnectException)

Example 3 with DummyObjectClass

use of com.evolveum.icf.dummy.resource.DummyObjectClass in project midpoint by Evolveum.

the class TestDummyHacks method initSystem.

/*
	 * (non-Javadoc)
	 * 
	 * @see com.evolveum.midpoint.test.AbstractIntegrationTest#initSystem()
	 */
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    // DO NOT DO provisioningService.postInit(..)
    // We want to avoid connector discovery and insert our own connector object
    //		provisioningService.postInit(initResult);
    connector = repoAddObjectFromFile(CONNECTOR_DUMMY_FILE, initResult);
    resource = repoAddObjectFromFile(RESOURCE_DUMMY_FILE, initResult);
    resourceType = resource.asObjectable();
    dummyResource = DummyResource.getInstance();
    dummyResource.reset();
    dummyResource.populateWithDefaultSchema();
    DummyObjectClass accountObjectClass = dummyResource.getAccountObjectClass();
    accountObjectClass.addAttributeDefinition(ProvisioningTestUtil.CONNID_DESCRIPTION_NAME, String.class);
}
Also used : DummyObjectClass(com.evolveum.icf.dummy.resource.DummyObjectClass)

Example 4 with DummyObjectClass

use of com.evolveum.icf.dummy.resource.DummyObjectClass in project midpoint by Evolveum.

the class TestUniversity method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    reconciliationTaskResultListener = new DebugReconciliationTaskResultListener();
    reconciliationTaskHandler.setReconciliationTaskResultListener(reconciliationTaskResultListener);
    // Resources
    dummyResourceCtlHr = DummyResourceContoller.create(RESOURCE_DUMMY_HR_ID, resourceDummyHr);
    DummyObjectClass privilegeObjectClass = dummyResourceCtlHr.getDummyResource().getPrivilegeObjectClass();
    dummyResourceCtlHr.addAttrDef(privilegeObjectClass, DUMMY_PRIVILEGE_ATTRIBUTE_HR_ORGPATH, String.class, false, false);
    dummyResourceHr = dummyResourceCtlHr.getDummyResource();
    resourceDummyHr = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_HR_FILE, RESOURCE_DUMMY_HR_OID, initTask, initResult);
    resourceDummyHrType = resourceDummyHr.asObjectable();
    dummyResourceCtlHr.setResource(resourceDummyHr);
    dummyResourceHr.setSyncStyle(DummySyncStyle.SMART);
    resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    openDJController.setResource(resourceOpenDj);
    //		// LDAP content
    //		openDJController.addEntryFromLdifFile(SCABB_OU_LDIF_FILE);
    //		openDJController.addEntryFromLdifFile(BOOTY_OU_LDIF_FILE);
    //		openDJController.addEntryFromLdifFile(BOOTY_LOOKOUT_OU_LDIF_FILE);
    //
    // Object Templates
    importObjectFromFile(OBJECT_TEMPLATE_ORG_FILE, initResult);
    setDefaultObjectTemplate(OrgType.COMPLEX_TYPE, OBJECT_TEMPLATE_ORG_OID);
    // Org
    importObjectFromFile(ORG_TOP_FILE, initResult);
    // Role
    importObjectFromFile(ROLE_META_ORG_FILE, initResult);
    // Tasks
    importObjectFromFile(TASK_LIVE_SYNC_DUMMY_HR_FILE, initResult);
}
Also used : DummyObjectClass(com.evolveum.icf.dummy.resource.DummyObjectClass) DebugReconciliationTaskResultListener(com.evolveum.midpoint.model.impl.util.DebugReconciliationTaskResultListener) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Example 5 with DummyObjectClass

use of com.evolveum.icf.dummy.resource.DummyObjectClass in project midpoint by Evolveum.

the class TestNullAttribute method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    // Resources
    //default instance, no instance id
    //when id is set it is required to be present in resource.xml (I guess)
    dummyResourceCtl = DummyResourceContoller.create(null, resourceDummy);
    DummyObjectClass dummyAdAccountObjectClass = dummyResourceCtl.getDummyResource().getAccountObjectClass();
    //attributes
    dummyResourceCtl.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME, String.class, false, false);
    dummyResourceCtl.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_SHIP, String.class, false, false);
    dummyResourceCtl.addAttrDef(dummyAdAccountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_WEAPON, String.class, false, false);
    dummyResource = dummyResourceCtl.getDummyResource();
    resourceDummy = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_FILE, RESOURCE_DUMMY_OID, initTask, initResult);
    dummyResourceCtl.setResource(resourceDummy);
    //		dummyResource.setSyncStyle(DummySyncStyle.SMART);
    //
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    // Object Templates
    importObjectFromFile(OBJECT_TEMPLATE_USER_FILE, initResult);
    setDefaultUserTemplate(OBJECT_TEMPLATE_USER_OID);
    // Role
    importObjectFromFile(ROLE_ACCOUNTONLY_FILE, initResult);
    importObjectFromFile(ROLE_SHIPNWEAPON_FILE, initResult);
    PrismObject<RoleType> rolesw = getRole(ROLE_SHIPNWEAPON_OID);
    display("role shipNWeapon initial", rolesw);
    //User
    importObjectFromFile(USER_SMACK_FILE, initResult);
}
Also used : DummyObjectClass(com.evolveum.icf.dummy.resource.DummyObjectClass) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Aggregations

DummyObjectClass (com.evolveum.icf.dummy.resource.DummyObjectClass)14 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 DebugReconciliationTaskResultListener (com.evolveum.midpoint.model.impl.util.DebugReconciliationTaskResultListener)2 FileNotFoundException (java.io.FileNotFoundException)2 ConnectException (java.net.ConnectException)2 ConnectionFailedException (org.identityconnectors.framework.common.exceptions.ConnectionFailedException)2 ConnectorIOException (org.identityconnectors.framework.common.exceptions.ConnectorIOException)2 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)1 DummyAttributeDefinition (com.evolveum.icf.dummy.resource.DummyAttributeDefinition)1 ObjectAlreadyExistsException (com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException)1 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)1 GuardedString (org.identityconnectors.common.security.GuardedString)1 AlreadyExistsException (org.identityconnectors.framework.common.exceptions.AlreadyExistsException)1 ConnectorException (org.identityconnectors.framework.common.exceptions.ConnectorException)1