[Git][java-team/plexus-sec-dispatcher][upstream] New upstream version 2.0

Emmanuel Bourg (@ebourg) gitlab at salsa.debian.org
Wed May 4 00:02:58 BST 2022



Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / plexus-sec-dispatcher


Commits:
24b1624e by Emmanuel Bourg at 2022-05-04T00:02:53+02:00
New upstream version 2.0
- - - - -


9 changed files:

- + .gitignore
- pom.xml
- src/main/java/org/sonatype/plexus/components/sec/dispatcher/DefaultSecDispatcher.java
- src/main/java/org/sonatype/plexus/components/sec/dispatcher/PasswordDecryptor.java
- − src/main/java/org/sonatype/plexus/components/sec/dispatcher/PasswordDecryptorException.java
- src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecDispatcher.java
- src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecDispatcherException.java
- src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecUtil.java
- src/test/java/org/sonatype/plexus/components/sec/dispatcher/SecUtilTest.java


Changes:

=====================================
.gitignore
=====================================
@@ -0,0 +1,7 @@
+target/
+.project
+.classpath
+.settings/
+bin
+.idea
+*.iml


=====================================
pom.xml
=====================================
@@ -1,56 +1,98 @@
 <?xml version="1.0"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
   <parent>
-    <groupId>org.sonatype.spice</groupId>
-    <artifactId>spice-parent</artifactId>
-    <version>12</version>
+    <groupId>org.codehaus.plexus</groupId>
+    <artifactId>plexus</artifactId>
+    <version>8</version>
+    <relativePath />
   </parent>
   
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.sonatype.plexus</groupId>
   <artifactId>plexus-sec-dispatcher</artifactId>
-  <url>http://spice.sonatype.org/${project.artifactId}</url>
-  
+  <version>2.0</version>
+
   <name>Plexus Security Dispatcher Component</name>
-  <version>1.4</version>
-  
+
+  <scm>
+    <connection>scm:git:git at github.com:codehaus-plexus/plexus-sec-dispatcher.git</connection>
+    <developerConnection>scm:git:git at github.com:codehaus-plexus/plexus-sec-dispatcher.git</developerConnection>
+    <url>https://github.com/codehaus-plexus/plexus-sec-dispatcher.git</url>
+    <tag>plexus-sec-dispatcher-2.0</tag>
+  </scm>
+  <issueManagement>
+    <system>jira</system>
+    <url>https://github.com/codehaus-plexus/plexus-sec-dispatcher/issues</url>
+  </issueManagement>
+
   <distributionManagement>
     <site>
-      <id>sonatype.org-sites</id>
-      <url>${spiceSiteBaseUrl}/${project.artifactId}</url>
+      <id>github:gh-pages</id>
+      <url>${project.scm.developerConnection}</url>
     </site>
   </distributionManagement>
-  
+
+  <properties>
+    <javaVersion>7</javaVersion>
+    <sisuVersion>0.3.4</sisuVersion>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>3.4.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-cipher</artifactId>
+      <version>2.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.sisu</groupId>
+      <artifactId>org.eclipse.sisu.inject</artifactId>
+      <version>${sisuVersion}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.13.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>
-        <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-maven-plugin</artifactId>
-        <version>1.3.5</version>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+        <version>${sisuVersion}</version>
         <executions>
           <execution>
             <goals>
-              <goal>descriptor</goal>
+              <goal>main-index</goal>
+              <goal>test-index</goal>
             </goals>
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <artifactId>maven-compiler-plugin
-        </artifactId>
-        <configuration>
-          <source>1.4</source>
-          <target>1.4</target>
-        </configuration>
-      </plugin>
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
+        <version>1.11</version>
         <configuration>
           <version>1.0.0</version>
           <models>
             <model>src/main/mdo/settings-security.mdo</model>
           </models>
+          <useJava5>true</useJava5>
         </configuration>
         <executions>
           <execution>
@@ -65,33 +107,4 @@
       </plugin>
     </plugins>
   </build>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.sonatype.plexus</groupId>
