use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class DelegatedAdminMgrConsole method grantPermission.
protected void grantPermission(boolean isRole) {
try {
ReaderUtil.clearScreen();
System.out.println("Enter perm object");
String object = ReaderUtil.readLn();
System.out.println("Enter perm operation");
String operation = ReaderUtil.readLn();
Permission pOp = new Permission(object, operation);
pOp.setAdmin(true);
String name;
if (isRole) {
System.out.println("Enter role name");
name = ReaderUtil.readLn();
aMgr.grantPermission(pOp, new Role(name));
} else {
System.out.println("Enter userId");
name = ReaderUtil.readLn();
aMgr.grantPermission(pOp, new User(name));
}
System.out.println("perm object [" + object + "] operation [" + operation + "] has been granted to [" + name + "]");
System.out.println("has been granted");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("grantPermission caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class DelegatedAdminMgrConsole method revokePermission.
protected void revokePermission(boolean isRole) {
try {
ReaderUtil.clearScreen();
System.out.println("Enter perm object");
String object = ReaderUtil.readLn();
System.out.println("Enter perm operation");
String operation = ReaderUtil.readLn();
Permission pOp = new Permission(object, operation);
pOp.setAdmin(true);
String name;
if (isRole) {
System.out.println("Enter role name");
name = ReaderUtil.readLn();
aMgr.revokePermission(pOp, new Role(name));
} else {
System.out.println("Enter userId");
name = ReaderUtil.readLn();
aMgr.revokePermission(pOp, new User(name));
}
System.out.println("perm object [" + object + "] operation [" + operation + "] has been granted to [" + name + "]");
System.out.println("has been revoked.");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("revokePermission caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Role 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.Role in project directory-fortress-core by apache.
the class ReviewMgrConsole method findRoles.
void findRoles() {
ReaderUtil.clearScreen();
try {
System.out.println("");
System.out.println("Enter value to search Roles with:");
String val = ReaderUtil.readLn();
List<Role> list = rm.findRoles(val);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Role re = list.get(i);
System.out.println("ROLE OBJECT [" + i + "]:");
System.out.println(" name [" + re.getName() + "]");
System.out.println(" internalId [" + re.getId() + "]");
System.out.println(" description [" + re.getDescription() + "]");
System.out.println(" parents [" + re.getParents() + "]");
printTemporal(re, "RBACROLE");
}
} else {
System.out.println("name [" + val + "] was not found");
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("findRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class ReviewMgrConsole method readRole.
/**
*/
void readRole() {
ReaderUtil.clearScreen();
try {
System.out.println("Enter Role name to read:");
Role role = new Role();
role.setName(ReaderUtil.readLn());
Role re = rm.readRole(role);
if (re != null) {
System.out.println("ROLE OBJECT:");
System.out.println(" name [" + re.getName() + "]");
System.out.println(" internalId [" + re.getId() + "]");
System.out.println(" description [" + re.getDescription() + "]");
System.out.println(" parents [" + re.getParents() + "]");
printTemporal(re, "RBACROLE");
} else {
System.out.println(" name [" + role.getName() + "] was not found");
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("readRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations