use of com.novell.security.nmas.jndi.ldap.ext.ChangePwdRequest in project ldapchai by ldapchai.
the class InetOrgPersonImpl method changePassword.
public final void changePassword(final String oldPassword, final String newPassword) throws ChaiUnavailableException, ChaiPasswordPolicyException {
final boolean useNmasSetting = this.getChaiProvider().getChaiConfiguration().getBooleanSetting(ChaiSetting.EDIRECTORY_ENABLE_NMAS);
if (!useNmasSetting) {
try {
replaceAttribute(ATTR_PASSWORD, oldPassword, newPassword);
} catch (ChaiOperationException e) {
throw new ChaiPasswordPolicyException(e.getMessage(), ChaiErrors.getErrorForMessage(e.getMessage()));
}
} else {
final ChangePwdRequest request = new ChangePwdRequest();
request.setNewPwd(newPassword);
request.setObjectDN(this.getEntryDN());
request.setOldPwd(oldPassword);
final ExtendedResponse response;
try {
response = getChaiProvider().extendedOperation(request);
} catch (ChaiOperationException e) {
throw new ChaiPasswordPolicyException(e.getMessage(), ChaiErrors.getErrorForMessage(e.getMessage()));
}
if (response != null) {
final ChangePwdResponse changeResponse = (ChangePwdResponse) response;
final int responseCode = changeResponse.getNmasRetCode();
if (responseCode != 0) {
LOGGER.debug("error changing nmas password: " + responseCode);
final String errorString = "nmas error " + responseCode;
throw new ChaiPasswordPolicyException(errorString, ChaiErrors.getErrorForMessage(errorString));
}
}
}
}
Aggregations