private DummyPrivilege convertToPriv(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException, ConflictException { String icfName = Utils.getMandatoryStringAttribute(createAttributes,Name.NAME); if (configuration.getUpCaseName()) { icfName = StringUtils.upperCase(icfName); } final DummyPrivilege newPriv = new DummyPrivilege(icfName); for (Attribute attr : createAttributes) { if (attr.is(Uid.NAME)) { throw new IllegalArgumentException("UID explicitly specified in the group attributes"); } else if (attr.is(Name.NAME)) { // Skip, already processed } else if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new InvalidAttributeValueException("Password specified for a privilege"); } else if (attr.is(OperationalAttributeInfos.ENABLE.getName())) { throw new InvalidAttributeValueException("Unsupported ENABLE attribute in privilege"); } else { String name = attr.getName(); try { newPriv.replaceAttributeValues(name,attr.getValue()); } catch (SchemaViolationException e) { throw new InvalidAttributeValueException(e.getMessage(),e); } catch (InterruptedException e) { throw new OperationTimeoutException(e.getMessage(),e); } } } return newPriv; }
protected DummyPrivilege getDummyPrivilegeAssert(String icfName, String icfUid) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { // if (isNameUnique()) { if (isIcfNameUidSame()) { return dummyResource.getPrivilegeByName(icfName); } else { DummyPrivilege priv = dummyResource.getPrivilegeById(icfUid); assertNotNull("No dummy privilege with ICF UID "+icfUid+" (expected name "+icfName+")", priv); assertEquals("Unexpected name in "+priv, icfName, priv.getName()); return priv; } }
String newName = (String)attr.getValue().get(0); try { resource.renamePrivilege(priv.getId(), priv.getName(), newName); } catch (ObjectDoesNotExistException e) { throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(e.getMessage(), e); String name = attr.getName(); try { priv.replaceAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { throw new InvalidAttributeValueException(e.getMessage(),e);
String name = attr.getName(); try { priv.removeAttributeValues(name, attr.getValue()); log.ok("Removed attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), priv, priv.getAttributeValues(name, Object.class)); } catch (SchemaViolationException e) {
String name = attr.getName(); try { priv.addAttributeValues(name, attr.getValue()); log.ok("Added attribute {0} values {1} from {2}, resulting values: {3}", name, attr.getValue(), priv, priv.getAttributeValues(name, Object.class)); } catch (SchemaViolationException e) {
@Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); initDummyResource(RESOURCE_DUMMY_PURPLE_NAME, RESOURCE_DUMMY_PURPLE_FILE, RESOURCE_DUMMY_PURPLE_OID, controller -> { controller.extendSchemaPirate(); controller.addAttrDef(controller.getDummyResource().getAccountObjectClass(), DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME, String.class, false, true); }, initTask, initResult); importObjectFromFile(ACCOUNT_JDOE_FILE); importObjectFromFile(ACCOUNT_CREW_FILE); importObjectFromFile(USER_JDOE_FILE); importObjectFromFile(ROLE_TEST_MATE_FILE); DummyAccount jdoe = new DummyAccount("jdoe"); jdoe.addAttributeValue("privileges", "test-mate"); getDummyResource(RESOURCE_DUMMY_PURPLE_NAME).addAccount(jdoe); DummyPrivilege crew = new DummyPrivilege("test-mate"); getDummyResource(RESOURCE_DUMMY_PURPLE_NAME).addPrivilege(crew); }
DummyPrivilege newPriv = convertToPriv(createAttributes); log.ok("Adding dummy privilege:\n{0}", newPriv.debugDump());
assertEquals("Wrong privilege power", (Integer)100, dummyPriv.getAttributeValue(DummyResourceContoller.DUMMY_PRIVILEGE_ATTRIBUTE_POWER, Integer.class));