Search in sources :

Example 76 with LdapException

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

the class AbstractPasswordPolicyResponder method process.

/**
 * {@inheritDoc}
 */
@Override
public final PasswordWarning process(PasswordPolicyOperation operation) throws PasswordException {
    try {
        ResultResponse response = operation.process();
        PasswordPolicy passwordPolicy = getPasswordPolicy(response);
        ResultCodeEnum resultCode = response.getLdapResult().getResultCode();
        if (resultCode == ResultCodeEnum.SUCCESS) {
            return success(passwordPolicy);
        } else {
            throw fail(response, passwordPolicy, resultCode);
        }
    } catch (LdapException e) {
        throw new PasswordException().setLdapException(e);
    }
}
Also used : ResultResponse(org.apache.directory.api.ldap.model.message.ResultResponse) PasswordException(org.apache.directory.ldap.client.template.exception.PasswordException) PasswordPolicy(org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) ResultCodeEnum(org.apache.directory.api.ldap.model.message.ResultCodeEnum)

Example 77 with LdapException

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

the class LdapConnectionTemplate method modifyPassword.

/**
 * {@inheritDoc}
 */
@Override
public void modifyPassword(Dn userDn, char[] oldPassword, char[] newPassword, boolean asAdmin) throws PasswordException {
    LdapConnection connection = null;
    try {
        connection = connectionPool.getConnection();
        if (!asAdmin) {
            authenticateConnection(connection, userDn, oldPassword);
        }
        modifyPassword(connection, userDn, newPassword);
    } catch (LdapException e) {
        throw new LdapRuntimeException(e);
    } finally {
        returnLdapConnection(connection);
    }
}
Also used : LdapRuntimeException(org.apache.directory.ldap.client.template.exception.LdapRuntimeException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnection(org.apache.directory.ldap.client.api.LdapConnection)

Example 78 with LdapException

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

the class SearchCursorImpl method next.

/**
 * {@inheritDoc}
 */
@Override
public boolean next() throws LdapException, CursorException {
    if (done) {
        return false;
    }
    try {
        if (future.isCancelled()) {
            response = null;
            done = true;
            return false;
        }
        response = future.get(timeout, timeUnit);
    } catch (Exception e) {
        LdapException ldapException = new LdapException(LdapNetworkConnection.NO_RESPONSE_ERROR, e);
        // Send an abandon request
        if (!future.isCancelled()) {
            future.cancel(true);
        }
        // close the cursor
        try {
            close(ldapException);
        } catch (IOException ioe) {
            throw new LdapException(ioe.getMessage(), ioe);
        }
        throw ldapException;
    }
    if (response == null) {
        future.cancel(true);
        throw new LdapConnectionTimeOutException(LdapNetworkConnection.TIME_OUT_ERROR);
    }
    done = response instanceof SearchResultDone;
    if (done) {
        searchDoneResp = (SearchResultDone) response;
        response = null;
    }
    return !done;
}
Also used : SearchResultDone(org.apache.directory.api.ldap.model.message.SearchResultDone) IOException(java.io.IOException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) IOException(java.io.IOException) LdapConnectionTimeOutException(org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException) CursorException(org.apache.directory.api.ldap.model.cursor.CursorException) InvalidCursorPositionException(org.apache.directory.api.ldap.model.cursor.InvalidCursorPositionException) LdapReferralException(org.apache.directory.api.ldap.model.exception.LdapReferralException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) LdapConnectionTimeOutException(org.apache.directory.ldap.client.api.exception.LdapConnectionTimeOutException)

Example 79 with LdapException

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

the class OidRegistry method getNameSet.

/**
 * Gets the names associated with an OID.  An OID is unique however it may
 * have many names used to refer to it.  A good example is the cn and
 * commonName attribute names for OID 2.5.4.3.  Within a server one name
 * within the set must be chosen as the primary name.  This is used to
 * name certain things within the server internally.  If there is more than
 * one name then the first name is taken to be the primary.
 *
 * @param oid the OID for which we return the set of common names
 * @return a sorted set of names
 * @throws org.apache.directory.api.ldap.model.exception.LdapException if oid does not exist
 */
public List<String> getNameSet(String oid) throws LdapException {
    SchemaObject schemaObject = byOid.get(oid);
    if (null == schemaObject) {
        String msg = I18n.err(I18n.ERR_13741_OID_NOT_FOUND_IN_REGISTRY, oid);
        LOG.error(msg);
        throw new LdapException(msg);
    }
    List<String> names = schemaObject.getNames();
    if (IS_DEBUG) {
        LOG.debug("looked up names '{}' for OID '{}'", ArrayUtils.toString(names), oid);
    }
    return names;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 80 with LdapException

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

the class OidRegistry method getPrimaryName.

/**
 * Gets the primary name associated with an OID.  The primary name is the
 * first name specified for the OID.
 *
 * @param oid the object identifier
 * @return the primary name
 * @throws LdapException if oid does not exist
 */
public String getPrimaryName(String oid) throws LdapException {
    SchemaObject schemaObject = byOid.get(oid);
    if (schemaObject != null) {
        return schemaObject.getName();
    } else {
        String msg = I18n.err(I18n.ERR_13741_OID_NOT_FOUND_IN_REGISTRY, oid);
        LOG.error(msg);
        throw new LdapException(msg);
    }
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Aggregations

LdapException (org.apache.directory.api.ldap.model.exception.LdapException)361 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)161 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)111 ArrayList (java.util.ArrayList)94 FinderException (org.apache.directory.fortress.core.FinderException)73 Modification (org.apache.directory.api.ldap.model.entry.Modification)70 Entry (org.apache.directory.api.ldap.model.entry.Entry)68 IOException (java.io.IOException)57 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)57 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)53 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)51 UpdateException (org.apache.directory.fortress.core.UpdateException)41 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)35 Dn (org.apache.directory.api.ldap.model.name.Dn)34 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)29 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)25 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)25 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)23 DecoderException (org.apache.directory.api.asn1.DecoderException)22 LdapNoPermissionException (org.apache.directory.api.ldap.model.exception.LdapNoPermissionException)22