Search in sources :

Example 6 with LdapNoSuchObjectException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.

the class PermDAO method getPerm.

/**
 * @param permission
 * @return
 * @throws org.apache.directory.fortress.core.FinderException
 */
Permission getPerm(Permission permission) throws FinderException {
    Permission entity = null;
    LdapConnection ld = null;
    String dn = getOpRdn(permission.getOpName(), permission.getObjId()) + "," + GlobalIds.POBJ_NAME + "=" + permission.getObjName() + "," + getRootDn(permission.isAdmin(), permission.getContextId());
    try {
        ld = getAdminConnection();
        Entry findEntry = read(ld, dn, PERMISSION_OP_ATRS);
        if (findEntry == null) {
            String warning = "getPerm no entry found dn [" + dn + "]";
            throw new FinderException(GlobalErrIds.PERM_OP_NOT_FOUND, warning);
        }
        entity = unloadPopLdapEntry(findEntry, 0, permission.isAdmin());
    } catch (LdapNoSuchObjectException e) {
        String warning = "getPerm Op COULD NOT FIND ENTRY for dn [" + dn + "]";
        throw new FinderException(GlobalErrIds.PERM_OP_NOT_FOUND, warning);
    } catch (LdapException e) {
        String error = "getUser [" + dn + "] caught LdapException=" + e.getMessage();
        throw new FinderException(GlobalErrIds.PERM_READ_OP_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return entity;
}
Also used : LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) FinderException(org.apache.directory.fortress.core.FinderException) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) Permission(org.apache.directory.fortress.core.model.Permission) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 7 with LdapNoSuchObjectException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.

the class PolicyDAO method getPolicy.

/**
 * @param policy
 * @return
 * @throws org.apache.directory.fortress.core.FinderException
 */
PwPolicy getPolicy(PwPolicy policy) throws FinderException {
    PwPolicy entity = null;
    LdapConnection ld = null;
    String dn = getDn(policy);
    try {
        ld = getAdminConnection();
        Entry findEntry = read(ld, dn, PASSWORD_POLICY_ATRS);
        entity = unloadLdapEntry(findEntry, 0);
    } catch (LdapNoSuchObjectException e) {
        String warning = "getPolicy Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
        throw new FinderException(GlobalErrIds.PSWD_NOT_FOUND, warning);
    } catch (LdapException e) {
        String error = "getPolicy name [" + policy.getName() + "] caught LdapException=" + e.getMessage();
        throw new FinderException(GlobalErrIds.PSWD_READ_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return entity;
}
Also used : LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) FinderException(org.apache.directory.fortress.core.FinderException) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) PwPolicy(org.apache.directory.fortress.core.model.PwPolicy) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 8 with LdapNoSuchObjectException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.

the class PropertyDAO method getProperties.

/**
 * Get properties on the provided entity using the provided property provider
 *
 * @param entity A FortressEntity that supports properties (Role, AdminRole, Group, Permission, PermObj)
 * @param propProvider DAO for entity type that implements property provider interface
 * @return Current properties of entity
 * @throws FinderException
 */
