use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class AdminMgrImplTest method delPermAttrSet.
public static void delPermAttrSet(String msg, String name) {
LogUtil.logIt(msg);
PermissionAttributeSet paSet = new PermissionAttributeSet(name);
try {
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
adminMgr.deletePermissionAttributeSet(paSet);
LOG.debug("delPermAttrSet name [" + paSet.getName() + "] successful");
} catch (SecurityException ex) {
LOG.error("delPermAttrSet 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 AdminMgrRestImpl method addPermissionAttributeSet.
/**
* {@inheritDoc}
*/
@Override
public PermissionAttributeSet addPermissionAttributeSet(PermissionAttributeSet permAttributeSet) throws SecurityException {
VUtil.assertNotNull(permAttributeSet, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM + ".addPermissionAttributeSet");
PermissionAttributeSet retSet;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(permAttributeSet);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD_ATTRIBUTE_SET);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (PermissionAttributeSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class PermDAO method unloadPASetLdapEntry.
private PermissionAttributeSet unloadPASetLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
PermissionAttributeSet entity = new ObjectFactory().createPermissionAttributeSet();
entity.setSequenceId(sequence);
entity.setName(getAttribute(le, SchemaConstants.CN_AT));
entity.setDn(le.getDn().getName());
entity.setInternalId(getAttribute(le, GlobalIds.FT_IID));
entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
entity.setType(getAttribute(le, GlobalIds.FT_PERMISSION_ATTRIBUTE_SET_TYPE));
return entity;
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class PermP method validatePaSet.
/*
* Ensure the paSet is present and name is safe.
*/
void validatePaSet(String paSetName, String contextId) throws ValidationException {
try {
PermissionAttributeSet paSet = new PermissionAttributeSet(paSetName);
paSet.setContextId(contextId);
read(paSet);
VUtil.safeText(paSetName, GlobalIds.DESC_LEN);
} catch (SecurityException e) {
String error = "validatePaSet - paSetName not found with name [" + paSetName + "] caught SecurityException=" + e;
throw new ValidationException(GlobalErrIds.PERM_ATTRIBUTE_SET_NOT_FOUND, error);
}
}
use of org.apache.directory.fortress.core.model.PermissionAttributeSet in project directory-fortress-core by apache.
the class ReviewMgrImpl method rolePermissionAttributeSets.
/**
* {@inheritDoc}
*/
@Override
public List<PermissionAttributeSet> rolePermissionAttributeSets(Role role, boolean noInhertiance) throws SecurityException {
Map<String, PermissionAttributeSet> permAttributeSets = new HashMap<String, PermissionAttributeSet>();
// look through all permissions in the role
List<Permission> permissions = this.rolePermissions(role, noInhertiance);
for (Permission perm : permissions) {
if (CollectionUtils.isNotEmpty(perm.getPaSets())) {
for (String paSetName : perm.getPaSets()) {
if (!permAttributeSets.containsKey(paSetName)) {
PermissionAttributeSet paSet = new PermissionAttributeSet(paSetName);
paSet.setContextId(this.contextId);
PermissionAttributeSet permAttributeSet = permP.read(paSet);
permAttributeSets.put(paSetName, permAttributeSet);
}
}
}
}
return new ArrayList<>(permAttributeSets.values());
}
Aggregations