use of org.apache.directory.fortress.core.FinderException in project directory-fortress-core by apache.
the class PermDAO method findPermissions.
/**
* @param permObj
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
List<PermObj> findPermissions(PermObj permObj) throws FinderException {
List<PermObj> permList = new ArrayList<>();
LdapConnection ld = null;
String permRoot = getRootDn(permObj.isAdmin(), permObj.getContextId());
try {
String permObjVal = encodeSafeText(permObj.getObjName(), GlobalIds.PERM_LEN);
StringBuilder filterbuf = new StringBuilder();
filterbuf.append(GlobalIds.FILTER_PREFIX);
filterbuf.append(PERM_OBJ_OBJECT_CLASS_NAME);
filterbuf.append(")(");
filterbuf.append(GlobalIds.POBJ_NAME);
filterbuf.append("=");
filterbuf.append(permObjVal);
filterbuf.append("*))");
ld = getAdminConnection();
SearchCursor searchResults = search(ld, permRoot, SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, GlobalIds.BATCH_SIZE);
long sequence = 0;
while (searchResults.next()) {
permList.add(unloadPobjLdapEntry(searchResults.getEntry(), sequence++, permObj.isAdmin()));
}
} catch (LdapException e) {
String error = "findPermissions caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PERM_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "findPermissions caught CursorException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PERM_SEARCH_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return permList;
}
use of org.apache.directory.fortress.core.FinderException in project directory-fortress-core by apache.
the class PolicyDAO method findPolicy.
/**
* @param policy
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
List<PwPolicy> findPolicy(PwPolicy policy) throws FinderException {
List<PwPolicy> policyArrayList = new ArrayList<>();
LdapConnection ld = null;
String policyRoot = getPolicyRoot(policy.getContextId());
String searchVal = null;
try {
searchVal = encodeSafeText(policy.getName(), GlobalIds.PWPOLICY_NAME_LEN);
String szFilter = GlobalIds.FILTER_PREFIX + PW_POLICY_CLASS + ")(" + PW_PWD_ID + "=" + searchVal + "*))";
ld = getAdminConnection();
SearchCursor searchResults = search(ld, policyRoot, SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_ATRS, false, GlobalIds.BATCH_SIZE);
long sequence = 0;
while (searchResults.next()) {
policyArrayList.add(unloadLdapEntry(searchResults.getEntry(), sequence++));
}
} catch (LdapException e) {
String error = "findPolicy name [" + searchVal + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "findPolicy name [" + searchVal + "] caught CursorException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return policyArrayList;
}
use of org.apache.directory.fortress.core.FinderException in project directory-fortress-core by apache.
the class PolicyDAO method getPolicies.
/**
* @return
* @throws FinderException
*/
Set<String> getPolicies(String contextId) throws FinderException {
Set<String> policySet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
LdapConnection ld = null;
String policyRoot = getPolicyRoot(contextId);
try {
String szFilter = "(objectclass=" + PW_POLICY_CLASS + ")";
ld = getAdminConnection();
SearchCursor searchResults = search(ld, policyRoot, SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_NAME_ATR, false, GlobalIds.BATCH_SIZE);
while (searchResults.next()) {
Entry entry = searchResults.getEntry();
policySet.add(getAttribute(entry, PW_PWD_ID));
}
} catch (LdapException e) {
String error = "getPolicies caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "getPolicies caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return policySet;
}
use of org.apache.directory.fortress.core.FinderException in project directory-fortress-core by apache.
the class AdminRoleDAO method findRoles.
/**
* @param adminRole
* @return
* @throws FinderException
*/
List<AdminRole> findRoles(AdminRole adminRole) throws FinderException {
List<AdminRole> roleList = new ArrayList<AdminRole>();
LdapConnection ld = null;
String roleRoot = getRootDn(adminRole.getContextId(), GlobalIds.ADMIN_ROLE_ROOT);
String filter;
try {
String searchVal = encodeSafeText(adminRole.getName(), GlobalIds.ROLE_LEN);
filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")(" + ROLE_NM + "=" + searchVal + "*))";
ld = getAdminConnection();
SearchCursor searchResults = search(ld, roleRoot, SearchScope.ONELEVEL, filter, ROLE_ATRS, false, GlobalIds.BATCH_SIZE);
long sequence = 0;
while (searchResults.next()) {
roleList.add(unloadLdapEntry(searchResults.getEntry(), sequence++, adminRole.getContextId()));
}
} catch (LdapException e) {
String error = "findRoles name [" + adminRole.getName() + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.ARLE_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "findRoles name [" + adminRole.getName() + "] caught CursorException=" + e.getMessage();
throw new FinderException(GlobalErrIds.ARLE_SEARCH_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return roleList;
}
use of org.apache.directory.fortress.core.FinderException in project directory-fortress-core by apache.
the class AdminRoleDAO method findRoles.
/**
* @param adminRole
* @param limit
* @return
* @throws FinderException
*/
List<String> findRoles(AdminRole adminRole, int limit) throws FinderException {
List<String> roleList = new ArrayList<String>();
LdapConnection ld = null;
String roleRoot = getRootDn(adminRole.getContextId(), GlobalIds.ADMIN_ROLE_ROOT);
String filter;
String searchVal = null;
try {
searchVal = encodeSafeText(adminRole.getName(), GlobalIds.ROLE_LEN);
filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")(" + ROLE_NM + "=" + searchVal + "*))";
ld = getAdminConnection();
SearchCursor searchResults = search(ld, roleRoot, SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, limit);
while (searchResults.next()) {
Entry entry = searchResults.getEntry();
roleList.add(getAttribute(entry, ROLE_NM));
}
} catch (LdapException e) {
String error = "findRoles name [" + searchVal + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.ARLE_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "findRoles name [" + searchVal + "] caught CursorException=" + e.getMessage();
throw new FinderException(GlobalErrIds.ARLE_SEARCH_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return roleList;
}
Aggregations