Properties getProperties(FortEntity entity, PropertyProvider propProvider) throws FinderException {
    Properties props = null;
    LdapConnection ld = null;
    String entityDn = propProvider.getDn(entity);
    try {
        ld = getAdminConnection();
        Entry findEntry = read(ld, entityDn, new String[] { GlobalIds.PROPS });
        props = PropUtil.getProperties(getAttributes(findEntry, GlobalIds.PROPS));
        if (props == null) {
            props = new Properties();
        }
    } catch (LdapNoSuchObjectException e) {
        String warning = "get properties COULD NOT FIND ENTRY for entity [" + entityDn + "]";
        throw new FinderException(GlobalErrIds.ENTITY_PROPS_NOT_FOUND, warning);
    } catch (LdapException e) {
        String error = "get properties [" + entityDn + "]= caught LDAPException=" + e.getMessage();
        throw new FinderException(GlobalErrIds.ENTITY_PROPS_LOAD_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return props;
}
Also used : LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) FinderException(org.apache.directory.fortress.core.FinderException) Entry(org.apache.directory.api.ldap.model.entry.Entry) Properties(java.util.Properties) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 9 with LdapNoSuchObjectException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.

the class OrgUnitDAO method findByKey.

/**
 * @param entity
 * @return
 * @throws FinderException
 */
OrgUnit findByKey(OrgUnit entity) throws FinderException {
    OrgUnit oe = null;
    LdapConnection ld = null;
    Dn dn = getDn(entity);
    try {
        ld = getAdminConnection();
        Entry findEntry = read(ld, dn, ORGUNIT_ATRS);
        if (findEntry == null) {
            String warning = "findByKey orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] COULD NOT FIND ENTRY for dn [" + dn + "]";
            int errCode;
            if (entity.getType() == OrgUnit.Type.PERM) {
                errCode = GlobalErrIds.ORG_NOT_FOUND_PERM;
            } else {
                errCode = GlobalErrIds.ORG_NOT_FOUND_USER;
            }
            throw new FinderException(errCode, warning);
        }
        oe = getEntityFromLdapEntry(findEntry, 0, entity.getContextId());
    } catch (LdapNoSuchObjectException e) {
        String warning = "findByKey orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] COULD NOT FIND ENTRY for dn [" + dn + "]";
        int errCode;
        if (entity.getType() == OrgUnit.Type.PERM) {
            errCode = GlobalErrIds.ORG_NOT_FOUND_PERM;
        } else {
            errCode = GlobalErrIds.ORG_NOT_FOUND_USER;
        }
        throw new FinderException(errCode, warning);
    } catch (LdapException e) {
        String error = "findByKey orgUnitName [" + entity.getName() + "] type [" + entity.getType() + "] dn [" + dn + "] caught LdapException=" + e;
        int errCode;
        if (entity.getType() == OrgUnit.Type.PERM) {
            errCode = GlobalErrIds.ORG_READ_FAILED_PERM;
        } else {
            errCode = GlobalErrIds.ORG_READ_FAILED_USER;
        }
        throw new FinderException(errCode, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return oe;
}
Also used : OrgUnit(org.apache.directory.fortress.core.model.OrgUnit) LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) FinderException(org.apache.directory.fortress.core.FinderException) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 10 with LdapNoSuchObjectException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.

the class SdDAO method getSD.

/**
 * @param sdSet
 * @return
 * @throws FinderException
 */
SDSet getSD(SDSet sdSet) throws FinderException {
    SDSet entity = null;
    LdapConnection ld = null;
    String dn = getDn(sdSet.getName(), sdSet.getContextId());
    try {
        ld = getAdminConnection();
        Entry findEntry = read(ld, dn, SD_SET_ATRS);
        if (findEntry == null) {
            String warning = "getSD no entry found dn [" + dn + "]";
            throw new FinderException(GlobalErrIds.SSD_NOT_FOUND, warning);
        }
        entity = unloadLdapEntry(findEntry, 0);
    } catch (LdapNoSuchObjectException e) {
        String warning = "getSD Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
        throw new FinderException(GlobalErrIds.SSD_NOT_FOUND, warning);
    } catch (LdapException e) {
        String error = "getSSD dn [" + dn + "] LEXCD=" + e;
        int errCode;
        if (sdSet.getType() == SDSet.SDType.DYNAMIC) {
            errCode = GlobalErrIds.DSD_READ_FAILED;
        } else {
            errCode = GlobalErrIds.SSD_READ_FAILED;
        }
        throw new FinderException(errCode, error, e);
    } finally {
        closeAdminConnection(ld);
    }
    return entity;
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) LdapNoSuchObjectException(org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException) FinderException(org.apache.directory.fortress.core.FinderException) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Aggregations

LdapNoSuchObjectException (org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException)21 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)19 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)19 Entry (org.apache.directory.api.ldap.model.entry.Entry)17 FinderException (org.apache.directory.fortress.core.FinderException)17 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)16 LdapAttributeInUseException (org.apache.directory.api.ldap.model.exception.LdapAttributeInUseException)3 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)2 Modification (org.apache.directory.api.ldap.model.entry.Modification)2 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)2 Permission (org.apache.directory.fortress.core.model.Permission)2 AuthenticationException (javax.naming.AuthenticationException)1 AuthenticationNotSupportedException (javax.naming.AuthenticationNotSupportedException)1 CommunicationException (javax.naming.CommunicationException)1 ContextNotEmptyException (javax.naming.ContextNotEmptyException)1 InvalidNameException (javax.naming.InvalidNameException)1 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)1 NameNotFoundException (javax.naming.NameNotFoundException)1