-      <artifactId>plexus-cipher</artifactId>
-      <version>1.4</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-container-default</artifactId>
-      <version>1.0-alpha-9-stable-1</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.2</version>
-    </dependency>
-  </dependencies>
-
-  <scm>
-    <connection>scm:svn:http://svn.sonatype.org/spice/tags/plexus-sec-dispatcher-1.4</connection>
-    <developerConnection>scm:svn:https://svn.sonatype.org/spice/tags/plexus-sec-dispatcher-1.4</developerConnection>
-    <url>http://svn.sonatype.org/spice/tags/plexus-sec-dispatcher-1.4</url>
-  </scm>
 </project>


=====================================
src/main/java/org/sonatype/plexus/components/sec/dispatcher/DefaultSecDispatcher.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,26 +15,30 @@ package org.sonatype.plexus.components.sec.dispatcher;
 
 
 import java.io.BufferedReader;
-import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import org.codehaus.plexus.logging.AbstractLogEnabled;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
 import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
 import org.sonatype.plexus.components.cipher.PlexusCipher;
 import org.sonatype.plexus.components.cipher.PlexusCipherException;
 import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
 
 /**
- * @plexus.component role-hint="default"
- * @author Oleg Gusakov</a>
+ * @author Oleg Gusakov
  */
+ at Singleton
+ at Named
 public class DefaultSecDispatcher
