This is an automated email from the ASF dual-hosted git repository.

shuwenwei pushed a commit to branch sync-generic-changes
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 0789228bff2796719a198541dbab78976a42c1da
Author: shuwenwei <[email protected]>
AuthorDate: Thu Sep 17 16:03:14 2026 +0800

    [Auth] Remove unused Role/User serialize and deserialize
---
 .../org/apache/iotdb/db/auth/entity/RoleTest.java  | 84 ----------------------
 .../org/apache/iotdb/db/auth/entity/UserTest.java  | 53 --------------
 .../org/apache/iotdb/commons/auth/entity/Role.java | 64 -----------------
 .../org/apache/iotdb/commons/auth/entity/User.java | 64 -----------------
 4 files changed, 265 deletions(-)

diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/entity/RoleTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/entity/RoleTest.java
deleted file mode 100644
index 270dd8af689..00000000000
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/entity/RoleTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth.entity;
-
-import org.apache.iotdb.commons.auth.entity.DatabasePrivilege;
-import org.apache.iotdb.commons.auth.entity.PathPrivilege;
-import org.apache.iotdb.commons.auth.entity.PrivilegeType;
-import org.apache.iotdb.commons.auth.entity.Role;
-import org.apache.iotdb.commons.auth.entity.TablePrivilege;
-import org.apache.iotdb.commons.conf.IoTDBConstant;
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Collections;
-
-public class RoleTest {
-
-  @Test
-  public void testRole_InitAndSerialize() throws IllegalPathException {
-    Role role = new Role("role");
-    PathPrivilege pathPrivilege = new PathPrivilege(new 
PartialPath("root.ln"));
-    role.setPrivilegeList(Collections.singletonList(pathPrivilege));
-    role.grantPathPrivilege(new PartialPath("root.ln"), 
PrivilegeType.READ_SCHEMA, true);
-    role.grantPathPrivilege(new PartialPath("root.ln"), 
PrivilegeType.READ_DATA, false);
-
-    Assert.assertEquals(
-        "Role{name='role', pathPrivilegeList=[root.ln : "
-            + "READ_DATA READ_SCHEMA_with_grant_option], 
systemPrivilegeSet=[], "
-            + "AnyScopePrivilegeMap=[], objectPrivilegeSet={}}",
-        role.toString());
-    Role role1 = new Role("role1");
-    role1.deserialize(role.serialize());
-    Assert.assertEquals(
-        "Role{name='role', pathPrivilegeList=[root.ln : "
-            + "READ_DATA READ_SCHEMA_with_grant_option], 
systemPrivilegeSet=[], "
-            + "AnyScopePrivilegeMap=[], objectPrivilegeSet={}}",
-        role1.toString());
-
-    Role admin = new Role("root");
-    PartialPath rootPath = new PartialPath(IoTDBConstant.PATH_ROOT + ".**");
-    PathPrivilege pathPri = new PathPrivilege(rootPath);
-    DatabasePrivilege databasePrivilege = new DatabasePrivilege("testDB");
-    TablePrivilege tablePrivilege = new TablePrivilege("testTable");
-    databasePrivilege.getTablePrivilegeMap().put("testTable", tablePrivilege);
-    for (PrivilegeType item : PrivilegeType.values()) {
-      if (item.isSystemPrivilege()) {
-        admin.getSysPrivilege().add(item);
-        admin.getSysPriGrantOpt().add(item);
-      } else if (item.isPathPrivilege()) {
-        pathPri.grantPrivilege(item, true);
-      } else if (item.isRelationalPrivilege()) {
-        databasePrivilege.grantDBPrivilege(item);
-        databasePrivilege.grantDBGrantOption(item);
-        databasePrivilege.grantTablePrivilege("testTable", item);
-        databasePrivilege.grantTableGrantOption("testTable", item);
-        admin.grantAnyScopePrivilege(item, true);
-      }
-    }
-    admin.getDBScopePrivilegeMap().put("testDB", databasePrivilege);
-    admin.getPathPrivilegeList().add(pathPri);
-    Assert.assertEquals(
-        "Role{name='root', pathPrivilegeList=[root.** : 
READ_DATA_with_grant_option WRITE_DATA_with_grant_option 
READ_SCHEMA_with_grant_option WRITE_SCHEMA_with_grant_option], 
systemPrivilegeSet=[USE_MODEL_with_grant_option, MAINTAIN_with_grant_option, 
EXTEND_TEMPLATE_with_grant_option, SYSTEM_with_grant_option, 
MANAGE_DATABASE_with_grant_option, MANAGE_USER_with_grant_option, 
USE_TRIGGER_with_grant_option, USE_CQ_with_grant_option, 
SECURITY_with_grant_option, USE_PIPE_with_grant_option, [...]
-        admin.toString());
-  }
-}
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/entity/UserTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/entity/UserTest.java
deleted file mode 100644
index 82e7d8f15b1..00000000000
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/auth/entity/UserTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.auth.entity;
-
-import org.apache.iotdb.commons.auth.entity.PathPrivilege;
-import org.apache.iotdb.commons.auth.entity.PrivilegeType;
-import org.apache.iotdb.commons.auth.entity.User;
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Collections;
-
-public class UserTest {
-
-  @Test
-  public void testUser() throws IllegalPathException {
-    User user = new User("user", "password123456");
-    PathPrivilege pathPrivilege = new PathPrivilege(new 
PartialPath("root.ln"));
-    user.setPrivilegeList(Collections.singletonList(pathPrivilege));
-    user.setPathPrivileges(
-        new PartialPath("root.ln"), 
Collections.singleton(PrivilegeType.WRITE_DATA));
-    Assert.assertEquals(
-        "User{id=-1, name='user', pathPrivilegeList=[root.ln : WRITE_DATA], "
-            + "sysPrivilegeSet=[], AnyScopePrivilegeMap=[], 
objectPrivilegeMap={}, roleList=[], isOpenIdUser=false}",
-        user.toString());
-    User user1 = new User("user1", "password1");
-    user1.deserialize(user.serialize());
-    Assert.assertEquals(
-        "User{id=-1, name='user', pathPrivilegeList=[root.ln : WRITE_DATA], "
-            + "sysPrivilegeSet=[], AnyScopePrivilegeMap=[], 
objectPrivilegeMap={}, roleList=[], isOpenIdUser=false}",
-        user1.toString());
-    Assert.assertEquals(user1, user);
-  }
-}
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/Role.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/Role.java
index e5296dca60c..4c1a4baa78f 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/Role.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/Role.java
@@ -21,17 +21,12 @@ package org.apache.iotdb.commons.auth.entity;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.utils.AuthUtils;
-import org.apache.iotdb.commons.utils.SerializeUtils;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.confignode.rpc.thrift.TDBPrivilege;
 import org.apache.iotdb.confignode.rpc.thrift.TPathPrivilege;
 import org.apache.iotdb.confignode.rpc.thrift.TRoleResp;
 import org.apache.iotdb.confignode.rpc.thrift.TTablePrivilege;
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -621,65 +616,6 @@ public class Role {
         objectPrivilegeMap);
   }
 
