use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class SdDAO method search.
/**
* @param roles
* @param sdSet
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
Set<SDSet> search(Set<String> roles, SDSet sdSet) throws FinderException {
Set<SDSet> sdList = new HashSet<>();
LdapConnection ld = null;
String ssdRoot = getSdRoot(sdSet.getContextId());
String objectClass = SSD_OBJECT_CLASS_NM;
if (sdSet.getType() == SDSet.SDType.DYNAMIC) {
objectClass = DSD_OBJECT_CLASS_NM;
}
try {
if (CollectionUtils.isNotEmpty(roles)) {
StringBuilder filterbuf = new StringBuilder();
filterbuf.append(GlobalIds.FILTER_PREFIX);
filterbuf.append(objectClass);
filterbuf.append(")(|");
for (String rle : roles) {
filterbuf.append("(");
filterbuf.append(ROLES);
filterbuf.append("=");
filterbuf.append(rle);
filterbuf.append(")");
}
filterbuf.append("))");
ld = getAdminConnection();
SearchCursor searchResults = search(ld, ssdRoot, SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, GlobalIds.BATCH_SIZE);
long sequence = 0;
while (searchResults.next()) {
sdList.add(unloadLdapEntry(searchResults.getEntry(), sequence++));
}
}
} catch (LdapException e) {
String error = "search type [" + sdSet.getType() + "] caught LdapException=" + e.getMessage();
int errCode;
if (sdSet.getType() == SDSet.SDType.DYNAMIC) {
errCode = GlobalErrIds.DSD_SEARCH_FAILED;
} else {
errCode = GlobalErrIds.SSD_SEARCH_FAILED;
}
throw new FinderException(errCode, error, e);
} catch (CursorException e) {
String error = "search type [" + sdSet.getType() + "] caught CursorException=" + e.getMessage();
int errCode;
if (sdSet.getType() == SDSet.SDType.DYNAMIC) {
errCode = GlobalErrIds.DSD_SEARCH_FAILED;
} else {
errCode = GlobalErrIds.SSD_SEARCH_FAILED;
}
throw new FinderException(errCode, error, e);
} finally {
closeAdminConnection(ld);
}
return sdList;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class SdDAO method unloadLdapEntry.
/**
* @param le
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private SDSet unloadLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
SDSet entity = new ObjectFactory().createSDset();
entity.setSequenceId(sequence);
entity.setId(getAttribute(le, GlobalIds.FT_IID));
entity.setName(getAttribute(le, SD_SET_NM));
entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
entity.setMembers(getAttributeSet(le, ROLES));
String szCard = getAttribute(le, SD_SET_CARDINALITY);
entity.setCardinality(Integer.valueOf(szCard));
return entity;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class SdP method read.
/**
* Return a fully populated SDSet entity for a given STATIC or DYNAMIC SDSet name. If matching record not found a
* SecurityException will be thrown.
*
* @param entity contains full SDSet name used for STATIC or DYNAMIC data sets in directory.
* @return SDSet entity containing all attributes associated with ou in directory.
* @throws SecurityException in the event SDSet not found or DAO search error.
*/
SDSet read(SDSet entity) throws SecurityException {
SDSet sde;
// The assumption is this method is called from ReviewMgr.ssdRoleSetRoles or ReviewMgr.dsdRoleSetRoles.
// If called from ReviewMgr, the object class type will be passed in:
SDSet.SDType type = entity.getType();
sde = sdDao.getSD(entity);
// Load the previously saved type onto the return entity:
sde.setType(type);
return sde;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrImpl method deleteSsdRoleMember.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public SDSet deleteSsdRoleMember(SDSet ssdSet, Role role) throws SecurityException {
String methodName = "deleteSsdRoleMember";
assertContext(CLS_NM, methodName, ssdSet, GlobalErrIds.SSD_NULL);
assertContext(CLS_NM, methodName, role, GlobalErrIds.ROLE_NULL);
setEntitySession(CLS_NM, methodName, ssdSet);
SDSet entity = sdP.read(ssdSet);
entity.setContextId(this.contextId);
entity.delMember(role.getName());
// when removing last role member a placeholder must be left in data set:
if (entity.getMembers().isEmpty()) {
entity.addMember(GlobalIds.NONE);
}
setAdminData(CLS_NM, methodName, entity);
SDSet ssdOut = sdP.update(entity);
// remove any references to the old SSD from cache:
clearSSDCache(role);
return ssdOut;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrImpl method addSsdRoleMember.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public SDSet addSsdRoleMember(SDSet ssdSet, Role role) throws SecurityException {
String methodName = "addSsdRoleMember";
assertContext(CLS_NM, methodName, ssdSet, GlobalErrIds.SSD_NULL);
assertContext(CLS_NM, methodName, role, GlobalErrIds.ROLE_NULL);
setEntitySession(CLS_NM, methodName, ssdSet);
SDSet entity = sdP.read(ssdSet);
entity.setContextId(this.contextId);
entity.addMember(role.getName());
setAdminData(CLS_NM, methodName, entity);
SDSet ssdOut = sdP.update(entity);
// remove any references to the old SSD from cache:
clearSSDCache(role);
return ssdOut;
}
Aggregations