-extends AbstractLogEnabled
-implements SecDispatcher
+  implements SecDispatcher
 {
+    private static final String DEFAULT_CONFIGURATION = "~/.settings-security.xml";
+
     public static final String SYSTEM_PROPERTY_SEC_LOCATION = "settings.security";
     
     public static final String TYPE_ATTR = "type";
@@ -45,32 +49,47 @@ implements SecDispatcher
 
     /**
      * DefaultHandler
-     * 
-     * @plexus.requirement
      */
-    protected PlexusCipher _cipher;
+    protected final PlexusCipher _cipher;
 
     /**
      * All available dispatchers
-     * 
-     * @plexus.requirement role="org.sonatype.plexus.components.sec.dispatcher.PasswordDecryptor"
      */
-    protected Map _decryptors;
+    protected final Map<String, PasswordDecryptor> _decryptors;
 
     /**
-     * 
-     * @plexus.configuration default-value="~/.settings-security.xml"
+     * Configuration file
      */
-    protected String _configurationFile = "~/.settings-security.xml";
+    protected String _configurationFile;
+
+    @Inject
+    public DefaultSecDispatcher( final PlexusCipher _cipher,
+                                 final Map<String, PasswordDecryptor> _decryptors,
+                                 @Named( "${_configurationFile:-" + DEFAULT_CONFIGURATION + "}" )
+                                 final String _configurationFile )
+    {
+        this._cipher = _cipher;
+        this._decryptors = _decryptors;
+        this._configurationFile = _configurationFile;
+    }
+
+    /**
+     * Ctor to be used in tests and other simplified cases (no decryptors and config).
+     */
+    public DefaultSecDispatcher( final PlexusCipher _cipher ) {
+        this( _cipher, new HashMap<String, PasswordDecryptor>(), DEFAULT_CONFIGURATION );
+    }
 
     // ---------------------------------------------------------------
+
+    @Override
     public String decrypt( String str )
         throws SecDispatcherException
     {
         if( ! isEncryptedString( str ) )
             return str;
         
-        String bare = null;
+        String bare;
         
         try
         {
@@ -83,9 +102,9 @@ implements SecDispatcher
         
         try
         {
-            Map attr = stripAttributes( bare );
+            Map<String, String> attr = stripAttributes( bare );
             
-            String res = null;
+            String res;
 
             SettingsSecurity sec = getSec();
             
@@ -97,14 +116,14 @@ implements SecDispatcher
             }
             else
             {
-                String type = (String) attr.get( TYPE_ATTR );
+                String type = attr.get( TYPE_ATTR );
                 
                 if( _decryptors == null )
                     throw new SecDispatcherException( "plexus container did not supply any required dispatchers - cannot lookup "+type );
                 
-                Map conf = SecUtil.getConfig( sec, type );
+                Map<String, String> conf = SecUtil.getConfig( sec, type );
                 
-                PasswordDecryptor dispatcher = (PasswordDecryptor) _decryptors.get( type );
+                PasswordDecryptor dispatcher = _decryptors.get( type );
                 
                 if( dispatcher == null )
                     throw new SecDispatcherException( "no dispatcher for hint "+type );
@@ -135,7 +154,7 @@ implements SecDispatcher
         return str;
     }
     
-    private Map stripAttributes( String str )
+    private Map<String, String> stripAttributes( String str )
     {
         int start = str.indexOf( ATTR_START );
         int stop = str.indexOf( ATTR_STOP );
@@ -146,17 +165,17 @@ implements SecDispatcher
             
             String attrs = str.substring( start+1, stop ).trim();
             
-            if( attrs == null || attrs.length() < 1 )
+            if( attrs.length() < 1 )
                 return null;
             
-            Map res = null;
+            Map<String, String> res = null;
             
             StringTokenizer st = new StringTokenizer( attrs, ", " );
             
             while( st.hasMoreTokens() )
             {
                 if( res == null )
-                    res = new HashMap( st.countTokens() );
+                    res = new HashMap<>( st.countTokens() );
                 
                 String pair = st.nextToken();
                 
@@ -183,7 +202,9 @@ implements SecDispatcher
         
         return null;
     }
+
     //----------------------------------------------------------------------------
+
     private boolean isEncryptedString( String str )
     {
         if( str == null )
@@ -191,7 +212,9 @@ implements SecDispatcher
 
         return _cipher.isEncryptedString( str );
     }
+
     //----------------------------------------------------------------------------
+
     private SettingsSecurity getSec()
     throws SecDispatcherException
     {
@@ -210,7 +233,9 @@ implements SecDispatcher
         
         return sec;
     }
+
     //----------------------------------------------------------------------------
+
     private String getMaster( SettingsSecurity sec )
     throws SecDispatcherException
     {
@@ -238,43 +263,40 @@ implements SecDispatcher
     {
         _configurationFile = file;
     }
-    //----------------------------------------------------------------------------
-    // ***************************************************************
-    /**
-     * Encrytion helper
-     * @throws IOException 
-     */
 
     //---------------------------------------------------------------
+
     private static boolean propertyExists( String [] values, String [] av )
     {
         if( values != null )
         {
-            for( int i=0; i< values.length; i++ )
-            {
-                String p = System.getProperty( values[i] );
-                
-                if( p != null )
+            for ( String item : values ) {
+                String p = System.getProperty( item );
+
+                if ( p != null ) {
                     return true;
+                }
             }
         
             if( av != null )
-                for( int i=0; i< values.length; i++ )
-                    for( int j=0; j< av.length; j++ )
-                    {
-                        if( ("--"+values[i]).equals( av[j] ) )
+                for ( String value : values )
+                    for ( String s : av ) {
+                        if ( ( "--" + value ).equals( s ) ) {
                             return true;
+                        }
                     }
         }
         
         return false;
     }
     
-    private static final void usage()
+    private static void usage()
     {
-        System.out.println("usage: java -jar ...jar [-m|-p]\n-m: encrypt master password\n-p: encrypt password");
+        System.out.println( "usage: java -jar ...jar [-m|-p]\n-m: encrypt master password\n-p: encrypt password" );
     }
+
     //---------------------------------------------------------------
+
     public static void main( String[] args )
     throws Exception
     {
@@ -291,7 +313,9 @@ implements SecDispatcher
         else
             usage();
     }
+
     //---------------------------------------------------------------
+
     private static void show( boolean showMaster )
     throws Exception
     {
@@ -309,9 +333,8 @@ implements SecDispatcher
         System.out.println("\n");
         
         DefaultPlexusCipher dc = new DefaultPlexusCipher();
-        DefaultSecDispatcher dd = new DefaultSecDispatcher();
-        dd._cipher = dc;
-        
+        DefaultSecDispatcher dd = new DefaultSecDispatcher( dc );
+
         if( showMaster )
             System.out.println( dc.encryptAndDecorate( pass, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) );
         else
@@ -320,6 +343,4 @@ implements SecDispatcher
             System.out.println( dc.encryptAndDecorate( pass, dd.getMaster(sec) ) );
         }
     }
-    //---------------------------------------------------------------
-    //---------------------------------------------------------------
 }


=====================================
src/main/java/org/sonatype/plexus/components/sec/dispatcher/PasswordDecryptor.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,
@@ -24,8 +24,6 @@ import java.util.Map;
  */
 public interface PasswordDecryptor
 {
-    public static String ROLE = PasswordDecryptor.class.getName();
-
     /**
      * decrypt given encrypted string
      * 
@@ -36,6 +34,5 @@ public interface PasswordDecryptor
      * 
      * @throws SecDispatcherException
      */
-    String decrypt( String str, Map attributes, Map config )
-    throws SecDispatcherException;
+    String decrypt( String str, Map attributes, Map config ) throws SecDispatcherException;
 }


=====================================
src/main/java/org/sonatype/plexus/components/sec/dispatcher/PasswordDecryptorException.java deleted
=====================================
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2008 Sonatype, Inc. All rights reserved.
- *
- * This program is licensed to you under the Apache License Version 2.0,
- * and you may not use this file except in compliance with the Apache License Version 2.0.
- * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the Apache License Version 2.0 is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
- */
- 
-package org.sonatype.plexus.components.sec.dispatcher;
-
-/**
- *
- *
- * @author Oleg Gusakov
- * @version $Id$
- *
- */
-public class PasswordDecryptorException
-    extends Exception
-{
-
-    /**
-     * 
-     */
-    public PasswordDecryptorException()
-    {
-        // TODO Auto-generated constructor stub
-    }
-
-    /**
-     * @param message
-     */
-    public PasswordDecryptorException( String message )
-    {
-        super( message );
-        // TODO Auto-generated constructor stub
-    }
-
-    /**
-     * @param cause
-     */
-    public PasswordDecryptorException( Throwable cause )
-    {
-        super( cause );
-        // TODO Auto-generated constructor stub
-    }
-
-    /**
-     * @param message
-     * @param cause
-     */
-    public PasswordDecryptorException( String message, Throwable cause )
-    {
-        super( message, cause );
-        // TODO Auto-generated constructor stub
-    }
-
-}


=====================================
src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecDispatcher.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,
@@ -13,19 +13,16 @@
  
 package org.sonatype.plexus.components.sec.dispatcher;
 
-
 /**
- * This component descrypts a string, passed to it
+ * This component decrypts a string, passed to it
  * 
  * @author Oleg Gusakov
  */
 public interface SecDispatcher
 {
-    public static String ROLE = SecDispatcher.class.getName();
-    
-    public static final String [] SYSTEM_PROPERTY_MASTER_PASSWORD = new String [] {"settings.master.password","settings-master-password"};
+    String [] SYSTEM_PROPERTY_MASTER_PASSWORD = new String [] {"settings.master.password","settings-master-password"};
     
-    public static final String [] SYSTEM_PROPERTY_SERVER_PASSWORD = new String [] {"settings.server.password","settings-server-password"};
+    String [] SYSTEM_PROPERTY_SERVER_PASSWORD = new String [] {"settings.server.password","settings-server-password"};
 
     /**
      * decrypt given encrypted string
@@ -34,6 +31,5 @@ public interface SecDispatcher
      * @return decrypted string
      * @throws SecDispatcherException
      */
-    String decrypt( String str )
-    throws SecDispatcherException;
+    String decrypt( String str ) throws SecDispatcherException;
 }


=====================================
src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecDispatcherException.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,
@@ -16,11 +16,6 @@ package org.sonatype.plexus.components.sec.dispatcher;
 public class SecDispatcherException
     extends Exception
 {
-
-    public SecDispatcherException()
-    {
-    }
-
     public SecDispatcherException( String message )
     {
         super( message );
@@ -35,5 +30,4 @@ public class SecDispatcherException
     {
         super( message, cause );
     }
-
 }


=====================================
src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecUtil.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,
@@ -13,14 +13,11 @@
  
 package org.sonatype.plexus.components.sec.dispatcher;
 
-import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -76,7 +73,7 @@ public class SecUtil
     }
     //---------------------------------------------------------------------------------------------------------------
     private static InputStream toStream( String resource )
-    throws MalformedURLException, IOException
+    throws IOException
     {
       if( resource == null )
         return null;
@@ -88,53 +85,46 @@ public class SecUtil
           String protocol = resource.substring( 0, ind );
           resource = resource.substring( ind + PROTOCOL_DELIM_LEN );
 
-          for( int i=0; i<URL_PROTOCOLS.length; i++ )
-          {
-              String p = URL_PROTOCOLS[i];
-              
-              if( protocol.regionMatches( true, 0, p, 0, p.length() ) )
-                return new URL( p+PROTOCOL_DELIM+resource).openStream();
+          for ( String p : URL_PROTOCOLS ) {
+              if ( protocol.regionMatches( true, 0, p, 0, p.length() ) ) {
+                  return new URL( p + PROTOCOL_DELIM + resource ).openStream();
+              }
           }
       }
 
-      return new FileInputStream( new File(resource) );
+      return new FileInputStream( resource );
     }
     //---------------------------------------------------------------------------------------------------------------
-    public static Map getConfig( SettingsSecurity sec, String name )
+    public static Map<String, String> getConfig( SettingsSecurity sec, String name )
     {
         if( name == null )
             return null;
         
-        List cl = sec.getConfigurations();
+        List<Config> cl = sec.getConfigurations();
         
-        if( cl == null )
+        if( cl == null || cl.isEmpty() )
             return null;
-        
-        for( Iterator i = cl.iterator(); i.hasNext(); )
-        {
-            Config cf = (Config) i.next();
-            
-            if( !name.equals( cf.getName() ) )
+
+        for ( Config cf : cl ) {
+            if ( !name.equals( cf.getName() ) ) {
                 continue;
-            
-            List pl = cf.getProperties();
-            
-            if( pl == null || pl.isEmpty() )
+            }
+
+            List<ConfigProperty> pl = cf.getProperties();
+
+            if ( pl == null || pl.isEmpty() ) {
                 return null;
-            
-            Map res = new HashMap( pl.size() );
+            }
 
-            for( Iterator j = pl.iterator(); j.hasNext(); )
-            {
-                ConfigProperty p = (ConfigProperty) j.next();
-                
+            Map<String, String> res = new HashMap<>( pl.size() );
+
+            for ( ConfigProperty p : pl ) {
                 res.put( p.getName(), p.getValue() );
             }
-            
+
             return res;
         }
         
         return null;
     }
-    //---------------------------------------------------------------------------------------------------------------
 }


=====================================
src/test/java/org/sonatype/plexus/components/sec/dispatcher/SecUtilTest.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,
@@ -18,7 +18,8 @@ package org.sonatype.plexus.components.sec.dispatcher;
 import java.io.FileWriter;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
 import org.sonatype.plexus.components.sec.dispatcher.model.Config;
@@ -26,6 +27,9 @@ import org.sonatype.plexus.components.sec.dispatcher.model.ConfigProperty;
 import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
 import org.sonatype.plexus.components.sec.dispatcher.model.io.xpp3.SecurityConfigurationXpp3Writer;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 /**
  *
  *
@@ -34,7 +38,6 @@ import org.sonatype.plexus.components.sec.dispatcher.model.io.xpp3.SecurityConfi
  *
  */
 public class SecUtilTest
-extends TestCase
 {
     String _pw = "{1wQaa6S/o8MH7FnaTNL53XmhT5O0SEGXQi3gC49o6OY=}";
     
@@ -47,8 +50,9 @@ extends TestCase
     String _propName = "pname";
     
     String _propVal = "pval";
-    
-    protected void setUp()
+
+    @Before
+    public void prepare()
     throws Exception
     {
         System.setProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, "./target/sec.xml" );
@@ -78,6 +82,7 @@ extends TestCase
         new SecurityConfigurationXpp3Writer().write( new FileWriter("./target/sec1.xml"), sec );
     }
 
+    @Test
     public void testRead()
     throws Exception
     {
@@ -96,12 +101,12 @@ extends TestCase
         assertEquals( _propVal, conf.get( _propName ) );
     }
 
+    @Test
     public void testDecrypt()
     throws Exception
     {
-        DefaultSecDispatcher sd = new DefaultSecDispatcher();
-        sd._cipher = new DefaultPlexusCipher();
-        
+        DefaultSecDispatcher sd = new DefaultSecDispatcher(new DefaultPlexusCipher());
+
         String pass = sd.decrypt( _encrypted );
         
         assertNotNull( pass );



View it on GitLab: https://salsa.debian.org/java-team/plexus-sec-dispatcher/-/commit/24b1624e2f7b91ae1fe14757a87e7bba08afca85

-- 
View it on GitLab: https://salsa.debian.org/java-team/plexus-sec-dispatcher/-/commit/24b1624e2f7b91ae1fe14757a87e7bba08afca85
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20220503/96a5a492/attachment.htm>


More information about the pkg-java-commits mailing list