-  public ByteBuffer serialize() {
-    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-    DataOutputStream dataOutputStream = new 
DataOutputStream(byteArrayOutputStream);
-
-    SerializeUtils.serialize(name, dataOutputStream);
-
-    try {
-      SerializeUtils.serializePrivilegeTypeSet(sysPrivilegeSet, 
dataOutputStream);
-      SerializeUtils.serializePrivilegeTypeSet(sysPriGrantOpt, 
dataOutputStream);
-      dataOutputStream.writeInt(pathPrivilegeList.size());
-      for (PathPrivilege pathPrivilege : pathPrivilegeList) {
-        dataOutputStream.write(pathPrivilege.serialize().array());
-      }
-      SerializeUtils.serializePrivilegeTypeSet(anyScopePrivilegeSet, 
dataOutputStream);
-      SerializeUtils.serializePrivilegeTypeSet(anyScopePrivilegeGrantOptSet, 
dataOutputStream);
-      dataOutputStream.writeInt(objectPrivilegeMap.size());
-      for (Map.Entry<String, DatabasePrivilege> item : 
objectPrivilegeMap.entrySet()) {
-        SerializeUtils.serialize(item.getKey(), dataOutputStream);
-        dataOutputStream.write(item.getValue().serialize().array());
-      }
-    } catch (IOException e) {
-      // unreachable
-    }
-
-    return ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
-  }
-
-  public void deserialize(ByteBuffer buffer) {
-    name = SerializeUtils.deserializeString(buffer);
-    int sysPrivilegeSize = buffer.getInt();
-    sysPrivilegeSet = new HashSet<>();
-    for (int i = 0; i < sysPrivilegeSize; i++) {
-      sysPrivilegeSet.add(PrivilegeType.values()[buffer.getInt()]);
-    }
-    int sysPriGrantOptSize = buffer.getInt();
-    sysPriGrantOpt = new HashSet<>();
-    for (int i = 0; i < sysPriGrantOptSize; i++) {
-      sysPriGrantOpt.add(PrivilegeType.values()[buffer.getInt()]);
-    }
-    int privilegeListSize = buffer.getInt();
-    pathPrivilegeList = new ArrayList<>(privilegeListSize);
-    for (int i = 0; i < privilegeListSize; i++) {
-      PathPrivilege pathPrivilege = new PathPrivilege();
-      pathPrivilege.deserialize(buffer);
-      pathPrivilegeList.add(pathPrivilege);
-    }
-
-    SerializeUtils.deserializePrivilegeTypeSet(anyScopePrivilegeSet, buffer);
-    SerializeUtils.deserializePrivilegeTypeSet(anyScopePrivilegeGrantOptSet, 
buffer);
-
-    int objectPrivilegesSize = buffer.getInt();
-    for (int i = 0; i < objectPrivilegesSize; i++) {
-      DatabasePrivilege databasePrivilege = new DatabasePrivilege();
-      String objectName = SerializeUtils.deserializeString(buffer);
-      databasePrivilege.deserialize(buffer);
-      this.objectPrivilegeMap.put(objectName, databasePrivilege);
-    }
-  }
-
   @Override
   public String toString() {
     return "Role{"
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/User.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/User.java
index 0bebeaf8e06..16575e505eb 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/User.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/entity/User.java
@@ -18,18 +18,11 @@
  */
 package org.apache.iotdb.commons.auth.entity;
 
-import org.apache.iotdb.commons.utils.SerializeUtils;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.confignode.rpc.thrift.TListUserInfo;
 import org.apache.iotdb.confignode.rpc.thrift.TUserResp;
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Objects;
 import java.util.Set;
 
@@ -187,63 +180,6 @@ public class User extends Role {
         isOpenIdUser);
   }
 
