use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupMgrRestImpl method roleGroups.
/**
* {@inheritDoc}
*/
@Override
public List<Group> roleGroups(Role role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".roleGroups");
List<Group> retGroups;
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.GROUP_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retGroups = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retGroups;
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupAntTest method testReadGroups.
@Test
public void testReadGroups() {
// gather role input data:
List<Addgroup> addgroups = fortressAntTask.getAddgroups();
for (Addgroup addgroup : addgroups) {
List<Group> groups = addgroup.getGroups();
readGroups("READ-GRPS", groups);
}
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupMgrImplTest method deassignUserMember.
private void deassignUserMember(String message, Group group, String[][] users) {
LogUtil.logIt(message);
try {
groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
for (String[] userArray : users) {
User user = UserTestData.getUser(userArray);
groupMgr.deassign(group, user.getUserId());
}
LOG.debug("deassignUserMember group [" + group.getName() + "] successful");
int countOfOldUsers = group.getMembers().size();
// read from LDAP and get count of members after deassignment
Group groupFromLdap = groupMgr.read(group);
int actualAmountOfMembers = groupFromLdap.getMembers().size();
assertEquals(CLS_NM + ".deassignUserMember failed members size check", countOfOldUsers, actualAmountOfMembers);
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("deassignUserMember: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupMgrImplTest method roleGroups.
private void roleGroups(String message, String[][] roles, List<Group> expectedGroups) {
LogUtil.logIt(message);
try {
groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
for (String[] roleArray : roles) {
Role role = RoleTestData.getRole(roleArray);
List<Group> actualGroups = groupMgr.roleGroups(role);
LOG.debug("roleGroups role [" + role.getName() + "] successful");
assertNotNull(actualGroups);
// The two list sizes better match or fail the test case.
assertTrue(CLS_NM + "roleGroups list size test case", actualGroups.size() == expectedGroups.size());
// For each actual group, check to see if it was in expected. If not fail the test case.
for (Group actualGroup : actualGroups) {
assertTrue(CLS_NM + ".roleGroups actual group name [" + actualGroup.getName() + "] not found", expectedGroups.contains(actualGroup));
// TODO : should compare members in expected groups to members in actual groups.
}
}
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("groupRoles: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Group in project directory-fortress-core by apache.
the class GroupMgrImplTest method assignUserMember.
private void assignUserMember(String message, Group group, String[][] users) {
LogUtil.logIt(message);
try {
groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
for (String[] userArray : users) {
User user = UserTestData.getUser(userArray);
groupMgr.assign(group, user.getUserId());
}
LOG.debug("assignUserMember group [" + group.getName() + "] successful");
int countOfOldUsers = group.getMembers().size();
int countOfNewUsers = users.length;
// read from LDAP and get count of members
Group groupFromLdap = groupMgr.read(group);
int actualAmountOfMembers = groupFromLdap.getMembers().size();
assertEquals(CLS_NM + ".assignUserMember failed members size check", countOfOldUsers + countOfNewUsers, actualAmountOfMembers);
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("assignUserMember: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations