[Git][java-team/plexus-sec-dispatcher][master] 12 commits: Updated the watch file
Emmanuel Bourg (@ebourg)
gitlab at salsa.debian.org
Wed May 4 00:02:52 BST 2022
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / plexus-sec-dispatcher
Commits:
6bb50776 by Emmanuel Bourg at 2022-05-03T23:58:34+02:00
Updated the watch file
- - - - -
e00b46a4 by Emmanuel Bourg at 2022-05-03T23:58:42+02:00
Standards-Version updated to 4.6.0.1
- - - - -
d2a62092 by Emmanuel Bourg at 2022-05-03T23:58:50+02:00
Switch to debhelper level 13
- - - - -
69e1c9fb by Emmanuel Bourg at 2022-05-04T00:02:22+02:00
Exclude the GitHub files from the upstream tarball
- - - - -
24b1624e by Emmanuel Bourg at 2022-05-04T00:02:53+02:00
New upstream version 2.0
- - - - -
c302bdb9 by Emmanuel Bourg at 2022-05-04T00:02:53+02:00
Update upstream source from tag 'upstream/2.0'
Update to upstream version '2.0'
with Debian dir 4d45452c061297b124995d057b82a516971b3e2e
- - - - -
d8c327fe by Emmanuel Bourg at 2022-05-04T00:32:15+02:00
Refreshed the patches
- - - - -
10bf107d by Emmanuel Bourg at 2022-05-04T00:33:16+02:00
Removed the dependency on junit
- - - - -
4efe5040 by Emmanuel Bourg at 2022-05-04T00:34:49+02:00
New build dependency on libeclipse-sisu-maven-plugin-java
- - - - -
9e5acda8 by Emmanuel Bourg at 2022-05-04T00:36:32+02:00
Removed the -java-doc package
- - - - -
62d556da by Emmanuel Bourg at 2022-05-04T01:02:19+02:00
Relocate the old org.sonatype.plexus:plexus-sec-dispatcher coordinates
- - - - -
e7199120 by Emmanuel Bourg at 2022-05-04T01:02:29+02:00
Upload to unstable
- - - - -
21 changed files:
- + .gitignore
- debian/changelog
- − debian/compat
- debian/control
- debian/copyright
- − debian/libplexus-sec-dispatcher-java-doc.doc-base.api
- − debian/libplexus-sec-dispatcher-java-doc.install
- debian/libplexus-sec-dispatcher-java.poms
- debian/maven.rules
- debian/patches/plexus-component-metadata.patch
- − debian/patches/pom.patch
- debian/patches/series
- debian/watch
- 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
=====================================
debian/changelog
=====================================
@@ -1,3 +1,18 @@
+plexus-sec-dispatcher (2.0-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream release
+ - Refreshed the patches
+ - Removed the dependency on junit
+ - New build dependency on libeclipse-sisu-maven-plugin-java
+ - Relocate the old org.sonatype.plexus:plexus-sec-dispatcher coordinates
+ * Removed the -java-doc package
+ * Updated the watch file
+ * Standards-Version updated to 4.6.0.1
+ * Switch to debhelper level 13
+
+ -- Emmanuel Bourg <ebourg at apache.org> Wed, 04 May 2022 01:02:22 +0200
+
plexus-sec-dispatcher (1.4-4) unstable; urgency=medium
* Team upload.
=====================================
debian/compat deleted
=====================================
@@ -1 +0,0 @@
-11
=====================================
debian/control
=====================================
@@ -4,19 +4,16 @@ Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders: Ludovic Claude <ludovic.claude at laposte.net>
Build-Depends:
- debhelper (>= 11),
+ debhelper-compat (= 13),
default-jdk,
- default-jdk-doc,
- junit (>= 3.8.2),
junit4,
- libmaven-javadoc-plugin-java,
+ libeclipse-sisu-maven-plugin-java,
libmodello-maven-plugin-java,
libplexus-cipher-java,
libplexus-component-metadata-java,
libplexus-utils2-java,
- libplexus-utils2-java-doc,
maven-debian-helper (>= 2.1)
-Standards-Version: 4.2.1
+Standards-Version: 4.6.0.1
Vcs-Git: https://salsa.debian.org/java-team/plexus-sec-dispatcher.git
Vcs-Browser: https://salsa.debian.org/java-team/plexus-sec-dispatcher
Homepage: https://github.com/codehaus-plexus/plexus-sec-dispatcher
@@ -25,23 +22,8 @@ Package: libplexus-sec-dispatcher-java
Architecture: all
Depends: ${misc:Depends}, ${maven:Depends}
Recommends: ${maven:OptionalDepends}
-Suggests: libplexus-sec-dispatcher-java-doc
Description: Plexus Security Dispatcher Component used by Maven
The Plexus project provides a full software stack for creating and
executing software projects. Based on the Plexus container, the applications
can utilise component-oriented programming to build modular, reusable
components that can easily be assembled and reused.
-
-Package: libplexus-sec-dispatcher-java-doc
-Architecture: all
-Section: doc
-Depends: ${misc:Depends}, ${maven:DocDepends}
-Recommends: ${maven:DocOptionalDepends}
-Suggests: libplexus-sec-dispatcher-java
-Description: Documentation for Plexus Security Dispatcher Component
- The Plexus project provides a full software stack for creating and
- executing software projects. Based on the Plexus container, the applications
- can utilise component-oriented programming to build modular, reusable
- components that can easily be assembled and reused.
- .
- This package contains the API documentation of libplexus-sec-dispatcher-java.
=====================================
debian/copyright
=====================================
@@ -1,6 +1,7 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Plexus Security Dispatcher Component
Source: https://github.com/codehaus-plexus/plexus-sec-dispatcher
+Files-Excluded: .github/*
Files: *
Copyright: 2008, Sonatype Inc.
=====================================
debian/libplexus-sec-dispatcher-java-doc.doc-base.api deleted
=====================================
@@ -1,10 +0,0 @@
-Document: libplexus-sec-dispatcher-java
-Title: API Javadoc for Plexus Security Dispatcher Component
-Author: Plexus Security Dispatcher Component developers
-Abstract: This is the API Javadoc provided for the
- libplexus-sec-dispatcher-java library.
-Section: Programming
-
-Format: HTML
-Index: /usr/share/doc/libplexus-sec-dispatcher-java/api/index.html
-Files: /usr/share/doc/libplexus-sec-dispatcher-java/api/*
=====================================
debian/libplexus-sec-dispatcher-java-doc.install deleted
=====================================
@@ -1 +0,0 @@
-target/apidocs/* usr/share/doc/libplexus-sec-dispatcher-java/api
=====================================
debian/libplexus-sec-dispatcher-java.poms
=====================================
@@ -23,4 +23,4 @@
# --ignore-pom: don't install the POM with mh_install or mh_installpoms. To use with POM files that are created
# temporarily for certain artifacts such as Javadoc jars.
#
-pom.xml --no-parent --has-package-version --java-lib
+pom.xml --no-parent --has-package-version --java-lib --relocate=org.sonatype.plexus:plexus-sec-dispatcher
=====================================
debian/maven.rules
=====================================
@@ -16,6 +16,6 @@
# and version starting with 3., replacing the version with 3.x
# junit junit jar s/3\\..*/3.x/
-junit junit jar s/3\..*/3.x/ * *
+junit junit jar s/4\..*/4.x/ * *
org.codehaus.plexus plexus-container-default jar s/.*/1.5.5/ * *
org.codehaus.plexus plexus-utils * s/.*/2.x/ * *
=====================================
debian/patches/plexus-component-metadata.patch
=====================================
@@ -2,7 +2,7 @@ Description: Generate the component descriptor with plexus-component-metadata in
Origin: backport, https://github.com/codehaus-plexus/plexus-pom/commit/3c5f784f
--- a/pom.xml
+++ b/pom.xml
-@@ -63,6 +63,18 @@
+@@ -105,6 +105,18 @@
</execution>
</executions>
</plugin>
@@ -20,4 +20,4 @@ Origin: backport, https://github.com/codehaus-plexus/plexus-pom/commit/3c5f784f
+ </plugin>
</plugins>
</build>
-
+ </project>
=====================================
debian/patches/pom.patch deleted
=====================================
@@ -1,18 +0,0 @@
---- a/pom.xml
-+++ b/pom.xml
-@@ -70,6 +70,7 @@
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
-+ <version>1.5.8</version>
- </dependency>
- <dependency>
- <groupId>org.sonatype.plexus</groupId>
-@@ -86,6 +87,7 @@
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
-+ <scope>test</scope>
- </dependency>
- </dependencies>
-
=====================================
debian/patches/series
=====================================
@@ -1,2 +1 @@
-pom.patch
plexus-component-metadata.patch
=====================================
debian/watch
=====================================
@@ -1,4 +1,4 @@
version=3
opts="uversionmangle=s{-(alpha|beta)-}{~$1}" \
-https://github.com/codehaus-plexus/plexus-sec-dispatcher/tags .*/(.*).tar.gz
+https://github.com/codehaus-plexus/plexus-sec-dispatcher/tags .*/(?:plexus-)?sec-dispatcher-(.*).tar.gz
=====================================
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/-/compare/4227830d82ce2fa21ce129880f3c054dec72a127...e7199120641d1d607acf5beb60c373314f58f200
--
View it on GitLab: https://salsa.debian.org/java-team/plexus-sec-dispatcher/-/compare/4227830d82ce2fa21ce129880f3c054dec72a127...e7199120641d1d607acf5beb60c373314f58f200
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/94b0b1f3/attachment.htm>
More information about the pkg-java-commits
mailing list