use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupMgrConsole method assign.
void assign() {
try {
ReaderUtil.clearScreen();
System.out.println("Enter userId");
String userId = ReaderUtil.readLn();
System.out.println("Enter group name");
String name = ReaderUtil.readLn();
groupMgr.assign(new Group(name), userId);
System.out.println("Group assigned user");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("assign caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupMgrConsole method deleteProperty.
void deleteProperty() {
try {
Group group = new Group();
ReaderUtil.clearScreen();
System.out.println("Enter group name:");
group.setName(ReaderUtil.readLn());
System.out.println("Enter property key:");
String key = ReaderUtil.readLn();
System.out.println("Enter property value:");
String value = ReaderUtil.readLn();
groupMgr.delete(group, key, value);
System.out.println("Delete property from Group successful");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("deleteProperty caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class PropertyMgrImplTest method testCrudProperties.
public void testCrudProperties() {
Role role = RoleTestData.getRole(RoleTestData.ROLES_TR1[0]);
AdminRole adminRole = AdminRoleTestData.getRole(AdminRoleTestData.AROLES_TR1[0]);
PermObj permObj = PermTestData.getObj(PermTestData.OBJS_TOB1[0]);
Permission permOp = PermTestData.getOp(permObj.getObjName(), PermTestData.OPS_TOP1[0]);
Group group = GroupTestData.TEST_GROUP1;
addProperties("ADD-PROP-RLE", role, PROPS);
addProperties("ADD-PROP-ADMRLE", adminRole, PROPS);
addProperties("ADD-PROP-POBJ", permObj, PROPS);
addProperties("ADD-PROP-POP", permOp, PROPS);
addProperties("ADD-PROP-GRP", group, PROPS);
updateProperties("UPD-PROP-RLE", role, PROPS_UPDATED[0]);
updateProperties("UPD-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
updateProperties("UPD-PROP-POBJ", permObj, PROPS_UPDATED[0]);
updateProperties("UPD-PROP-POP", permOp, PROPS_UPDATED[0]);
updateProperties("UPD-PROP-POP", group, PROPS_UPDATED[0]);
deleteProperties("DEL-PROP-RLE", role, PROPS_UPDATED[0]);
deleteProperties("DEL-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
deleteProperties("DEL-PROP-POBJ", permObj, PROPS_UPDATED[0]);
deleteProperties("DEL-PROP-POP", permOp, PROPS_UPDATED[0]);
deleteProperties("DEL-PROP-POP", group, PROPS_UPDATED[0]);
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class FortressAntTask method deleteGroupProperties.
/**
* @throws BuildException An error occurred while building
*/
private void deleteGroupProperties() throws BuildException {
if (delgroupproperties == null) {
return;
}
// Loop through the entityclass elements
for (Delgroupproperty delgroupproperty : delgroupproperties) {
List<Group> groups = delgroupproperty.getGroups();
for (Group group : groups) {
if (PropUtil.isNotEmpty(group.getProperties())) {
for (Enumeration<?> e = group.getProperties().propertyNames(); e.hasMoreElements(); ) {
// This LDAP attr is stored as a name-value pair separated by a ':'.
String key = (String) e.nextElement();
String val = group.getProperties().getProperty(key);
try {
groupMgr.delete(group, key, val);
} catch (SecurityException se) {
LOG.warn("deleteGroupProperties tenant={} name [{}], key [{}], value [{}] caught SecurityException={}", getTenant(), group.getName(), key, val, se);
}
}
} else {
LOG.info("deleteGroupProperties tenant={} name={}, no properties found", getTenant(), group.getName());
}
}
}
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupAntTest method findGroups.
private void findGroups(String msg, List<Group> inGroups) {
LogUtil.logIt(msg);
try {
GroupMgr groupMgr = GroupMgrFactory.createInstance();
List<Group> outGroups = groupMgr.find(new Group("t"));
assertNotNull(outGroups);
assertTrue("findGroups result set wrong size", outGroups.size() == inGroups.size());
for (Group inGroupAnt : inGroups) {
Group inGroup = inGroupAnt;
int index = outGroups.indexOf(inGroup);
assertTrue("findGroups input data error ", index != -1);
Group outGroup = outGroups.get(index);
assertNotNull(outGroup);
assertEqual(inGroup, outGroup);
}
} catch (SecurityException ex) {
LOG.error("findGroups caught SecurityException=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations