|
18 | 18 | */
|
19 | 19 | package org.codehaus.plexus.components.secdispatcher.internal.sources;
|
20 | 20 |
|
21 |
| -import org.codehaus.plexus.components.secdispatcher.MasterSourceMeta; |
22 |
| -import org.codehaus.plexus.components.secdispatcher.SecDispatcher; |
23 |
| -import org.codehaus.plexus.components.secdispatcher.SecDispatcherException; |
24 |
| - |
25 | 21 | import javax.inject.Named;
|
26 | 22 | import javax.inject.Singleton;
|
| 23 | + |
27 | 24 | import java.io.IOException;
|
28 | 25 | import java.nio.file.Files;
|
29 | 26 | import java.nio.file.Path;
|
|
32 | 29 | import java.util.Map;
|
33 | 30 | import java.util.Optional;
|
34 | 31 |
|
| 32 | +import org.codehaus.plexus.components.secdispatcher.MasterSourceMeta; |
| 33 | +import org.codehaus.plexus.components.secdispatcher.SecDispatcher; |
| 34 | +import org.codehaus.plexus.components.secdispatcher.SecDispatcherException; |
| 35 | + |
35 | 36 | /**
|
36 | 37 | * Password source that uses a plain file with plaintext master password (residing on things like an encrypted pen-drive
|
37 | 38 | * or partition). Idea is to "delegate" all the security to that data carrier (for example, it may ask for permission
|
@@ -96,7 +97,11 @@ private String readFile(String transformed) throws SecDispatcherException {
|
96 | 97 | Path file = Paths.get(transformed);
|
97 | 98 | if (file.isAbsolute() && Files.exists(file)) {
|
98 | 99 | try {
|
99 |
| - return Files.readAllLines(file).stream().filter(l -> l.startsWith("#")).map(String::trim).findFirst().orElse(null); |
| 100 | + return Files.readAllLines(file).stream() |
| 101 | + .filter(l -> l.startsWith("#")) |
| 102 | + .map(String::trim) |
| 103 | + .findFirst() |
| 104 | + .orElse(null); |
100 | 105 | } catch (IOException e) {
|
101 | 106 | throw new SecDispatcherException("Failed to read file '" + transformed + "'", e);
|
102 | 107 | }
|
|
0 commit comments