Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public String encrypt(String str, Map<String, String> attr) throws SecDispatcher

@Override
public String decrypt(String str) throws SecDispatcherException, IOException {
if (!isEncryptedString(str)) return str;
if (!isAnyEncryptedString(str)) return str;
String bare = unDecorate(str);
Map<String, String> attr = requireNonNull(stripAttributes(bare));
if (isLegacyEncryptedString(str)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.codehaus.plexus.components.secdispatcher.model.SettingsSecurity;
import org.codehaus.plexus.components.secdispatcher.model.io.stax.SecurityConfigurationStaxWriter;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -172,4 +174,23 @@ protected DefaultSecDispatcher construct() {
new LegacyDispatcher()),
CONFIG_PATH);
}

/**
* Test values created with Maven 3.9.9.
* <p>
* master password: "masterpassword"
* password: "password"
*/
@ParameterizedTest
@ValueSource(
strings = {
"src/test/legacy/legacy-settings-security-1.xml",
"src/test/legacy/legacy-settings-security-2.xml"
})
void legacy(String xml) throws Exception {
System.setProperty("settings.security", xml);
SecDispatcher secDispatcher = construct();
String cleartext = secDispatcher.decrypt("{L6L/HbmrY+cH+sNkphnq3fguYepTpM04WlIXb8nB1pk=}");
assertEquals("password", cleartext);
}
}