Skip to content

Commit c32d618

Browse files
committed
Improve legacy report
1 parent 945d2e6 commit c32d618

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/main/java/org/codehaus/plexus/components/secdispatcher/internal/DefaultSecDispatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ public ValidationResponse validateConfiguration() {
213213
report.computeIfAbsent(ValidationResponse.Level.INFO, k -> new ArrayList<>())
214214
.add("Default dispatcher " + defaultDispatcher + " configuration is valid");
215215

216+
// below is legacy check, that does not affect validity of config, is merely informational
216217
Dispatcher legacy = dispatchers.get(LegacyDispatcher.NAME);
217218
if (legacy == null) {
218219
report.computeIfAbsent(ValidationResponse.Level.INFO, k -> new ArrayList<>())
219220
.add("Legacy dispatcher not present in system");
220221
} else {
221-
// legacy is just "informational" does not affect overall status; merely allows fallback
222222
report.computeIfAbsent(ValidationResponse.Level.INFO, k -> new ArrayList<>())
223223
.add("Legacy dispatcher present in system");
224224
ValidationResponse legacyResponse =

src/main/java/org/codehaus/plexus/components/secdispatcher/internal/dispatchers/LegacyDispatcher.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,27 @@ public SecDispatcher.ValidationResponse validateConfiguration(Map<String, String
111111
HashMap<SecDispatcher.ValidationResponse.Level, List<String>> report = new HashMap<>();
112112
boolean valid = false;
113113
try {
114-
String mp = getMasterPassword();
115-
if (mp == null) {
114+
String mpe = getMasterMasterPasswordFromSettingsSecurityXml();
115+
if (mpe == null) {
116116
report.computeIfAbsent(SecDispatcher.ValidationResponse.Level.ERROR, k -> new ArrayList<>())
117-
.add("Master Password not found");
117+
.add("Legacy configuration not found or does not contain encrypted master password");
118118
} else {
119119
report.computeIfAbsent(SecDispatcher.ValidationResponse.Level.INFO, k -> new ArrayList<>())
120-
.add("Master Password found and decrypted");
121-
valid = true;
120+
.add("Legacy configuration found and contain encrypted master password");
121+
122+
String mp = getMasterPassword();
123+
if (mp == null) {
124+
report.computeIfAbsent(SecDispatcher.ValidationResponse.Level.ERROR, k -> new ArrayList<>())
125+
.add("Master Password not found");
126+
} else {
127+
report.computeIfAbsent(SecDispatcher.ValidationResponse.Level.INFO, k -> new ArrayList<>())
128+
.add("Master Password successfully decrypted");
129+
valid = true;
130+
}
122131
}
123132
} catch (PlexusCipherException e) {
124133
report.computeIfAbsent(SecDispatcher.ValidationResponse.Level.ERROR, k -> new ArrayList<>())
125-
.add("Master Password could not be decrypted");
134+
.add("Master Password decryption failed");
126135
}
127136
return new SecDispatcher.ValidationResponse(getClass().getSimpleName(), valid, report, List.of());
128137
}

0 commit comments

Comments
 (0)