use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class PermDAO method getPermAttributeSet.
PermissionAttributeSet getPermAttributeSet(PermissionAttributeSet permAttributeSet) throws FinderException {
PermissionAttributeSet entity = null;
LdapConnection ld = null;
String dn = getDn(permAttributeSet, permAttributeSet.getContextId());
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, PERMISION_ATTRIBUTE_SET_ATRS);
if (findEntry == null) {
String warning = "getPermAttributeSet no entry found dn [" + dn + "]";
throw new FinderException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, warning);
}
entity = unloadPASetLdapEntry(findEntry, 0);
// find permission attributes for this set
entity.setAttributes(this.findPermissionAttributes(entity));
} catch (LdapNoSuchObjectException e) {
String warning = "getPermAttributeSet COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "getPermAttributeSet dn [" + dn + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method rolePermissionAttributeSets.
/**
* {@inheritDoc}
*/
@Override
public List<PermissionAttributeSet> rolePermissionAttributeSets(Role role, boolean noInhertiance) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".rolePermissionAttributeSets");
List<PermissionAttributeSet> retAttrSets;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(role);
request.setIsFlag(noInhertiance);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_PERM_ATTR_SETS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retAttrSets = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retAttrSets;
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class ReviewMgrImplTest method readPermissionAttributeSet.
public static void readPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttributes) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
PermissionAttributeSet entity = reviewMgr.readPermAttributeSet(new PermissionAttributeSet(name));
assertNotNull(entity);
assertEquals(name, entity.getName());
assertEquals(PermTestData.TPA_SET_TYPE, entity.getType());
for (PermissionAttribute pa : permAttributes) {
assertTrue(entity.getAttributes().contains(pa));
}
LOG.debug("readPermissionAttributeSet name [" + name + "] successful");
} catch (SecurityException ex) {
LOG.error("readPermissionAttributeSet name [" + name + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage() + ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class AdminMgrImplTest method addPermissionAttributeSet.
public static void addPermissionAttributeSet(String msg, String name, Set<PermissionAttribute> permAttr) {
LogUtil.logIt(msg);
PermissionAttributeSet paSet = new PermissionAttributeSet(name);
paSet.setType(PermTestData.TPA_SET_TYPE);
try {
paSet.setAttributes(permAttr);
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
adminMgr.addPermissionAttributeSet(paSet);
LOG.debug("addPermissionAttributeSet name [" + paSet.getName() + "] successful");
} catch (SecurityException ex) {
LOG.error("addPermissionAttributeSet name [" + paSet.getName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class AdminMgrImplTest method addPermissionAttributeToSet.
public static void addPermissionAttributeToSet(String msg, String name, PermissionAttribute permAttr) {
LogUtil.logIt(msg);
PermissionAttributeSet paSet = new PermissionAttributeSet(name);
try {
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
adminMgr.addPermissionAttributeToSet(permAttr, name);
LOG.debug("addPermissionAttributeToSet name [" + paSet.getName() + "] successful");
} catch (SecurityException ex) {
LOG.error("addPermissionAttributeToSet name [" + paSet.getName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations