diff --git a/.gitignore b/.gitignore
index 5a78575..597cf42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ target/
.classpath
.settings/
bin
+*.iml
+
diff --git a/pom.xml b/pom.xml
index 669b3d2..10435e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
plexus-cipher
- 1.9-SNAPSHOT
+ 2.0-SNAPSHOT
Plexus Cipher: encryption/decryption Component
@@ -32,16 +32,37 @@
7
+ 0.3.4
2020-01-20T18:52:37Z
-
+
+
+
+ javax.inject
+ javax.inject
+ 1
+
+
+ org.eclipse.sisu
+ org.eclipse.sisu.inject
+ ${sisuVersion}
+ provided
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.1
+ 2.22.2
org.eclipse.m2e
@@ -106,7 +127,7 @@
org.eclipse.sisu
sisu-maven-plugin
- 0.3.4
+ ${sisuVersion}
@@ -119,19 +140,4 @@
-
-
- org.sonatype.sisu
- sisu-inject-bean
- 2.6.0
- provided
-
-
- junit
- junit
- 4.13.1
- test
-
-
-
diff --git a/src/main/java/org/sonatype/plexus/components/cipher/Base64.java b/src/main/java/org/sonatype/plexus/components/cipher/Base64.java
index 8420278..1ee726a 100644
--- a/src/main/java/org/sonatype/plexus/components/cipher/Base64.java
+++ b/src/main/java/org/sonatype/plexus/components/cipher/Base64.java
@@ -95,7 +95,7 @@ public class Base64
* The value of undefined encodings is -1
.
*
*/
- private static byte[] base64Alphabet = new byte[BASELENGTH];
+ private static final byte[] base64Alphabet = new byte[BASELENGTH];
/**
*
@@ -110,7 +110,7 @@ public class Base64
* For example, lookUpBase64Alphabet[62]
returns '+'
.
*
*/
- private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
+ private static final byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
// Populating the lookup and character arrays
static {
diff --git a/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java b/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java
index 379eedd..db5a9b6 100644
--- a/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java
+++ b/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (c) 2008 Sonatype, Inc. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
@@ -15,35 +15,38 @@
import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.enterprise.inject.Typed;
import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.eclipse.sisu.Typed;
/**
+ * Default implementation of {@link PlexusCipher}. This class is thread safe.
+ *
* @author Oleg Gusakov
*/
+@Singleton
@Named( "default" )
@Typed( PlexusCipher.class )
public class DefaultPlexusCipher
implements PlexusCipher
{
-
private static final Pattern ENCRYPTED_STRING_PATTERN = Pattern.compile( ".*?[^\\\\]?\\{(.*?[^\\\\])\\}.*" );
private final PBECipher _cipher;
// ---------------------------------------------------------------
public DefaultPlexusCipher()
- throws PlexusCipherException
{
_cipher = new PBECipher();
}
// ---------------------------------------------------------------
+ @Override
public String encrypt( final String str, final String passPhrase )
throws PlexusCipherException
{
@@ -56,6 +59,7 @@ public String encrypt( final String str, final String passPhrase )
}
// ---------------------------------------------------------------
+ @Override
public String encryptAndDecorate( final String str, final String passPhrase )
throws PlexusCipherException
{
@@ -63,6 +67,7 @@ public String encryptAndDecorate( final String str, final String passPhrase )
}
// ---------------------------------------------------------------
+ @Override
public String decrypt( final String str, final String passPhrase )
throws PlexusCipherException
{
@@ -75,6 +80,7 @@ public String decrypt( final String str, final String passPhrase )
}
// ---------------------------------------------------------------
+ @Override
public String decryptDecorated( final String str, final String passPhrase )
throws PlexusCipherException
{
@@ -92,6 +98,7 @@ public String decryptDecorated( final String str, final String passPhrase )
}
// ----------------------------------------------------------------------------
+ @Override
public boolean isEncryptedString( final String str )
{
if ( str == null || str.length() < 1 )
@@ -105,7 +112,7 @@ public boolean isEncryptedString( final String str )
}
// ----------------------------------------------------------------------------
- // -------------------
+ @Override
public String unDecorate( final String str )
throws PlexusCipherException
{
@@ -122,43 +129,39 @@ public String unDecorate( final String str )
}
// ----------------------------------------------------------------------------
- // -------------------
+ @Override
public String decorate( final String str )
{
return ENCRYPTED_STRING_DECORATION_START + ( str == null ? "" : str ) + ENCRYPTED_STRING_DECORATION_STOP;
}
// ---------------------------------------------------------------
- // ---------------------------------------------------------------
- // ***************************************************************
+
/**
* Exploratory part. This method returns all available services types
*/
public static String[] getServiceTypes()
{
- Set result = new HashSet();
+ Set result = new HashSet<>();
// All all providers
Provider[] providers = Security.getProviders();
- for ( int i = 0; i < providers.length; i++ )
- {
+ for (Provider provider : providers) {
// Get services provided by each provider
- Set keys = providers[i].keySet();
- for ( Iterator it = keys.iterator(); it.hasNext(); )
- {
- String key = (String) it.next();
- key = key.split( " " )[0];
-
- if ( key.startsWith( "Alg.Alias." ) )
- {
+ Set