use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deassignAdminUserRole.
void deassignAdminUserRole(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rArray[i]).getName());
dAdminMgr.deassignUser(uAdminRole);
i++;
}
} catch (SecurityException ex) {
LOG.error("deassignAdminUserRole caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deassignAdminUsers.
/**
* @param msg
* @param uArray
* @param rArray
*/
void deassignAdminUsers(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
DelReviewMgr dReviewMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
dReviewMgr = getManagedDelegatedReviewMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
i++;
for (String[] rle : rArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rle).getName());
AdminRoleTestData.getRole(rle);
dAdminMgr.deassignUser(uAdminRole);
LOG.debug("deassignAdminUsers user [" + uAdminRole.getUserId() + "] role [" + uAdminRole.getName() + "] successful");
// Let's double check the number of users associated with role:
List<User> users = dReviewMgr.assignedUsers(AdminRoleTestData.getRole(rle));
assertNotNull(users);
// If this is the last user deassigned from role, both lists will be returned empty:
if (i == uArray.length) {
assertTrue(users.size() == 0);
} else {
assertTrue(CLS_NM + "deassignAdminUsers list size check", (rArray.length - i) == users.size());
}
}
}
} catch (SecurityException ex) {
LOG.error("deassignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method assignAdminUserRole.
public static void assignAdminUserRole(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rArray[i]).getName());
dAdminMgr.assignUser(uAdminRole);
i++;
}
} catch (SecurityException ex) {
LOG.error("assignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class DelAccessMgrRestImpl method sessionAdminRoles.
/**
* {@inheritDoc}
*/
@Override
public List<UserAdminRole> sessionAdminRoles(Session session) throws SecurityException {
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, CLS_NM + ".sessionAdminRoles");
List<UserAdminRole> roles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setSession(session);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ROLES);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
roles = response.getEntities();
Session outSession = response.getSession();
session.copy(outSession);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return roles;
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class ReviewMgrConsole method displayUsers.
/**
* Description of the Method
*/
protected void displayUsers() {
try {
User ue;
ArrayList list = (ArrayList) rm.findUsers(new User());
int size = list.size();
for (int i = 0; i < size; i++) {
ue = (User) list.get(i);
System.out.println("USER[" + i + "]");
System.out.println(" userId [" + ue.getUserId() + "]");
System.out.println(" internalId [" + ue.getInternalId() + "]");
System.out.println(" description [" + ue.getDescription() + "]");
System.out.println(" common name [" + ue.getCn() + "]");
System.out.println(" surname [" + ue.getSn() + "]");
System.out.println(" orgUnitId [" + ue.getOu() + "]");
System.out.println(" pwpolicy [" + ue.getPwPolicy() + "]");
printTemporal(ue, "USER");
printPosixAccount(ue, "POSIX");
printAddress(ue.getAddress(), "ADDRESS");
printPhone(ue.getPhones(), "PHONES");
printPhone(ue.getMobiles(), "MOBILES");
if (ue.getRoles() != null) {
for (UserRole ur : ue.getRoles()) {
printTemporal(ur, "RBACROLE");
}
}
if (ue.getAdminRoles() != null) {
for (UserAdminRole ur : ue.getAdminRoles()) {
printAdminRole(ur);
printTemporal(ur, "ADMINROLE");
}
}
System.out.println();
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("displayUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations