mirror of https://github.com/apache/maven.git
[MNG-553] Secure Storage of Server Passwords
o Extended IT to check new CLI commands to encrypt passwords git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@803545 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
77ba2adf5f
commit
0ee199ecfa
|
@ -24,6 +24,8 @@ import org.apache.maven.it.util.ResourceExtractor;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.mortbay.jetty.Server;
|
||||
|
@ -163,4 +165,52 @@ public class MavenITmng0553SettingsAuthzEncryptionTest
|
|||
verifier.assertArtifactPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the CLI supports generation of encrypted (master) passwords.
|
||||
*/
|
||||
public void testitEncryption()
|
||||
throws Exception
|
||||
{
|
||||
Verifier verifier = new Verifier( new File( testDir, "test-3" ).getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.getSystemProperties().setProperty( "settings.security", "settings~security.xml" );
|
||||
verifier.getCliOptions().add( "--encrypt-master-password" );
|
||||
verifier.getCliOptions().add( "test" );
|
||||
verifier.setLogFileName( "log-emp.txt" );
|
||||
verifier.executeGoal( "-e" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
List log = verifier.loadLines( verifier.getLogFileName(), null );
|
||||
assertNotNull( findPassword( log ) );
|
||||
|
||||
verifier = new Verifier( new File( testDir, "test-3" ).getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.getSystemProperties().setProperty( "settings.security", "settings-security.xml" );
|
||||
verifier.getCliOptions().add( "--encrypt-password" );
|
||||
verifier.getCliOptions().add( "testpass" );
|
||||
verifier.setLogFileName( "log-ep.txt" );
|
||||
verifier.executeGoal( "-e" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
log = verifier.loadLines( verifier.getLogFileName(), null );
|
||||
assertNotNull( findPassword( log ) );
|
||||
}
|
||||
|
||||
private String findPassword( List log )
|
||||
{
|
||||
for ( Iterator it = log.iterator(); it.hasNext(); )
|
||||
{
|
||||
String line = (String) it.next();
|
||||
|
||||
if ( line.matches( ".*\\{[A-Za-z0-9+/=]+\\}.*" ) )
|
||||
{
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<settingsSecurity>
|
||||
<master>{1wQaa6S/o8MH7FnaTNL53XmhT5O0SEGXQi3gC49o6OY=}</master>
|
||||
</settingsSecurity>
|
Loading…
Reference in New Issue