예제 #1
0
  @Test
  public void test500FetchObject() throws Exception {
    final String TEST_NAME = "test500FetchObject";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    ResourceAttributeContainer resourceObject =
        createResourceObject("uid=Teell,ou=People,dc=example,dc=com", "Teell William", "Teell");

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

    PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject);
    // Add a testing object
    cc.addObject(shadow, null, addResult);

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceObject.getDefinition().getComplexTypeDefinition();

    Collection<ResourceAttribute<?>> identifiers = resourceObject.getIdentifiers();
    // Determine object class from the schema

    ResourceObjectIdentification identification =
        new ResourceObjectIdentification(accountDefinition, identifiers);
    OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);

    // WHEN
    PrismObject<ShadowType> ro = cc.fetchObject(ShadowType.class, identification, null, result);

    // THEN

    AssertJUnit.assertNotNull(ro);
    System.out.println("Fetched object " + ro);
    System.out.println("Result:");
    System.out.println(result.debugDump());
  }
예제 #2
0
  @Test
  public void test610ChangePassword() throws Exception {
    final String TEST_NAME = "test610ChangePassword";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    ResourceAttributeContainer resourceObject =
        createResourceObject("uid=drake,ou=People,dc=example,dc=com", "Sir Francis Drake", "Drake");
    PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject);

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

    // Add a testing object
    cc.addObject(shadow, null, addResult);

    String entryUuid = (String) resourceObject.getIdentifier().getValue().getValue();
    SearchResultEntry entry = openDJController.searchAndAssertByEntryUuid(entryUuid);
    display("Entry before change", entry);
    String passwordBefore = OpenDJController.getAttributeValue(entry, "userPassword");
    // We have set no password during create, therefore the password should
    // be empty
    assertNull(passwordBefore);

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceObject.getDefinition().getComplexTypeDefinition();

    Collection<ResourceAttribute<?>> identifiers = resourceObject.getIdentifiers();
    // Determine object class from the schema

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

    // WHEN

    Set<Operation> changes = new HashSet<Operation>();
    ProtectedStringType passPs = protector.encryptString("salalala");

    ItemDeltaType propMod = new ItemDeltaType();
    // create modification path
    Document doc = DOMUtil.getDocument();
    ItemPathType path = new ItemPathType("credentials/password/value");
    //		PropertyPath propPath = new PropertyPath(new
    // PropertyPath(ResourceObjectShadowType.F_CREDENTIALS), CredentialsType.F_PASSWORD);
    propMod.setPath(path);

    // set the replace value
    MapXNode passPsXnode = prismContext.getBeanConverter().marshalProtectedDataType(passPs);
    RawType value = new RawType(passPsXnode, prismContext);
    propMod.getValue().add(value);

    // set the modificaion type
    propMod.setModificationType(ModificationTypeType.REPLACE);

    PropertyDelta passDelta =
        (PropertyDelta) DeltaConvertor.createItemDelta(propMod, shadow.getDefinition());
    PropertyModificationOperation passwordModification =
        new PropertyModificationOperation(passDelta);
    changes.add(passwordModification);

    //		PasswordChangeOperation passwordChange = new PasswordChangeOperation(passPs);
    //		changes.add(passwordChange);
    cc.modifyObject(accountDefinition, identifiers, changes, result);

    // THEN

    entry = openDJController.searchAndAssertByEntryUuid(entryUuid);
    display("Entry after change", entry);

    String passwordAfter = OpenDJController.getAttributeValue(entry, "userPassword");
    assertNotNull(passwordAfter);

    System.out.println("Account password: " + passwordAfter);
  }