Search in sources :

Example 1 with PwdPolicyCheckResponse

use of com.novell.security.nmas.jndi.ldap.ext.PwdPolicyCheckResponse in project ldapchai by ldapchai.

the class InetOrgPersonImpl method testPasswordPolicy.

public boolean testPasswordPolicy(final String password) throws ChaiUnavailableException, ChaiPasswordPolicyException {
    final boolean useNmasSetting = this.getChaiProvider().getChaiConfiguration().getBooleanSetting(ChaiSetting.EDIRECTORY_ENABLE_NMAS);
    if (!useNmasSetting) {
        return true;
    }
    final PwdPolicyCheckRequest request = new PwdPolicyCheckRequest();
    request.setData(password);
    request.setObjectDN(this.getEntryDN());
    final ExtendedResponse response;
    try {
        response = getChaiProvider().extendedOperation(request);
    } catch (ChaiOperationException e) {
        LOGGER.debug("unexpected error while checking [nmas] password policy: " + e.getMessage());
        return true;
    }
    if (response != null) {
        final PwdPolicyCheckResponse setResponse = (PwdPolicyCheckResponse) response;
        final int responseCode = setResponse.getNmasRetCode();
        if (responseCode != 0) {
            LOGGER.debug("nmas response code returned from server while testing nmas password: " + responseCode);
            final String errorString = "nmas error " + responseCode;
            throw new ChaiPasswordPolicyException(errorString, ChaiErrors.getErrorForMessage(errorString));
        }
    }
    return true;
}
Also used : PwdPolicyCheckResponse(com.novell.security.nmas.jndi.ldap.ext.PwdPolicyCheckResponse) ExtendedResponse(javax.naming.ldap.ExtendedResponse) ChaiPasswordPolicyException(com.novell.ldapchai.exception.ChaiPasswordPolicyException) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException) PwdPolicyCheckRequest(com.novell.security.nmas.jndi.ldap.ext.PwdPolicyCheckRequest)

Aggregations

ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)1 ChaiPasswordPolicyException (com.novell.ldapchai.exception.ChaiPasswordPolicyException)1 PwdPolicyCheckRequest (com.novell.security.nmas.jndi.ldap.ext.PwdPolicyCheckRequest)1 PwdPolicyCheckResponse (com.novell.security.nmas.jndi.ldap.ext.PwdPolicyCheckResponse)1 ExtendedResponse (javax.naming.ldap.ExtendedResponse)1