use of com.novell.ldapchai.ChaiRequestControl in project ldapchai by ldapchai.
the class UserImpl method setPassword.
public void setPassword(final String newPassword, final boolean enforcePasswordPolicy) throws ChaiUnavailableException, ChaiPasswordPolicyException, ChaiOperationException {
final String quotedPwd = '"' + newPassword + '"';
final byte[] littleEndianEncodedPwd;
try {
littleEndianEncodedPwd = quotedPwd.getBytes("UTF-16LE");
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("unexpected error, missing 'UTF-16LE' character encoder", e);
}
final byte[][] multiBA = new byte[][] { littleEndianEncodedPwd };
try {
if (enforcePasswordPolicy && this.getChaiProvider().getChaiConfiguration().getBooleanSetting(ChaiSetting.AD_SET_POLICY_HINTS_ON_PW_SET)) {
// 0x1 berEncoded
final byte[] value = { 48, (byte) 132, 0, 0, 0, 3, 2, 1, 1 };
final ChaiRequestControl[] controls = new ChaiRequestControl[] { new ChaiRequestControl(LDAP_SERVER_POLICY_HINTS_OID, true, value) };
chaiProvider.writeBinaryAttribute(this.getEntryDN(), "unicodePwd", multiBA, true, controls);
} else {
writeBinaryAttribute("unicodePwd", multiBA);
}
} catch (ChaiOperationException e) {
if (e.getErrorCode() == ChaiError.UNKNOWN) {
throw new ChaiOperationException(e.getMessage(), ChaiError.PASSWORD_BADPASSWORD);
} else {
throw e;
}
}
}
use of com.novell.ldapchai.ChaiRequestControl in project ldapchai by ldapchai.
the class ApacheLdapProviderImpl method figureControls.
private static Control[] figureControls(final ChaiRequestControl[] chaiControls) {
final List<Control> returnObj = new ArrayList<Control>();
for (final ChaiRequestControl chaiControl : chaiControls) {
final Control control = new Control() {
public String getOid() {
return chaiControl.getId();
}
public boolean isCritical() {
return chaiControl.isCritical();
}
public void setCritical(final boolean isCritical) {
}
};
returnObj.add(control);
}
return returnObj.toArray(new Control[returnObj.size()]);
}
Aggregations