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 f66c91e [KARAF-6417] Make users properties file configurable (again)
for AutoEncryptionSupport
f66c91e is described below
commit f66c91ec5bbff97df5e1109e5657a0f64d4f7a00
Author: Grzegorz Grzybek <[email protected]>
AuthorDate: Mon Sep 16 09:27:36 2019 +0200
[KARAF-6417] Make users properties file configurable (again) for
AutoEncryptionSupport
(cherry picked from commit 9d40657e6fcf2d8a94768148405d4fa1400ee0cf)
---
.../modules/properties/AutoEncryptionSupport.java | 20 ++++++++++++++++++--
1 file changed, 18 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 6603308..5e95eb4 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
@@ -19,6 +19,7 @@ package org.apache.karaf.jaas.modules.properties;
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import java.io.Closeable;
+import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
@@ -45,9 +46,17 @@ public class AutoEncryptionSupport implements Runnable,
Closeable {
private EncryptionSupport encryptionSupport;
private ExecutorService executor;
+ private String usersFileName;
+
public AutoEncryptionSupport(Map<String, Object> properties) {
running = true;
encryptionSupport = new EncryptionSupport(properties);
+ Object usersFile = properties.get(PropertiesLoginModule.USER_FILE);
+ if (usersFile instanceof File) {
+ usersFileName = ((File) usersFile).getAbsolutePath();
+ } else if (usersFile != null) {
+ usersFileName = usersFile.toString();
+ }
executor =
Executors.newSingleThreadExecutor(ThreadUtils.namedThreadFactory("encryption"));
executor.execute(this);
}
@@ -67,10 +76,17 @@ public class AutoEncryptionSupport implements Runnable,
Closeable {
WatchService watchService = null;
try {
watchService = FileSystems.getDefault().newWatchService();
- Path dir = Paths.get(System.getProperty("karaf.etc"));
+ Path dir = null;
+ Path file = null;
+ if (usersFileName == null) {
+ dir = Paths.get(System.getProperty("karaf.etc"));
+ file = dir.resolve("users.properties");
+ } else {
+ file = new File(usersFileName).toPath();
+ dir = file.getParent();
+ }
dir.register(watchService, ENTRY_MODIFY);
- Path file = dir.resolve("users.properties");
encryptedPassword(new Properties(file.toFile()));
while (running) {