Search in sources :

Example 1 with PasswordException

use of org.apache.directory.ldap.client.template.exception.PasswordException 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 2 with PasswordException

use of org.apache.directory.ldap.client.template.exception.PasswordException in project directory-ldap-api by apache.

the class AbstractPasswordPolicyResponder method fail.

/**
 * Returns an exception to be thrown in the case of a non SUCCESS
 * <code>resultCode</code>.
 *
 * @param resultResponse The result response
 * @param passwordPolicy The password policy in use
 * @param resultCode The result
 * @return The created PasswordException
 */
protected PasswordException fail(ResultResponse resultResponse, PasswordPolicy passwordPolicy, ResultCodeEnum resultCode) {
    PasswordException exception = new PasswordException();
    exception.setResultCode(resultCode);
    if (passwordPolicy != null && passwordPolicy.getResponse() != null && passwordPolicy.getResponse().getPasswordPolicyError() != null) {
        exception.setPasswordPolicyError(passwordPolicy.getResponse().getPasswordPolicyError());
    }
    return exception;
}
Also used : PasswordException(org.apache.directory.ldap.client.template.exception.PasswordException)

Aggregations

PasswordException (org.apache.directory.ldap.client.template.exception.PasswordException)2 PasswordPolicy (org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 ResultCodeEnum (org.apache.directory.api.ldap.model.message.ResultCodeEnum)1 ResultResponse (org.apache.directory.api.ldap.model.message.ResultResponse)1