use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrRestImpl method setSsdSetCardinality.
/**
* {@inheritDoc}
*/
@Override
public SDSet setSsdSetCardinality(SDSet ssdSet, int cardinality) throws SecurityException {
VUtil.assertNotNull(ssdSet, GlobalErrIds.SSD_NULL, CLS_NM + ".setSsdSetCardinality");
SDSet retSet;
FortRequest request = RestUtils.getRequest(this.contextId);
ssdSet.setCardinality(cardinality);
request.setEntity(ssdSet);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_CARD_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (SDSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrRestImpl method addSsdRoleMember.
/**
* {@inheritDoc}
*/
@Override
public SDSet addSsdRoleMember(SDSet ssdSet, Role role) throws SecurityException {
VUtil.assertNotNull(ssdSet, GlobalErrIds.SSD_NULL, CLS_NM + ".addSsdRoleMember");
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".addSsdRoleMember");
SDSet retSet;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(ssdSet);
request.setValue(role.getName());
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_ADD_MEMBER);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (SDSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrRestImpl method deleteSsdSet.
/**
* {@inheritDoc}
*/
@Override
public SDSet deleteSsdSet(SDSet ssdSet) throws SecurityException {
VUtil.assertNotNull(ssdSet, GlobalErrIds.SSD_NULL, CLS_NM + ".deleteSsdSet");
SDSet retSet;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(ssdSet);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.SSD_DELETE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (SDSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrRestImpl method addDsdRoleMember.
/**
* {@inheritDoc}
*/
@Override
public SDSet addDsdRoleMember(SDSet dsdSet, Role role) throws SecurityException {
VUtil.assertNotNull(dsdSet, GlobalErrIds.SSD_NULL, CLS_NM + ".addDsdRoleMember");
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".addDsdRoleMember");
SDSet retSet;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(dsdSet);
request.setValue(role.getName());
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_ADD_MEMBER);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (SDSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AccessMgrImplTest method createSessionsDSD.
/**
* @param msg
* @param uArray
* @param dsdArray
*/
public static void createSessionsDSD(String msg, String[][] uArray, String[][] dsdArray) {
LogUtil.logIt(msg);
try {
AccessMgr accessMgr = AccessMgrFactory.createInstance(TestUtils.getContext());
int i = 0;
for (String[] usr : uArray) {
SDSet dsd = RoleTestData.getSDSet(dsdArray[i++]);
User user = UserTestData.getUser(usr);
Session session = accessMgr.createSession(user, false);
assertNotNull(session);
String userId = accessMgr.getUserId(session);
assertTrue(CLS_NM + ".createSessionsDSD failed compare found userId [" + userId + "] valid userId [" + UserTestData.getUserId(usr) + "]", userId.equalsIgnoreCase(UserTestData.getUserId(usr)));
UserTestData.assertEquals(user, usr);
List<UserRole> uRoles = session.getRoles();
assertNotNull(uRoles);
// was the number of members in test DSD greater than the cardinality?
if (dsd.getMembers().size() < dsd.getCardinality()) {
assertEquals(CLS_NM + ".createSessionsDSD role list size check failed user-role user [" + user.getUserId() + "]", dsd.getMembers().size(), uRoles.size());
} else {
assertEquals(CLS_NM + ".createSessionsDSD role cardinality check failed user-role list size user [" + user.getUserId() + "] dsd set [" + dsd.getName() + "] card [" + dsd.getCardinality() + "] listsize [" + uRoles.size() + "]", dsd.getCardinality() - 1, uRoles.size());
}
}
LOG.debug("createSessionsDSD successful");
} catch (SecurityException ex) {
LOG.error("createSessionsDSD: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations