use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method assignedRoles.
/**
* {@inheritDoc}
*/
@Override
public List<String> assignedRoles(String userId) throws SecurityException {
VUtil.assertNotNullOrEmpty(userId, GlobalErrIds.USER_NULL, CLS_NM + ".assignedRoles");
List<String> retUserRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setValue(userId);
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.getValues();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retUserRoles;
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class PwPolicyMgrRestImpl method add.
/**
* {@inheritDoc}
*/
@Override
public void add(PwPolicy policy) throws SecurityException {
VUtil.assertNotNull(policy, GlobalErrIds.PSWD_PLCY_NULL, CLS_NM + ".add");
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(policy);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PSWD_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class PwPolicyMgrRestImpl method deletePasswordPolicy.
/**
* {@inheritDoc}
*/
@Override
public void deletePasswordPolicy(String userId) throws SecurityException {
VUtil.assertNotNullOrEmpty(userId, GlobalErrIds.USER_NULL, CLS_NM + ".deletePasswordPolicy");
FortRequest request = RestUtils.getRequest(this.contextId);
request.setValue(userId);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PSWD_USER_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method assignedUsers.
/**
* {@inheritDoc}
*/
@Override
public List<String> assignedUsers(Role role, int limit) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".assignedUsers");
List<String> retUsers;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setLimit(limit);
request.setEntity(role);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retUsers = response.getValues();
// 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 ReviewMgrRestImpl method ssdRoleSetRoles.
/**
* {@inheritDoc}
*/
@Override
public Set<String> ssdRoleSetRoles(SDSet ssd) throws SecurityException {
VUtil.assertNotNull(ssd, GlobalErrIds.SSD_NULL, CLS_NM + ".ssdRoleSetRoles");
Set<String> retRoleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(ssd);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_ROLES);
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;
}
Aggregations