cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generating shorter IdentityIQ passwords without lowering max length constraint

Generating shorter IdentityIQ passwords without lowering max length constraint

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.

 

  1. The PasswordGenerator class will generate a random password using the passed in PasswordPolicy.
  2. The password will be the length of whatever is set in the 'passwordMaxLength' password constraint.

 

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.

Labels (1)
Comments

Thanks Blake for sharing. My question is: how to apply this method to IIQ so that it works as desired via Manage Access -> Manage Password -> Generate? Is there a place//hook/rule we can inject this function in? Apparently, when clicking the generate button, an REST API call "generatePassword" is made to IIQ.

This does not seem to work on 8.4, changes made like this are persisted to the PasswordPolicy object. Strangely it seems to only persist when running the rule through the debug pages or through an application provisioning policy. This works as expected on Identity provisioning policies. 

Version history
Revision #:
2 of 2
Last update:
‎Aug 02, 2023 12:11 AM
Updated by: