Search in sources :

Example 6 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class AbstractIntegrationTest method assertShadowSecondaryIdentifier.

protected void assertShadowSecondaryIdentifier(PrismObject<ShadowType> shadow, String expectedIdentifier, ResourceType resourceType, MatchingRule<String> nameMatchingRule) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass());
    ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
    assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + expectedIdentifier, idProp);
    if (nameMatchingRule == null) {
        assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, expectedIdentifier, idProp.getRealValue());
    } else {
        PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue());
    }
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) Containerable(com.evolveum.midpoint.prism.Containerable) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 7 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class TestSanity method test016ProvisioningSearchAccountsIterative.

@Test
public void test016ProvisioningSearchAccountsIterative() throws Exception {
    TestUtil.displayTestTile("test016ProvisioningSearchAccountsIterative");
    // GIVEN
    OperationResult result = new OperationResult(TestSanity.class.getName() + ".test016ProvisioningSearchAccountsIterative");
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceTypeOpenDjrepo, prismContext);
    final RefinedObjectClassDefinition refinedAccountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    QName objectClass = refinedAccountDefinition.getObjectClassDefinition().getTypeName();
    ObjectQuery q = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceTypeOpenDjrepo.getOid(), objectClass, prismContext);
    //        ObjectQuery q = QueryConvertor.createObjectQuery(ResourceObjectShadowType.class, query, prismContext);
    final Collection<ObjectType> objects = new HashSet<ObjectType>();
    final MatchingRule caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
    ResultHandler handler = new ResultHandler<ObjectType>() {

        @Override
        public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) {
            ObjectType objectType = prismObject.asObjectable();
            objects.add(objectType);
            display("Found object", objectType);
            assertTrue(objectType instanceof ShadowType);
            ShadowType shadow = (ShadowType) objectType;
            assertNotNull(shadow.getOid());
            assertNotNull(shadow.getName());
            assertEquals(RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS, shadow.getObjectClass());
            assertEquals(RESOURCE_OPENDJ_OID, shadow.getResourceRef().getOid());
            String icfUid = getAttributeValue(shadow, getOpenDjPrimaryIdentifierQName());
            assertNotNull("No ICF UID", icfUid);
            String icfName = getNormalizedAttributeValue(shadow, refinedAccountDefinition, getOpenDjSecondaryIdentifierQName());
            assertNotNull("No ICF NAME", icfName);
            try {
                PrismAsserts.assertEquals("Wrong shadow name", caseIgnoreMatchingRule, shadow.getName().getOrig(), icfName);
            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
            assertNotNull("Missing LDAP uid", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "uid")));
            assertNotNull("Missing LDAP cn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "cn")));
            assertNotNull("Missing LDAP sn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "sn")));
            assertNotNull("Missing activation", shadow.getActivation());
            assertNotNull("Missing activation status", shadow.getActivation().getAdministrativeStatus());
            return true;
        }
    };
    // WHEN
    provisioningService.searchObjectsIterative(ShadowType.class, q, null, handler, null, result);
    // THEN
    display("Count", objects.size());
}
Also used : QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) StringIgnoreCaseMatchingRule(com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 8 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method getAttributeDefinition.

protected ResourceAttributeDefinition getAttributeDefinition(PrismObject<ResourceType> resource, QName attributeName) throws SchemaException {
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    if (refinedSchema == null) {
        throw new SchemaException("No refined schema for " + resource);
    }
    RefinedObjectClassDefinition accountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    return accountDefinition.findAttributeDefinition(attributeName);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 9 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createAccountShadowQuery.

protected ObjectQuery createAccountShadowQuery(String username, PrismObject<ResourceType> resource) throws SchemaException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
    RefinedObjectClassDefinition rAccount = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    Collection<? extends ResourceAttributeDefinition> identifierDefs = rAccount.getPrimaryIdentifiers();
    assert identifierDefs.size() == 1 : "Unexpected identifier set in " + resource + " refined schema: " + identifierDefs;
    ResourceAttributeDefinition identifierDef = identifierDefs.iterator().next();
    //TODO: set matching rule instead of null
    return QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(identifierDef, ShadowType.F_ATTRIBUTES, identifierDef.getName()).eq(username).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccount.getObjectClassDefinition().getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).build();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 10 with RefinedResourceSchema

use of com.evolveum.midpoint.common.refinery.RefinedResourceSchema in project midpoint by Evolveum.

the class AdUtils method assertAdSchema.

public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject<ResourceType> resource, QName accountObjectClass, PrismContext prismContext) throws SchemaException {
    ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext);
    display("Resource schema", resourceSchema);
    RefinedResourceSchema refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
    display("Refined schema", refinedSchema);
    ObjectClassComplexTypeDefinition accountObjectClassDefinition = refinedSchema.findObjectClassDefinition(accountObjectClass);
    assertNotNull("No definition for object class " + accountObjectClass, accountObjectClassDefinition);
    display("Account object class def", accountObjectClassDefinition);
    ResourceAttributeDefinition<String> cnDef = accountObjectClassDefinition.findAttributeDefinition("cn");
    PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, 1);
    assertTrue("cn read", cnDef.canRead());
    assertTrue("cn modify", cnDef.canModify());
    assertTrue("cn add", cnDef.canAdd());
    ResourceAttributeDefinition<String> samAccountNameDef = accountObjectClassDefinition.findAttributeDefinition(ATTRIBUTE_SAM_ACCOUNT_NAME_NAME);
    PrismAsserts.assertDefinition(samAccountNameDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME), DOMUtil.XSD_STRING, 0, 1);
    assertTrue("samAccountNameDef read", samAccountNameDef.canRead());
    assertTrue("samAccountNameDef modify", samAccountNameDef.canModify());
    assertTrue("samAccountNameDef add", samAccountNameDef.canAdd());
    ResourceAttributeDefinition<String> oDef = accountObjectClassDefinition.findAttributeDefinition("o");
    PrismAsserts.assertDefinition(oDef, new QName(MidPointConstants.NS_RI, "o"), DOMUtil.XSD_STRING, 0, -1);
    assertTrue("o read", oDef.canRead());
    assertTrue("o modify", oDef.canModify());
    assertTrue("o add", oDef.canAdd());
    ResourceAttributeDefinition<Long> createTimestampDef = accountObjectClassDefinition.findAttributeDefinition("createTimeStamp");
    PrismAsserts.assertDefinition(createTimestampDef, new QName(MidPointConstants.NS_RI, "createTimeStamp"), DOMUtil.XSD_LONG, 0, 1);
    assertTrue("createTimeStampDef read", createTimestampDef.canRead());
    assertFalse("createTimeStampDef modify", createTimestampDef.canModify());
    assertFalse("createTimeStampDef add", createTimestampDef.canAdd());
    ResourceAttributeDefinition<Long> isCriticalSystemObjectDef = accountObjectClassDefinition.findAttributeDefinition("isCriticalSystemObject");
    PrismAsserts.assertDefinition(isCriticalSystemObjectDef, new QName(MidPointConstants.NS_RI, "isCriticalSystemObject"), DOMUtil.XSD_BOOLEAN, 0, 1);
    assertTrue("isCriticalSystemObject read", isCriticalSystemObjectDef.canRead());
    assertTrue("isCriticalSystemObject modify", isCriticalSystemObjectDef.canModify());
    assertTrue("isCriticalSystemObject add", isCriticalSystemObjectDef.canAdd());
    ResourceAttributeDefinition<Long> nTSecurityDescriptorDef = accountObjectClassDefinition.findAttributeDefinition("nTSecurityDescriptor");
    PrismAsserts.assertDefinition(nTSecurityDescriptorDef, new QName(MidPointConstants.NS_RI, "nTSecurityDescriptor"), DOMUtil.XSD_BASE64BINARY, 0, 1);
    assertTrue("nTSecurityDescriptor read", nTSecurityDescriptorDef.canRead());
    assertTrue("nTSecurityDescriptor modify", nTSecurityDescriptorDef.canModify());
    assertTrue("nTSecurityDescriptor add", nTSecurityDescriptorDef.canAdd());
    ResourceAttributeDefinition<Long> lastLogonDef = accountObjectClassDefinition.findAttributeDefinition("lastLogon");
    PrismAsserts.assertDefinition(lastLogonDef, new QName(MidPointConstants.NS_RI, "lastLogon"), DOMUtil.XSD_LONG, 0, 1);
    assertTrue("lastLogonDef read", lastLogonDef.canRead());
    assertTrue("lastLogonDef modify", lastLogonDef.canModify());
    assertTrue("lastLogonDef add", lastLogonDef.canAdd());
    return accountObjectClassDefinition;
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Aggregations

RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 QName (javax.xml.namespace.QName)10 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)4 Test (org.testng.annotations.Test)4 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)3 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 Containerable (com.evolveum.midpoint.prism.Containerable)2 MatchingRule (com.evolveum.midpoint.prism.match.MatchingRule)2