Search code examples
event-handlingchange-passwordoim

How to generate password policy based password in OIM 11gr2ps2


I am creating a event handler to modify user password using OIM UserManager API. But now I need to consider password policy and then generate new password that is compatible with the password policy defined in OIM.

Can you please point to some APIs and Methods which can help here?


Solution

  • import oracle.idm.common.ipf.api.password.RandomPasswordGenerator;
    import oracle.idm.common.ipf.api.password.RandomPasswordGeneratorImpl;
    

    The classes above actually gives handle on the randomly generated password that I was looking for. The code below shows the implementation for the same.

    PasswordPolicyInfo passwordPolicyInfo = ((PasswordMgmtService)Platform.getService(PasswordMgmtService.class)).getApplicablePasswordPolicy(entityId, Boolean.valueOf(false));
    
      RandomPasswordGenerator randomPasswordGenerator = new RandomPasswordGeneratorImpl();
    
      OimPasswordPolicy policy = new OimPasswordPolicy(Utils.getIpfPasswordPolicyInfoVO(passwordPolicyInfo));
      policy.setId(passwordPolicyInfo.getId());
      policy.setName(passwordPolicyInfo.getName());
    
      char[] generatedPassword = randomPasswordGenerator.generatePassword(policy, null);