Exemplo n.º 1
0
  private ResourceAttributeContainer createResourceObject(String dn, String sn, String cn)
      throws SchemaException {
    // Account type is hardcoded now
    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass"));
    // Determine identifier from the schema
    ResourceAttributeContainer resourceObject =
        accountDefinition.instantiate(ShadowType.F_ATTRIBUTES);

    ResourceAttributeDefinition road =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn"));
    ResourceAttribute roa = road.instantiate();
    roa.setValue(new PrismPropertyValue(sn));
    resourceObject.add(roa);

    road =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn"));
    roa = road.instantiate();
    roa.setValue(new PrismPropertyValue(cn));
    resourceObject.add(roa);

    road = accountDefinition.findAttributeDefinition(ConnectorFactoryIcfImpl.ICFS_NAME);
    roa = road.instantiate();
    roa.setValue(new PrismPropertyValue(dn));
    resourceObject.add(roa);

    return resourceObject;
  }
Exemplo n.º 2
0
  @Test
  public void test100AddDeleteObject() throws Exception {
    final String TEST_NAME = "test100AddDeleteObject";
    TestUtil.displayTestTile(this, TEST_NAME);

    OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);

    Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith");

    String uid = null;
    for (ResourceAttribute<?> resourceAttribute : identifiers) {
      if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) {
        uid = resourceAttribute.getValue(String.class).getValue();
        System.out.println("uuuuid:" + uid);
        assertNotNull(uid);
      }
    }

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME);

    cc.deleteObject(accountDefinition, null, identifiers, result);

    ResourceObjectIdentification identification =
        new ResourceObjectIdentification(accountDefinition, identifiers);
    PrismObject<ShadowType> resObj = null;
    try {
      resObj = cc.fetchObject(ShadowType.class, identification, null, result);
      Assert.fail();
    } catch (ObjectNotFoundException ex) {
      AssertJUnit.assertNull(resObj);
    }
  }
Exemplo n.º 3
0
  @Test
  public void testAddDeleteObject() throws Exception {
    TestUtil.displayTestTile(this, "testDeleteObject");

    OperationResult result = new OperationResult(this.getClass().getName() + ".testDelete");

    Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith");

    String uid = null;
    for (ResourceAttribute<?> resourceAttribute : identifiers) {
      if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) {
        uid = resourceAttribute.getValue(String.class).getValue();
        System.out.println("uuuuid:" + uid);
        assertNotNull(uid);
      }
    }

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);

    cc.deleteObject(accountDefinition, null, identifiers, result);

    PrismObject<ShadowType> resObj = null;
    try {
      resObj = cc.fetchObject(ShadowType.class, accountDefinition, identifiers, null, result);
      Assert.fail();
    } catch (ObjectNotFoundException ex) {
      AssertJUnit.assertNull(resObj);
    }
  }
Exemplo n.º 4
0
 private String getEntryUuid(Collection<ResourceAttribute<?>> identifiers) {
   for (ResourceAttribute<?> identifier : identifiers) {
     if (identifier.getElementName().equals(ConnectorFactoryIcfImpl.ICFS_UID)) {
       return identifier.getValue(String.class).getValue();
     }
   }
   return null;
 }
Exemplo n.º 5
0
 private PrismProperty createProperty(String propertyName, String propertyValue) {
   ObjectClassComplexTypeDefinition accountDefinition =
       resourceSchema.findObjectClassDefinition(
           new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass"));
   ResourceAttributeDefinition propertyDef =
       accountDefinition.findAttributeDefinition(
           new QName(ResourceTypeUtil.getResourceNamespace(resourceType), propertyName));
   ResourceAttribute property = propertyDef.instantiate();
   property.setValue(new PrismPropertyValue(propertyValue));
   return property;
 }
Exemplo n.º 6
0
  private Collection<ResourceAttribute<?>> addSampleResourceObject(
      String name, String givenName, String familyName)
      throws CommunicationException, GenericFrameworkException, SchemaException,
          ObjectAlreadyExistsException, ConfigurationException {
    OperationResult result = new OperationResult(this.getClass().getName() + ".testAdd");

    QName objectClassQname =
        new QName(
            ResourceTypeUtil.getResourceNamespace(resourceType),
            ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME);
    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(objectClassQname);
    assertNotNull("No object class definition " + objectClassQname, accountDefinition);
    ResourceAttributeContainer resourceObject =
        accountDefinition.instantiate(ShadowType.F_ATTRIBUTES);

    ResourceAttributeDefinition<String> attributeDefinition =
        accountDefinition.findAttributeDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME));
    ResourceAttribute<String> attribute = attributeDefinition.instantiate();
    attribute.setValue(
        new PrismPropertyValue<String>("uid=" + name + ",ou=people,dc=example,dc=com"));
    resourceObject.add(attribute);

    attributeDefinition =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn"));
    attribute = attributeDefinition.instantiate();
    attribute.setValue(new PrismPropertyValue(familyName));
    resourceObject.add(attribute);

    attributeDefinition =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn"));
    attribute = attributeDefinition.instantiate();
    attribute.setValue(new PrismPropertyValue(givenName + " " + familyName));
    resourceObject.add(attribute);

    attributeDefinition =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName"));
    attribute = attributeDefinition.instantiate();
    attribute.setValue(new PrismPropertyValue(givenName));
    resourceObject.add(attribute);

    PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject);

    Set<Operation> operation = new HashSet<Operation>();
    Collection<ResourceAttribute<?>> resourceAttributes = cc.addObject(shadow, operation, result);
    return resourceAttributes;
  }
Exemplo n.º 7
0
 private PrismProperty createProperty(String propertyName, String propertyValue) {
   ObjectClassComplexTypeDefinition accountDefinition =
       resourceSchema.findObjectClassDefinition(
           new QName(
               ResourceTypeUtil.getResourceNamespace(resourceType),
               ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME));
   ResourceAttributeDefinition propertyDef =
       accountDefinition.findAttributeDefinition(
           new QName(ResourceTypeUtil.getResourceNamespace(resourceType), propertyName));
   ResourceAttribute property = propertyDef.instantiate();
   property.setValue(new PrismPropertyValue(propertyValue));
   return property;
 }
Exemplo n.º 8
0
 private String getEntryUuid(Collection<ResourceAttribute<?>> identifiers) {
   for (ResourceAttribute<?> identifier : identifiers) {
     if (identifier
         .getElementName()
         .equals(
             new QName(
                 ResourceTypeUtil.getResourceNamespace(resourceType),
                 ProvisioningTestUtil.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME))) {
       return identifier.getValue(String.class).getValue();
     }
   }
   return null;
 }
Exemplo n.º 9
0
  private ResourceAttributeContainer createResourceObject(String dn, String sn, String cn)
      throws SchemaException {
    // Account type is hardcoded now
    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME));
    // Determine identifier from the schema
    ResourceAttributeContainer resourceObject =
        accountDefinition.instantiate(ShadowType.F_ATTRIBUTES);

    ResourceAttributeDefinition road =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn"));
    ResourceAttribute roa = road.instantiate();
    roa.setValue(new PrismPropertyValue(sn));
    resourceObject.add(roa);

    road =
        accountDefinition.findAttributeDefinition(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn"));
    roa = road.instantiate();
    roa.setValue(new PrismPropertyValue(cn));
    resourceObject.add(roa);

    road =
        accountDefinition.findAttributeDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME));
    roa = road.instantiate();
    roa.setValue(new PrismPropertyValue(dn));
    resourceObject.add(roa);

    return resourceObject;
  }