Ever need to randomly generate a simpler password than what is allowed based off the 'passwordMaxLength' constraint.
Here is some quick background on generating passwords in IIQ.
The following method will drop the max length to 10 temporarily, without affecting other places in IIQ where it is important to allow up to 20 characters when setting passwords.
public static String generatePassword(PasswordPolicy policy) {
String password = null;
/*
The true max password length is 20 characters. When generating passwords, we want to have a 10 character password because it is easier to tell to users.
So we temporarily drop the max length in the password policy to 10, but without saving the change so actual policy is not impacted when used in other situations.
*/
Map passwordContraints = policy.getPasswordConstraints();
passwordContraints.put("passwordMaxLength","10");
policy.setPasswordConstraints(passwordContraints);
try {
PasswordGenerator gen = new PasswordGenerator(context);
password = gen.generatePassword(policy);
} catch (GeneralException ge) {
pwlogger.error("Exception generating password: " + ge.getMessage());
}
return password;
}
Help Desk password resets and the initial temporary passwords managers give to their new employees will now be easier to relay, but still adhere to the password policy.