Search in sources :

Example 6 with LdapNoSuchAttributeException

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

the class UserDAO method unlock.

/**
 * @param user
 * @throws UpdateException
 */
void unlock(User user) throws UpdateException {
    LdapConnection ld = null;
    String userDn = getDn(user.getUserId(), user.getContextId());
    try {
        // ld = getAdminConnection();
        List<Modification> mods = new ArrayList<Modification>();
        mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, OPENLDAP_PW_LOCKED_TIME));
        ld = getAdminConnection();
        modify(ld, userDn, mods, user);
    } catch (LdapNoSuchAttributeException e) {
        LOG.info("unlock user [" + user.getUserId() + "] no such attribute:" + OPENLDAP_ACCOUNT_LOCKED_TIME);
    } catch (LdapException e) {
        String error = "unlock user [" + user.getUserId() + "] caught LDAPException= " + e.getMessage();
        throw new UpdateException(GlobalErrIds.USER_PW_UNLOCK_FAILED, error, e);
    } finally {
        closeAdminConnection(ld);
    }
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) ArrayList(java.util.ArrayList) UpdateException(org.apache.directory.fortress.core.UpdateException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 7 with LdapNoSuchAttributeException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.

the class DefaultObjectClassRegistry method registerDescendants.

/**
 * {@inheritDoc}
 */
@Override
public void registerDescendants(ObjectClass objectClass, List<ObjectClass> ancestors) throws LdapException {
    // add this attribute to descendant list of other attributes in superior chain
    if ((ancestors == null) || ancestors.isEmpty()) {
        return;
    }
    for (ObjectClass ancestor : ancestors) {
        // Get the ancestor's descendant, if any
        Set<ObjectClass> descendants = oidToDescendants.get(ancestor.getOid());
        // Initialize the descendant Set to store the descendants for the attributeType
        if (descendants == null) {
            descendants = new HashSet<>(1);
            oidToDescendants.put(ancestor.getOid(), descendants);
        }
        // Add the current ObjectClass as a descendant
        descendants.add(objectClass);
        try {
            // And recurse until we reach the top of the hierarchy
            registerDescendants(objectClass, ancestor.getSuperiors());
        } catch (LdapException ne) {
            throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
        }
    }
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 8 with LdapNoSuchAttributeException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.

the class DefaultObjectClassRegistry method unregister.

/**
 * {@inheritDoc}
 */
@Override
public ObjectClass unregister(String numericOid) throws LdapException {
    try {
        ObjectClass removed = super.unregister(numericOid);
        // Deleting an ObjectClass which might be used as a superior means we have
        // to recursively update the descendant map. We also have to remove
        // the at.oid -> descendant relation
        oidToDescendants.remove(numericOid);
        // Now recurse if needed
        unregisterDescendants(removed, removed.getSuperiors());
        return removed;
    } catch (LdapException ne) {
        throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
    }
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 9 with LdapNoSuchAttributeException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.

the class DefaultObjectClassRegistry method hasDescendants.

/**
 * {@inheritDoc}
 */
@Override
public boolean hasDescendants(String ancestorId) throws LdapException {
    try {
        String oid = getOidByName(ancestorId);
        Set<ObjectClass> descendants = oidToDescendants.get(oid);
        return (descendants != null) && !descendants.isEmpty();
    } catch (LdapException ne) {
        throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
    }
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Example 10 with LdapNoSuchAttributeException

use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.

the class DefaultAttributeTypeRegistry method descendants.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public Iterator<AttributeType> descendants(String ancestorId) throws LdapException {
    try {
        String oid = getOidByName(ancestorId);
        Set<AttributeType> descendants = oidToDescendantSet.get(oid);
        if (descendants == null) {
            return Collections.EMPTY_SET.iterator();
        }
        return descendants.iterator();
    } catch (LdapException ne) {
        throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
    }
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapNoSuchAttributeException(org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)

Aggregations

LdapNoSuchAttributeException (org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)12 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)11 ArrayList (java.util.ArrayList)4 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)4 Modification (org.apache.directory.api.ldap.model.entry.Modification)4 UpdateException (org.apache.directory.fortress.core.UpdateException)4 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)4 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)3 ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)3 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 NamingException (javax.naming.NamingException)1 NoPermissionException (javax.naming.NoPermissionException)1 OperationNotSupportedException (javax.naming.OperationNotSupportedException)1 ServiceUnavailableException (javax.naming.ServiceUnavailableException)1