use of org.apache.directory.fortress.core.model.FortRequest in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method readPermObj.
/**
* {@inheritDoc}
*/
@Override
public PermObj readPermObj(PermObj permObj) throws SecurityException {
VUtil.assertNotNull(permObj, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".readPermObj");
PermObj retObj;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(permObj);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retObj = (PermObj) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retObj;
}
use of org.apache.directory.fortress.core.model.FortRequest in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method assignedRoles.
/**
* {@inheritDoc}
*/
@Override
public List<UserRole> assignedRoles(User user) throws SecurityException {
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".assignedRoles");
List<UserRole> retUserRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(user);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retUserRoles = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retUserRoles;
}
use of org.apache.directory.fortress.core.model.FortRequest in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method authorizedRoles.
/**
* {@inheritDoc}
*/
@Override
public Set<String> authorizedRoles(User user) throws SecurityException {
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".authorizedRoles");
Set<String> retRoleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(user);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_AUTHZED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
Set<String> tempNames = response.getValueSet();
// This is done to use a case insensitive TreeSet for returned names.
retRoleNames.addAll(tempNames);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRoleNames;
}
use of org.apache.directory.fortress.core.model.FortRequest in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method findRoles.
/**
* {@inheritDoc}
*/
@Override
public List<String> findRoles(String searchVal, int limit) throws SecurityException {
VUtil.assertNotNull(searchVal, GlobalErrIds.ROLE_NM_NULL, CLS_NM + ".findRoles");
List<String> retRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setValue(searchVal);
request.setLimit(limit);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRoles = response.getValues();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRoles;
}
use of org.apache.directory.fortress.core.model.FortRequest in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method ssdRoleSets.
/**
* {@inheritDoc}
*/
@Override
public List<SDSet> ssdRoleSets(Role role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".ssdRoleSets");
List<SDSet> retSsdRoleSets;
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.SSD_ROLE_SETS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSsdRoleSets = response.getEntities();
if (retSsdRoleSets == null) {
retSsdRoleSets = new ArrayList<>();
}
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSsdRoleSets;
}
Aggregations