Skip to content

Commit 981f223

Browse files
committed
Remove this nonsense
1 parent b687a83 commit 981f223

File tree

3 files changed

+5
-59
lines changed

3 files changed

+5
-59
lines changed

src/main/java/org/codehaus/plexus/components/secdispatcher/SecDispatcher.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* @author Oleg Gusakov
2020
*/
2121
public interface SecDispatcher {
22+
String DEFAULT_CONFIGURATION = "~/.m2/settings-security.xml";
23+
String SYSTEM_PROPERTY_CONFIGURATION_LOCATION = "settings.security";
24+
2225
/**
2326
* decrypt given encrypted string
2427
*

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

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@
1717
import javax.inject.Named;
1818
import javax.inject.Singleton;
1919

20-
import java.io.BufferedReader;
21-
import java.io.InputStreamReader;
2220
import java.net.URI;
2321
import java.net.URISyntaxException;
24-
import java.util.Collections;
2522
import java.util.HashMap;
2623
import java.util.Map;
2724
import java.util.StringTokenizer;
2825

2926
import org.codehaus.plexus.components.cipher.PlexusCipher;
3027
import org.codehaus.plexus.components.cipher.PlexusCipherException;
31-
import org.codehaus.plexus.components.cipher.internal.DefaultPlexusCipher;
3228
import org.codehaus.plexus.components.secdispatcher.SecDispatcher;
3329
import org.codehaus.plexus.components.secdispatcher.SecDispatcherException;
3430
import org.codehaus.plexus.components.secdispatcher.model.SettingsSecurity;
@@ -41,10 +37,6 @@
4137
@Singleton
4238
@Named
4339
public class DefaultSecDispatcher implements SecDispatcher {
44-
public static final String DEFAULT_CONFIGURATION = "~/.m2/settings-security.xml";
45-
46-
public static final String SYSTEM_PROPERTY_SEC_LOCATION = "settings.security";
47-
4840
public static final String TYPE_ATTR = "type";
4941
public static final char ATTR_START = '[';
5042
public static final char ATTR_STOP = ']';
@@ -166,7 +158,7 @@ private boolean isEncryptedString(String str) {
166158
// ----------------------------------------------------------------------------
167159

168160
private SettingsSecurity getSec() throws SecDispatcherException {
169-
String location = System.getProperty(SYSTEM_PROPERTY_SEC_LOCATION, getConfigurationFile());
161+
String location = System.getProperty(SYSTEM_PROPERTY_CONFIGURATION_LOCATION, getConfigurationFile());
170162
String realLocation =
171163
location.charAt(0) == '~' ? System.getProperty("user.home") + location.substring(1) : location;
172164

@@ -226,53 +218,4 @@ private static boolean propertyExists(String[] values, String[] av) {
226218

227219
return false;
228220
}
229-
230-
private static void usage() {
231-
System.out.println("usage: java -jar ...jar [-m|-p]\n-m: encrypt master password\n-p: encrypt password");
232-
}
233-
234-
// ---------------------------------------------------------------
235-
236-
private static final String[] SYSTEM_PROPERTY_MASTER_PASSWORD =
237-
new String[] {"settings.master.password", "settings-master-password"};
238-
239-
private static final String[] SYSTEM_PROPERTY_SERVER_PASSWORD =
240-
new String[] {"settings.server.password", "settings-server-password"};
241-
242-
public static void main(String[] args) throws Exception {
243-
if (args == null || args.length < 1) {
244-
usage();
245-
return;
246-
}
247-
248-
if ("-m".equals(args[0]) || propertyExists(SYSTEM_PROPERTY_MASTER_PASSWORD, args)) show(true);
249-
else if ("-p".equals(args[0]) || propertyExists(SYSTEM_PROPERTY_SERVER_PASSWORD, args)) show(false);
250-
else usage();
251-
}
252-
253-
// ---------------------------------------------------------------
254-
255-
private static void show(boolean showMaster) throws Exception {
256-
if (showMaster) System.out.print("\nsettings master password\n");
257-
else System.out.print("\nsettings server password\n");
258-
259-
System.out.print("enter password: ");
260-
261-
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
262-
263-
String pass = r.readLine();
264-
265-
System.out.println("\n");
266-
267-
DefaultPlexusCipher dc = new DefaultPlexusCipher();
268-
DefaultSecDispatcher dd =
269-
new DefaultSecDispatcher(dc, Collections.emptyMap(), Collections.emptyMap(), DEFAULT_CONFIGURATION);
270-
271-
if (showMaster)
272-
System.out.println(dc.encryptAndDecorate(pass, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION));
273-
else {
274-
SettingsSecurity sec = dd.getSec();
275-
System.out.println(dc.encryptAndDecorate(pass, dd.getMaster(sec)));
276-
}
277-
}
278221
}

src/test/java/org/codehaus/plexus/components/secdispatcher/internal/SecUtilTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private void saveSec(String masterSource) throws Exception {
7474

7575
@BeforeEach
7676
public void prepare() throws Exception {
77-
System.setProperty(DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, "./target/sec.xml");
77+
System.setProperty(DefaultSecDispatcher.SYSTEM_PROPERTY_CONFIGURATION_LOCATION, "./target/sec.xml");
7878

7979
SettingsSecurity sec = new SettingsSecurity();
8080

0 commit comments

Comments
 (0)