use of org.apache.directory.fortress.core.model.Permission 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.Permission in project directory-fortress-core by apache.
the class PermTestData method getOp.
/**
* @param objName
* @param op
* @return
*/
public static Permission getOp(String objName, String[] op) {
Permission pOp = new Permission();
pOp.setObjName(objName);
pOp.setObjId(getObjId(op));
pOp.setOpName(getName(op));
pOp.setDescription(getDescription(op));
// pOp.setAbstractName(pOp.getObjName() + "." + pOp.getOpName());
pOp.setType(getType(op));
pOp.setAdmin(isOpAdmin(op));
return pOp;
}
use of org.apache.directory.fortress.core.model.Permission 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.Permission in project directory-fortress-core by apache.
the class ReviewMgrConsole method readPermission.
/**
* Description of the Method
*
*@param pmap Description of the Parameter
*/
/* private final void prettyPrintFinePermissions(Map pmap)
{
if (pmap != null)
{
Set pset = pmap.keySet();
Iterator piter = pset.iterator();
while (piter.hasNext())
{
FinePerm perm = (FinePerm) pmap.get(piter.next());
System.out.println("Fine Perm objectname:" + perm.getObjName());
if (perm.getRoles() != null && perm.getRoles().size() > 0)
{
List roles = perm.getRoles();
for (int i = 0; i < roles.size(); i++)
{
String name = (String) roles.get(i);
System.out.println("Fine Perm name: " + name);
}
}
if (perm.getUsers() != null && perm.getUsers().size() > 0)
{
List users = perm.getUsers();
for (int i = 0; i < users.size(); i++)
{
String user = (String) users.get(i);
System.out.println("Fine Perm user: " + user);
}
}
if (perm.getGroups() != null && perm.getGroups().size() > 0)
{
List groups = perm.getGroups();
for (int i = 0; i < groups.size(); i++)
{
String group = (String) groups.get(i);
System.out.println("Fine Perm group: " + group);
}
}
}
}
}
*/
/**
* Description of the Method
*/
void readPermission() {
Permission pe;
try {
Permission permission = new Permission();
ReaderUtil.clearScreen();
System.out.println("Enter perm object name:");
String name = ReaderUtil.readLn();
permission.setObjName(name);
System.out.println("Enter perm object id or null for none:");
String oid = ReaderUtil.readLn();
permission.setObjId(oid);
System.out.println("Enter perm operation name:");
String op = ReaderUtil.readLn();
permission.setOpName(op);
pe = rm.readPermission(permission);
if (pe != null) {
// System.out.println("perm operation [" + pe.operation + "]");
System.out.println("object name [" + pe.getObjName() + "]");
System.out.println("object id [" + pe.getObjId() + "]");
System.out.println("operation name [" + pe.getOpName() + "]");
System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
System.out.println("internalId [" + pe.getInternalId() + "]");
if (pe.getUsers() != null && pe.getUsers().size() > 0) {
int ctr = 0;
for (String user : pe.getUsers()) {
System.out.println("user[" + ctr++ + "]=" + user);
}
}
if (pe.getRoles() != null && pe.getRoles().size() > 0) {
int ctr = 0;
for (String role : pe.getRoles()) {
System.out.println("name[" + ctr++ + "]=" + role);
}
}
if (pe.getProperties() != null && pe.getProperties().size() > 0) {
int ctr = 0;
for (Enumeration e = pe.getProperties().propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = pe.getProperty(key);
System.out.println("prop key[" + ctr + "]=" + key);
System.out.println("prop value[" + ctr++ + "]=" + val);
}
}
System.out.println("**");
System.out.println("read operation complete");
System.out.println("ENTER to continue");
}
} catch (SecurityException e) {
LOG.error("readPermission caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrConsole method permissionUsers.
void permissionUsers() {
Permission pe;
try {
Permission permission = new Permission();
ReaderUtil.clearScreen();
System.out.println("Enter perm object name:");
String name = ReaderUtil.readLn();
permission.setObjName(name);
System.out.println("Enter perm object id or null for none:");
String oid = ReaderUtil.readLn();
permission.setObjId(oid);
System.out.println("Enter perm operation name:");
String op = ReaderUtil.readLn();
permission.setOpName(op);
pe = rm.readPermission(permission);
if (pe != null) {
// System.out.println("perm operation [" + pe.operation + "]");
System.out.println("object name [" + pe.getObjName() + "]");
System.out.println("object id [" + pe.getObjId() + "]");
System.out.println("operation name [" + pe.getOpName() + "]");
System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
System.out.println("internalId [" + pe.getInternalId() + "]");
if (pe.getUsers() != null && pe.getUsers().size() > 0) {
int ctr = 0;
for (String user : pe.getUsers()) {
System.out.println("user[" + ctr++ + "]=" + user);
}
}
System.out.println("**");
System.out.println("read operation complete");
System.out.println("ENTER to continue");
}
} catch (SecurityException e) {
LOG.error("permissionUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations