You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/08/23 05:03:02 UTC

[karaf] branch master updated: Fixing encrypted passwork regression

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

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new a452e54  Fixing encrypted passwork regression
     new 1659169  Merge pull request #913 from coheigea/password_regression
a452e54 is described below

commit a452e54ce9e499d54c9f61f918e00f5c96cded68
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Thu Aug 22 14:58:14 2019 +0100

    Fixing encrypted passwork regression
---
 .../jaas/modules/properties/AutoEncryptionSupport.java     | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/AutoEncryptionSupport.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/AutoEncryptionSupport.java
index 3819720..6603308 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/AutoEncryptionSupport.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/AutoEncryptionSupport.java
@@ -108,24 +108,34 @@ public class AutoEncryptionSupport implements Runnable, Closeable {
         boolean changed = false;
         for (String userName : users.keySet()) {
             String user = userName;
+            String userInfos = users.get(user);
 
             if (user.startsWith(PropertiesBackingEngine.GROUP_PREFIX)) {
                 continue;
             }
 
             // the password is in the first position
-            String[] infos = users.get(user).split(",");
+            String[] infos = userInfos.split(",");
             String storedPassword = infos[0];
 
             // check if the stored password is flagged as encrypted
             String encryptedPassword = encryptionSupport.encrypt(storedPassword);
             if (!storedPassword.equals(encryptedPassword)) {
                 LOGGER.debug("The password isn't flagged as encrypted, encrypt it.");
+                userInfos = encryptedPassword + ",";
+                for (int i = 1; i < infos.length; i++) {
+                    if (i == (infos.length - 1)) {
+                        userInfos = userInfos + infos[i];
+                    } else {
+                        userInfos = userInfos + infos[i] + ",";
+                    }
+                }
+
                 if (user.contains("\\")) {
                     users.remove(user);
                     user = user.replace("\\", "\\\\");
                 }
-                users.put(user, encryptedPassword + "," + String.join(",", infos));
+                users.put(user, userInfos);
                 changed = true;
             }
         }