use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class DelReviewMgrRestImpl method assignedUsers.
/**
* {@inheritDoc}
*/
@Override
public List<User> assignedUsers(AdminRole role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".assignedUsers");
List<User> retUsers;
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.USER_ASGNED_ADMIN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retUsers = response.getEntities();
// do not return a null list to the caller:
if (retUsers == null) {
retUsers = new ArrayList<>();
}
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retUsers;
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class GroupMgrRestImpl method read.
/**
* {@inheritDoc}
*/
@Override
public Group read(Group group) throws SecurityException {
VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".read");
Group retGroup;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(group);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.GROUP_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retGroup = (Group) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retGroup;
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class GroupMgrRestImpl method add.
/**
* {@inheritDoc}
*/
@Override
public Group add(Group group) throws SecurityException {
VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".add");
Group retGroup;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(group);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.GROUP_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retGroup = (Group) response.getEntity();
} else {
throw new org.apache.directory.fortress.core.SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retGroup;
}
use of org.apache.directory.fortress.core.model.FortResponse 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.FortResponse in project directory-fortress-core by apache.
the class AdminMgrRestImpl method addInheritance.
/**
* {@inheritDoc}
*/
@Override
public void addInheritance(Role parentRole, Role childRole) throws SecurityException {
VUtil.assertNotNull(parentRole, GlobalErrIds.PARENT_ROLE_NULL, CLS_NM + ".addInheritance");
VUtil.assertNotNull(childRole, GlobalErrIds.CHILD_ROLE_NULL, CLS_NM + ".addInheritance");
FortRequest request = RestUtils.getRequest(this.contextId);
RoleRelationship relationship = new RoleRelationship();
relationship.setParent(parentRole);
relationship.setChild(childRole);
request.setEntity(relationship);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_ADDINHERIT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
Aggregations