use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrImplTest method addRoleGrants.
/**
* @param rArray
* @param objArray
* @param opArray
*/
public static void addRoleGrants(String msg, String[][] rArray, String[][] objArray, String[][] opArray, boolean isAdmin, boolean canFail) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
Role role = new Role();
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] rle : rArray) {
for (String[] obj : objArray) {
for (String[] op : opArray) {
role = new Role(RoleTestData.getName(rle));
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.grantPermission(pOp, role);
LOG.debug("addRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
}
} catch (SecurityException ex) {
if (!canFail) {
LOG.error("addRoleGrants role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrImplTest method delRoleGrantsH.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
private void delRoleGrantsH(String msg, String[][] rArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
Role role = new Role();
try {
AdminMgr adminMgr = getManagedAdminMgr();
int i = 0;
for (String[] obj : objArray) {
role = new Role(RoleTestData.getName(rArray[i++]));
for (String[] op : opArray) {
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.revokePermission(pOp, role);
LOG.debug("delRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("delRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrImplTest method addPermOps.
/**
* @param objArray
* @param opArray
*/
public static void addPermOps(String msg, String[][] objArray, String[][] opArray, boolean isAdmin, boolean canFail) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] obj : objArray) {
for (String[] op : opArray) {
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.addPermission(pOp);
LOG.debug("addPermOp objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] successful");
}
}
} catch (SecurityException ex) {
if (!canFail) {
LOG.error("addPermOp objName [" + pOp.getObjName() + "] opName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrImplTest method addRoleGrantsH.
/**
* @param msg
* @param rArray
* @param objArray
* @param opArray
*/
public static void addRoleGrantsH(String msg, String[][] rArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
Role role = new Role();
try {
AdminMgr adminMgr = getManagedAdminMgr();
int i = 0;
for (String[] obj : objArray) {
role = new Role(RoleTestData.getName(rArray[i++]));
for (String[] op : opArray) {
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.grantPermission(pOp, role);
LOG.debug("addRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
} catch (SecurityException ex) {
LOG.error("addRoleGrantsH role name [" + role.getName() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrImplTest method addUserGrants.
/**
* @param uArray
* @param objArray
* @param opArray
*/
public static void addUserGrants(String msg, String[][] uArray, String[][] objArray, String[][] opArray) {
LogUtil.logIt(msg);
Permission pOp = new Permission();
User user = new User();
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] usr : uArray) {
for (String[] obj : objArray) {
for (String[] op : opArray) {
user = new User(UserTestData.getUserId(usr));
pOp = PermTestData.getOp(PermTestData.getName(obj), op);
adminMgr.grantPermission(pOp, user);
LOG.debug("addUserGrants userId [" + user.getUserId() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addUserGrants userId [" + user.getUserId() + "] objName [" + pOp.getObjName() + "] objectId [" + pOp.getObjId() + "] operation name [" + pOp.getOpName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations