public void changeDescriptionIfNeeded(DummyAccount account) throws SchemaViolationException, ConflictException { if (generateAccountDescriptionOnCreate) { try { account.replaceAttributeValue(DummyAccount.ATTR_DESCRIPTION_NAME, "Updated description of " + account.getName()); } catch (SchemaViolationException|ConnectException|FileNotFoundException|InterruptedException e) { throw new SystemException("Couldn't replace the 'description' attribute value", e); } } }
public String addAccount(DummyAccount newAccount) throws ObjectAlreadyExistsException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { if (generateAccountDescriptionOnCreate && newAccount.getAttributeValue(DummyAccount.ATTR_DESCRIPTION_NAME) == null) { newAccount.addAttributeValue(DummyAccount.ATTR_DESCRIPTION_NAME, "Description of " + newAccount.getName()); } return addObject(accounts, newAccount); }
protected void applyModifyMetadata(DummyObject object, OperationOptions options) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { String runAsUser = options.getRunAsUser(); if (runAsUser != null) { if (!configuration.getSupportRunAs()) { throw new UnsupportedOperationException("runAsUser option is not supported"); } DummyAccount runAsAccount = resource.getAccountByUsername(runAsUser); if (runAsAccount == null) { new ConfigurationException("No runAsUser "+runAsUser); } GuardedString runWithPassword = options.getRunWithPassword(); if (runWithPassword != null) { runWithPassword.access((clearChars) -> { if (!runAsAccount.getPassword().equals(new String(clearChars))) { throw new InvalidPasswordException("Wrong runWithPassword"); } }); } else { throw new InvalidPasswordException("No runWithPassword"); } object.setLastModifier(runAsAccount.getName()); } else { object.setLastModifier(null); } }
protected DummyAccount getDummyAccountAssert(String icfName, String icfUid) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { if (isIcfNameUidSame()) { return dummyResource.getAccountByUsername(icfName); } else { DummyAccount account = dummyResource.getAccountById(icfUid); assertNotNull("No dummy account with ICF UID "+icfUid+" (expected name "+icfName+")", account); assertEquals("Unexpected name in "+account, icfName, account.getName()); return account; } }
@Test public void test040AddAccount() throws Exception { final String TEST_NAME = "test040AddAccount"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition); ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME); // WHEN cc.addObject(shadow, null, null, result); // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); }
@Test public void test100AddAccount() throws Exception { final String TEST_NAME = "test100AddAccount"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition); ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME); // WHEN cc.addObject(shadow, null, null, result); // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); }
String newName = (String)attr.getValue().get(0); try { resource.renameAccount(account.getId(), account.getName(), newName); } catch (ObjectDoesNotExistException e) { throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(e.getMessage(), e);
String newName = getSingleReplaceValueMandatory(delta, String.class); try { resource.renameAccount(account.getId(), account.getName(), newName); } catch (ObjectDoesNotExistException e) { throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(e.getMessage(), e);
assertEquals("Username is wrong", ACCOUNT_WILL_USERNAME, dummyAccount.getName()); assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname")); assertTrue("The account is not enabled", dummyAccount.isEnabled());
assertEquals("Username is wrong", transformNameFromResource(ACCOUNT_WILL_USERNAME), dummyAccount.getName()); assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname")); assertTrue("The account is not enabled", dummyAccount.isEnabled());
assertEquals("Username is wrong", transformNameFromResource(ACCOUNT_WILL_USERNAME), dummyAccount.getName()); assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname")); assertTrue("The account is not enabled", dummyAccount.isEnabled());
assertEquals("Username is wrong", transformNameFromResource(ACCOUNT_WILL_USERNAME), dummyAccount.getName()); assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname")); assertTrue("The account is not enabled", dummyAccount.isEnabled());