use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelReviewMgrRestImpl method readRole.
/**
* {@inheritDoc}
*/
@Override
public AdminRole readRole(AdminRole role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".readRole");
AdminRole retRole;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(role);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRole = (AdminRole) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRole;
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelReviewMgrRestImpl method findRoles.
/**
* {@inheritDoc}
*/
@Override
public List<AdminRole> findRoles(String searchVal) throws SecurityException {
VUtil.assertNotNull(searchVal, GlobalErrIds.ARLE_NM_NULL, CLS_NM + ".findRoles");
List<AdminRole> retRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setValue(searchVal);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRoles = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRoles;
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class AdminRoleTestData method getRole.
public static AdminRole getRole(String[] rle) {
AdminRole role = (AdminRole) getRoleConstraint(rle);
role.setName(RoleTestData.getName(rle));
role.setDescription(RoleTestData.getDescription(rle));
role.setOsUSet(getOsUSet(rle));
role.setOsPSet(getOsPSet(rle));
role.setBeginRange(getBeginRange(rle));
role.setEndRange(getEndRange(rle));
role.setBeginInclusive(isBeginInclusive(rle));
role.setEndInclusive(isEndInclusive(rle));
return role;
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addInheritedAdminRoles.
/**
* @param msg
* @param rArray
*/
public static void addInheritedAdminRoles(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole role = AdminRoleTestData.getRole(rle);
Set<String> parents = RoleTestData.getRelationships(rle);
if (parents != null) {
for (String pRole : parents) {
dAdminMgr.addInheritance(new AdminRole(pRole), role);
LOG.debug("addInheritedAdminRoles child role [" + role.getName() + "] parent role [" + pRole + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addInheritedAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.AdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method addAdminRoleAscendant.
/**
* @param msg
* @param rArray
*/
public static void addAdminRoleAscendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
if (RoleTestData.isCreate(rle)) {
dAdminMgr.addRole(adminRole);
LOG.debug("addAdminRoleAscendant add adminRole [" + adminRole.getName() + "] successful");
}
Set<String> ascs = RoleTestData.getRelationships(rle);
if (ascs != null) {
for (String asc : ascs) {
dAdminMgr.addAscendant(adminRole, new AdminRole(asc));
LOG.debug("addAdminRoleAscendant desc role [" + adminRole.getName() + "] asc role [" + asc + "] successful");
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String asc : inheritances) {
dAdminMgr.addInheritance(new AdminRole(asc), adminRole);
LOG.debug("addAdminRoleAscendant desc role [" + adminRole.getName() + "] asc role [" + asc + "] successful");
}
}
}
} catch (SecurityException ex) {
LOG.error("addAdminRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations