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;
}
Aggregations