-  @Override
-  public ByteBuffer serialize() {
-    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-    DataOutputStream dataOutputStream = new 
DataOutputStream(byteArrayOutputStream);
-
-    SerializeUtils.serialize(super.getName(), dataOutputStream);
-    SerializeUtils.serialize(password, dataOutputStream);
-
-    try {
-      dataOutputStream.writeInt(super.getSysPrivilege().size());
-      for (PrivilegeType item : super.getSysPrivilege()) {
-        dataOutputStream.writeInt(item.ordinal());
-      }
-      dataOutputStream.writeInt(super.getSysPriGrantOpt().size());
-      for (PrivilegeType item : super.getSysPriGrantOpt()) {
-        dataOutputStream.writeInt(item.ordinal());
-      }
-      dataOutputStream.writeInt(super.getPathPrivilegeList().size());
-      for (PathPrivilege pathPrivilege : super.getPathPrivilegeList()) {
-        dataOutputStream.write(pathPrivilege.serialize().array());
-      }
-    } catch (IOException e) {
-      // unreachable
-    }
-    SerializeUtils.serializeStringList(new ArrayList<>(roleSet), 
dataOutputStream);
-
-    return ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
-  }
-
-  @Override
-  public void deserialize(ByteBuffer buffer) {
-    super.setName(SerializeUtils.deserializeString(buffer));
-    password = SerializeUtils.deserializeString(buffer);
-    int systemPriSize = buffer.getInt();
-    Set<PrivilegeType> sysPri = new HashSet<>();
-    for (int i = 0; i < systemPriSize; i++) {
-      sysPri.add(PrivilegeType.values()[buffer.getInt()]);
-    }
-    super.setSysPrivilegeSet(sysPri);
-    int sysPriGrantOptSize = buffer.getInt();
-    Set<PrivilegeType> grantOpt = new HashSet<>();
-    for (int i = 0; i < sysPriGrantOptSize; i++) {
-      grantOpt.add(PrivilegeType.values()[buffer.getInt()]);
-    }
-    super.setSysPriGrantOpt(grantOpt);
-
-    int privilegeListSize = buffer.getInt();
-    List<PathPrivilege> privilegeList = new ArrayList<>(privilegeListSize);
-    for (int i = 0; i < privilegeListSize; i++) {
-      PathPrivilege pathPrivilege = new PathPrivilege();
-      pathPrivilege.deserialize(buffer);
-      privilegeList.add(pathPrivilege);
-    }
-    super.setPrivilegeList(privilegeList);
-    roleSet = new HashSet<>(SerializeUtils.deserializeStringList(buffer));
-  }
-
   /**
    * TestOnly, get the string representation of the user.
    *

Reply via email to