use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class PermDAO method grant.
/**
* @param pOp
* @param role
* @throws org.apache.directory.fortress.core.UpdateException
*
* @throws org.apache.directory.fortress.core.FinderException
*/
void grant(Permission pOp, Role role) throws UpdateException {
LdapConnection ld = null;
String dn = getDn(pOp, pOp.getContextId());
try {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, ROLES, role.getName()));
ld = getAdminConnection();
modify(ld, dn, mods, pOp);
} catch (LdapAttributeInUseException e) {
String warning = "grant perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] role [" + role.getName() + "] assignment already exists, Fortress rc=" + GlobalErrIds.PERM_ROLE_EXIST;
throw new UpdateException(GlobalErrIds.PERM_ROLE_EXIST, warning);
} catch (LdapNoSuchObjectException e) {
String warning = "grant perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] role [" + role.getName() + "] perm not found, Fortress rc=" + GlobalErrIds.PERM_OP_NOT_FOUND;
throw new UpdateException(GlobalErrIds.PERM_OP_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "grant perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] name [" + role.getName() + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.PERM_GRANT_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class AdminRoleDAO method getRole.
/**
* This method will retrieve the AdminRole from {@link GlobalIds#ADMIN_ROLE_ROOT} container by name.
*
* @param adminRole maps to {@link AdminRole#name}.
* @return AdminRole back to client.
* @throws FinderException in the event LDAP errors occur.
*/
AdminRole getRole(AdminRole adminRole) throws FinderException {
AdminRole entity = null;
LdapConnection ld = null;
String dn = getDn(adminRole);
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, ROLE_ATRS);
if (findEntry != null) {
entity = unloadLdapEntry(findEntry, 0, adminRole.getContextId());
}
if (entity == null) {
String warning = "getRole name [" + adminRole.getName() + "] no entry found dn [" + dn + "]";
throw new FinderException(GlobalErrIds.ARLE_NOT_FOUND, warning);
}
} catch (LdapNoSuchObjectException e) {
String warning = "getRole name [" + adminRole.getName() + "] Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.ARLE_NOT_FOUND, warning, e);
} catch (LdapException e) {
String error = "getRole dn [" + dn + "] LEXCD=" + e.getMessage();
throw new FinderException(GlobalErrIds.ARLE_READ_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class RoleDAO method getRole.
/**
* @param role
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
Role getRole(Role role) throws FinderException {
Role entity = null;
LdapConnection ld = null;
String dn = getDn(role.getName(), role.getContextId());
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, ROLE_ATRS);
if (findEntry != null) {
entity = unloadLdapEntry(findEntry, 0, role.getContextId());
}
if (entity == null) {
String warning = "getRole no entry found dn [" + dn + "]";
throw new FinderException(GlobalErrIds.ROLE_NOT_FOUND, warning);
}
} catch (LdapNoSuchObjectException e) {
String warning = "getRole Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.ROLE_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "getRole dn [" + dn + "] LEXCD=" + e;
throw new FinderException(GlobalErrIds.ROLE_READ_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class GroupDAO method get.
/**
* @param group
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
Group get(Group group) throws FinderException {
Group entity = null;
LdapConnection ld = null;
String dn = getDn(group.getName(), group.getContextId());
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, GROUP_ATRS);
if (findEntry == null) {
String warning = "No Group entry found dn [" + dn + "]";
throw new FinderException(GlobalErrIds.GROUP_NOT_FOUND, warning);
}
entity = unloadLdapEntry(findEntry, 0);
} catch (LdapNoSuchObjectException e) {
String warning = "read Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.GROUP_NOT_FOUND, warning, e);
} catch (LdapException e) {
String error = "read dn [" + dn + "] LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.GROUP_READ_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class ConfigDAO method getConfig.
/**
* @param name
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
Properties getConfig(String name) throws FinderException {
Properties props = null;
LdapConnection ld = null;
String dn = getDn(name);
LOG.info("getConfig dn [{}]", dn);
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, CONFIG_ATRS);
props = PropUtil.getProperties(getAttributes(findEntry, GlobalIds.PROPS));
} catch (LdapNoSuchObjectException e) {
String warning = "getConfig COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.USER_NOT_FOUND, warning, e);
} catch (LdapException e) {
String error = "getConfig dn [" + dn + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.FT_CONFIG_READ_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return props;
}
Aggregations