private void changePassword(String userType,String oldPassword,String newPassword) throws Exception {
  String fileEncPassword=getUserPassword(userType);
  String userDN=getUserDN(userType);
  if ((fileEncPassword == null) || (fileEncPassword.length() == 0) || (userDN == null)|| (userDN.length() == 0)) {
    debug.error("Null password or user DN for user type: " + userType + " from file: "+ configFile);
    throw new XMLException(i18n.getString("dscfg-corrupted-serverconfig"));
  }
  if (!oldPassword.equals(AccessController.doPrivileged(new DecodeAction(fileEncPassword)))) {
    throw new Exception(i18n.getString("dscfg-old-passwd-donot-match"));
  }
  if (isAMSDKConfigured) {
    try {
      new AuthContext(new AuthPrincipal(userDN),newPassword.toCharArray());
      if (debug.messageEnabled()) {
        debug.message("DN: " + userDN + " new password is already updated in the directory");
      }
    }
 catch (    LoginException lee) {
      try {
        AuthContext ac=new AuthContext(new AuthPrincipal(userDN),oldPassword.toCharArray());
        PersistentObject user=UMSObject.getObject(ac.getSSOToken(),new Guid(userDN));
        if (debug.messageEnabled()) {
          debug.message("For DN: " + userDN + " changing password in directory");
        }
        user.setAttribute(new Attr("userPassword",newPassword));
        user.save();
      }
 catch (      LoginException le) {
        if (debug.warningEnabled()) {
          debug.warning("For DN: " + userDN + " new and old passwords donot match with directory");
        }
        throw new Exception(i18n.getString("dscfg-invalid-password") + "\n" + le.getMessage());
      }
    }
  }
  setUserPassword(userType,newPassword);
}

private void changePassword ( String userType , String oldPassword , String newPassword ) throws Exception { String fileEncPassword = getUserPassword ( userType ) ; String userDN = getUserDN ( userType ) ; if ( ( fileEncPassword == null ) || ( fileEncPassword . length ( ) == 0 ) || ( userDN == null ) || ( userDN . length ( ) == 0 ) ) { debug . error ( "Null password or user DN for user type: " + userType + " from file: " + configFile ) ; throw new XMLException ( i18n . getString ( "dscfg-corrupted-serverconfig" ) ) ; } if ( ! oldPassword . equals ( AccessController . doPrivileged ( new DecodeAction ( fileEncPassword ) ) ) ) { throw new Exception ( i18n . getString ( "dscfg-old-passwd-donot-match" ) ) ; } if ( isAMSDKConfigured ) { try { new AuthContext ( new AuthPrincipal ( userDN ) , newPassword . toCharArray ( ) ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "DN: " + userDN + " new password is already updated in the directory" ) ; } } catch ( LoginException lee ) { try { AuthContext ac = new AuthContext ( new AuthPrincipal ( userDN ) , oldPassword . toCharArray ( ) ) ; PersistentObject user = UMSObject . getObject ( ac . getSSOToken ( ) , new Guid ( userDN ) ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "For DN: " + userDN + " changing password in directory" ) ; } user . setAttribute ( new Attr ( "userPassword" , newPassword ) ) ; user . save ( ) ; } catch ( LoginException le ) { if ( debug . warningEnabled ( ) ) { debug . warning ( "For DN: " + userDN + " new and old passwords donot match with directory" ) ; } throw new Exception ( i18n . getString ( "dscfg-invalid-password" ) + "\n" + le . getMessage ( ) ) ; } } } setUserPassword ( userType , newPassword ) ; }
checks and sets the password
