ColinLeeo commented on code in PR #13158:
URL: https://github.com/apache/iotdb/pull/13158#discussion_r1923251532


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/user/LocalFileUserAccessor.java:
##########
@@ -193,135 +180,62 @@ public User loadUser(String username) throws IOException 
{
             }
           }
         }
-        user.setRoleList(roleList);
+        user.setRoleSet(roleList);
         return user;
       }
-    } catch (Exception e) {
-      throw new IOException(e);
-    } finally {
-      strBufferLocal.remove();
-    }
-  }
-
-  /**
-   * Serialize the user object to a temp file, then replace the old user file 
with the new file.
-   *
-   * @param user The user object that is to be saved.
-   */
-  @Override
-  public void saveUser(User user) throws IOException {
-    File userProfile =
-        SystemFileFactory.INSTANCE.getFile(
-            userDirPath
-                + File.separator
-                + user.getName()
-                + IoTDBConstant.PROFILE_SUFFIX
-                + TEMP_SUFFIX);
-
-    try (FileOutputStream fileOutputStream = new FileOutputStream(userProfile);
-        BufferedOutputStream outputStream = new 
BufferedOutputStream(fileOutputStream)) {
-      // for IOTDB 1.2, the username's length will be stored as a negative 
number.
-      byte[] strBuffer = user.getName().getBytes(STRING_ENCODING);
-      IOUtils.writeInt(outputStream, -1 * strBuffer.length, 
encodingBufferLocal);
-      outputStream.write(strBuffer);
-      IOUtils.writeString(outputStream, user.getPassword(), STRING_ENCODING, 
encodingBufferLocal);
-      IOUtils.writeInt(outputStream, user.getAllSysPrivileges(), 
encodingBufferLocal);
-
-      int privilegeNum = user.getPathPrivilegeList().size();
-      for (int i = 0; i < privilegeNum; i++) {
-        PathPrivilege pathPrivilege = user.getPathPrivilegeList().get(i);
-        IOUtils.writePathPrivilege(
-            outputStream, pathPrivilege, STRING_ENCODING, encodingBufferLocal);
+      assert (tag == VERSION);
+      user.setName(IOUtils.readString(dataInputStream, STRING_ENCODING, 
strBufferLocal));
+      user.setPassword(IOUtils.readString(dataInputStream, STRING_ENCODING, 
strBufferLocal));
+      user.setSysPrivilegesWithMask(dataInputStream.readInt());

Review Comment:
   good idea.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to