OIM Create Password Policy API


  1. package com.oimacademy.password;
  2. import com.oimacademy.connection.OIMConnection;
  3. import oracle.iam.passwordmgmt.api.PasswordMgmtService;
  4. import oracle.iam.passwordmgmt.vo.PasswordPolicyInfo;
  5. public class PasswordPolicy {
  6.  static PasswordMgmtService passwordmgmtService = OIMConnection.getConnection().getService(PasswordMgmtService.class);
  7.  public static void main(String[] args) throws Exception {
  8.   // TODO Auto-generated method stub
  9.   passwordPolicyCreate();
  10.   //deletePolicy("PasswordPolicy90");
  11.  } 
  12.  public static String passwordPolicyCreate() throws Exception {
  13.   //Create Password Policy
  14.         String name = "PasswordPolicy1" ; 
  15.         PasswordPolicyInfo passPolicyInfo = new PasswordPolicyInfo();
  16.         passPolicyInfo.setName(name);
  17.         passPolicyInfo.setShortDesc(name + " description");
  18.         passPolicyInfo.setPasswordExpiresAfterInDays(90);               
  19.         PasswordPolicyInfo searchPassPolicyInfo = new PasswordPolicyInfo();
  20.         passPolicyInfo = passwordmgmtService.create(passPolicyInfo);        
  21.         searchPassPolicyInfo = passwordmgmtService.getDetails(passPolicyInfo.getName());                 
  22.         System.out.println("Password Policy Key -> " +passPolicyInfo.getId()) ;
  23.         System.out.println("Search Password Policy Key -> "+searchPassPolicyInfo.getId()) ;  
  24.         System.out.println("getPasswordExpiresAfterInDays - >"+passPolicyInfo.getPasswordExpiresAfterInDays());
  25.         return passPolicyInfo.getId();
  26.  } 
  27.  public static void deletePolicy(String name){
  28.   // passwordmgmtService.delete(name) ;
  29.   PasswordPolicyInfo passPolicyInfo = new PasswordPolicyInfo();
  30.      passPolicyInfo.setPasswordExpiresAfterInDays(null);
  31.   passPolicyInfo.setName("PasswordPolicy1");
  32.   passwordmgmtService.update(passPolicyInfo);
  33.    passPolicyInfo=passwordmgmtService.getDetails(passPolicyInfo.getName());
  34.    System.out.println(passPolicyInfo.getId());
  35.    System.out.println(passPolicyInfo.getPasswordExpiresAfterInDays());
  36.  }
  37. }


No comments:

Post a Comment