Fix author type conversion (#16560)

diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java
index 57133e6..06c564f 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/auth/AuthorInfo.java
@@ -67,9 +67,22 @@
   }
 
   public static ConfigPhysicalPlanType getConfigPhysicalPlanTypeFromAuthorType(int authorType) {
+    if (authorType < 0) {
+      throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
+    }
     ConfigPhysicalPlanType configPhysicalPlanType;
-    if (authorType == AuthorType.RENAME_USER.ordinal()) {
-      configPhysicalPlanType = ConfigPhysicalPlanType.RenameUser;
+    if (authorType >= AuthorType.RENAME_USER.ordinal()) {
+      AuthorType type = AuthorType.values()[authorType];
+      switch (type) {
+        case RENAME_USER:
+          return ConfigPhysicalPlanType.RenameUser;
+        case UPDATE_USER_MAX_SESSION:
+          return ConfigPhysicalPlanType.UpdateUserMaxSession;
+        case UPDATE_USER_MIN_SESSION:
+          return ConfigPhysicalPlanType.UpdateUserMinSession;
+        default:
+          throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
+      }
     } else {
       configPhysicalPlanType =
           ConfigPhysicalPlanType.values()[authorType + ConfigPhysicalPlanType.CreateUser.ordinal()];
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
index 0f4a164..2269f22 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
@@ -234,7 +234,6 @@
 import org.apache.iotdb.confignode.service.ConfigNode;
 import org.apache.iotdb.consensus.exception.ConsensusException;
 import org.apache.iotdb.db.queryengine.plan.relational.type.AuthorRType;
-import org.apache.iotdb.db.queryengine.plan.statement.AuthorType;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.TSStatusCode;
 
@@ -633,9 +632,6 @@
 
   @Override
   public TSStatus operatePermission(final TAuthorizerReq req) {
-    if (req.getAuthorType() < 0 || req.getAuthorType() >= AuthorType.values().length) {
-      throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
-    }
     ConfigPhysicalPlanType configPhysicalPlanType =
         AuthorInfo.getConfigPhysicalPlanTypeFromAuthorType(req.getAuthorType());
     return configManager.operatePermission(
@@ -654,9 +650,6 @@
 
   @Override
   public TAuthorizerResp queryPermission(final TAuthorizerReq req) {
-    if (req.getAuthorType() < 0 || req.getAuthorType() >= AuthorType.values().length) {
-      throw new IndexOutOfBoundsException("Invalid Author Type ordinal");
-    }
     final PermissionInfoResp dataSet =
         (PermissionInfoResp)
             configManager.queryPermission(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/type/AuthorRType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/type/AuthorRType.java
index ea0d649..4f399f6 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/type/AuthorRType.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/type/AuthorRType.java
@@ -18,6 +18,9 @@
  */
 package org.apache.iotdb.db.queryengine.plan.relational.type;
 
+// When adding new types that need to be converted to ConfigPhysicalPlanType, you can refer to this
+// document:
+// https://docs.google.com/document/d/1WvAyuLn1y988svLl8rGUEcesMkAyH6UTT597KQAVm1A/edit?usp=sharing
 public enum AuthorRType {
   CREATE_USER,
   CREATE_ROLE,
@@ -50,6 +53,8 @@
   LIST_ROLE,
   LIST_USER_PRIV,
   LIST_ROLE_PRIV,
+  UPDATE_MAX_USER_SESSION,
+  UPDATE_MIN_USER_SESSION,
   // Remind to renew the convert codes in ConfigNodeRPCServiceProcessor
   RENAME_USER,
   ACCOUNT_UNLOCK
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java
index 5994944..53b8d1d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/AuthorType.java
@@ -19,7 +19,14 @@
 
 package org.apache.iotdb.db.queryengine.plan.statement;
 
+// If you need to add a new type, you need to add it to the end because the ordinal will be used as
+// offset to calculate ConfigPhysicalPlanType
+// When adding new types that need to be converted to ConfigPhysicalPlanType, you can refer to this
+// document:
+// https://docs.google.com/document/d/1WvAyuLn1y988svLl8rGUEcesMkAyH6UTT597KQAVm1A/edit?usp=sharing
 public enum AuthorType {
+  // The ConfigPhysicalPlanType in this part can be automatically converted according to the offset
+  // in this class
   CREATE_USER,
   CREATE_ROLE,
   DROP_USER,
@@ -35,101 +42,14 @@
   LIST_ROLE,
   LIST_USER_PRIVILEGE,
   LIST_ROLE_PRIVILEGE,
+
   ACCOUNT_UNLOCK,
+
   // Remind to renew the convert codes in ConfigNodeRPCServiceProcessor
+  // If the config node plan is involved, the type defined in following lines needs to manually add
+  // conversion logic
   RENAME_USER,
+  UPDATE_USER_MAX_SESSION,
+  UPDATE_USER_MIN_SESSION,
   ;
-
-  /**
-   * deserialize short number.
-   *
-   * @param i short number
-   * @return NamespaceType
-   */
-  public static AuthorType deserialize(short i) {
-    switch (i) {
-      case 0:
-        return CREATE_USER;
-      case 1:
-        return CREATE_ROLE;
-      case 2:
-        return DROP_USER;
-      case 3:
-        return DROP_ROLE;
-      case 4:
-        return GRANT_ROLE;
-      case 5:
-        return GRANT_USER;
-      case 6:
-        return GRANT_USER_ROLE;
-      case 7:
-        return REVOKE_USER;
-      case 8:
-        return REVOKE_ROLE;
-      case 9:
-        return REVOKE_USER_ROLE;
-      case 10:
-        return UPDATE_USER;
-      case 11:
-        return LIST_USER;
-      case 12:
-        return LIST_ROLE;
-      case 13:
-        return LIST_USER_PRIVILEGE;
-      case 14:
-        return LIST_ROLE_PRIVILEGE;
-      case 15:
-        return RENAME_USER;
-      case 16:
-        return ACCOUNT_UNLOCK;
-      default:
-        return null;
-    }
-  }
-
-  /**
-   * serialize.
-   *
-   * @return short number
-   */
-  public short serialize() {
-    switch (this) {
-      case CREATE_USER:
-        return 0;
-      case CREATE_ROLE:
-        return 1;
-      case DROP_USER:
-        return 2;
-      case DROP_ROLE:
-        return 3;
-      case GRANT_ROLE:
-        return 4;
-      case GRANT_USER:
-        return 5;
-      case GRANT_USER_ROLE:
-        return 6;
-      case REVOKE_USER:
-        return 7;
-      case REVOKE_ROLE:
-        return 8;
-      case REVOKE_USER_ROLE:
-        return 9;
-      case UPDATE_USER:
-        return 10;
-      case LIST_USER:
-        return 11;
-      case LIST_ROLE:
-        return 12;
-      case LIST_USER_PRIVILEGE:
-        return 13;
-      case LIST_ROLE_PRIVILEGE:
-        return 14;
-      case RENAME_USER:
-        return 15;
-      case ACCOUNT_UNLOCK:
-        return 16;
-      default:
-        return -1;
-    }
-  }
 }