You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/06/28 03:04:47 UTC

[GitHub] [inlong] gong commented on a diff in pull request #4775: [INLONG-4774][Manager] Support auth and encryption key user config

gong commented on code in PR #4775:
URL: https://github.com/apache/inlong/pull/4775#discussion_r907985601


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/UserServiceImpl.java:
##########
@@ -92,9 +96,19 @@ public boolean create(UserInfo userInfo) {
         entity.setDueDate(getOverDueDate(userInfo.getValidDays()));
         entity.setCreateBy(LoginUserUtils.getLoginUserDetail().getUserName());
         entity.setName(username);
-        entity.setSecretKey(userInfo.getSecretKey());
-        entity.setPublicKey(userInfo.getPublicKey());
-        entity.setPrivateKey(userInfo.getPrivateKey());
+        entity.setSecretKey(RandomStringUtils.randomAlphanumeric(8));
+        try {
+            Map<String, String> keyPairs = RSAUtils.generateRSAKeyPairs();
+            String publicKey = keyPairs.get(RSAUtils.PUBLIC_KEY);
+            String privateKey = keyPairs.get(RSAUtils.PRIVATE_KEY);
+            entity.setPublicKey(publicKey);
+            entity.setPrivateKey(privateKey);
+        } catch (Exception e) {
+            String errMsg = String.format("generate rsa key error: {}", e);
+            log.error(errMsg);
+            throw new BusinessException(errMsg);

Review Comment:
   I suggest print full exception stack. 



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org