Search in sources :

Example 1 with SetPwdResponse

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

the class InetOrgPersonImpl method setPassword.

public void setPassword(final String newPassword, final boolean enforcePasswordPolicy) throws ChaiUnavailableException, ChaiPasswordPolicyException {
    final boolean useNmasSetting = this.getChaiProvider().getChaiConfiguration().getBooleanSetting(ChaiSetting.EDIRECTORY_ENABLE_NMAS);
    if (!useNmasSetting) {
        try {
            writeStringAttribute(ATTR_PASSWORD, newPassword);
        } catch (ChaiOperationException e) {
            throw new ChaiPasswordPolicyException(e.getMessage(), ChaiErrors.getErrorForMessage(e.getMessage()));
        }
    } else {
        final SetPwdRequest request = new SetPwdRequest();
        request.setData(newPassword);
        request.setObjectDN(this.getEntryDN());
        final ExtendedResponse response;
        try {
            response = getChaiProvider().extendedOperation(request);
        } catch (ChaiOperationException e) {
            throw new ChaiPasswordPolicyException(e.getMessage(), ChaiErrors.getErrorForMessage(e.getMessage()));
        }
        if (response != null) {
            final SetPwdResponse setResponse = (SetPwdResponse) response;
            final int responseCode = setResponse.getNmasRetCode();
            if (responseCode != 0) {
                LOGGER.debug("error setting nmas password: " + responseCode);
                final String errorString = "nmas error " + responseCode;
                throw new ChaiPasswordPolicyException(errorString, ChaiErrors.getErrorForMessage(errorString));
            }
        }
    }
}
Also used : ChaiPasswordPolicyException(com.novell.ldapchai.exception.ChaiPasswordPolicyException) SetPwdRequest(com.novell.security.nmas.jndi.ldap.ext.SetPwdRequest) ExtendedResponse(javax.naming.ldap.ExtendedResponse) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException) SetPwdResponse(com.novell.security.nmas.jndi.ldap.ext.SetPwdResponse)

Aggregations

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