mirror of https://github.com/apache/maven.git
[MNG-4099] Password encryption CLI switches should prompt for password if missing
This commit is contained in:
parent
60437a28a9
commit
626884e9ee
|
@ -132,8 +132,8 @@ public class CLIManager
|
|||
options.addOption( OptionBuilder.withLongOpt( "also-make-dependents" ).withDescription( "If project list is specified, also build projects that depend on projects on the list" ).create( ALSO_MAKE_DEPENDENTS ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "log-file" ).hasArg().withDescription( "Log file to where all build output will go." ).create( LOG_FILE ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "show-version" ).withDescription( "Display version information WITHOUT stopping build" ).create( SHOW_VERSION ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ).hasArg().withDescription( "Encrypt master security password" ).create( ENCRYPT_MASTER_PASSWORD ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ).hasArg().withDescription( "Encrypt server password" ).create( ENCRYPT_PASSWORD ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ).hasOptionalArg().withDescription( "Encrypt master security password" ).create( ENCRYPT_MASTER_PASSWORD ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ).hasOptionalArg().withDescription( "Encrypt server password" ).create( ENCRYPT_PASSWORD ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "threads" ).hasArg().withDescription( "Thread count, for instance 2.0C where C is core multiplied" ).create( THREADS ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "legacy-local-repository" ).withDescription( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).create( LEGACY_LOCAL_REPOSITORY ) );
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.cli;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -497,6 +498,21 @@ public class MavenCli
|
|||
if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) )
|
||||
{
|
||||
String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD );
|
||||
|
||||
if ( passwd == null )
|
||||
{
|
||||
Console cons;
|
||||
char[] password;
|
||||
if ( ( cons = System.console() ) != null
|
||||
&& ( password = cons.readPassword( "Master password:") ) != null )
|
||||
{
|
||||
// Cipher uses Strings
|
||||
passwd = String.copyValueOf( password );
|
||||
|
||||
// Sun/Oracle advises to empty the char array
|
||||
java.util.Arrays.fill( password, ' ' );
|
||||
}
|
||||
}
|
||||
|
||||
DefaultPlexusCipher cipher = new DefaultPlexusCipher();
|
||||
|
||||
|
@ -507,6 +523,21 @@ public class MavenCli
|
|||
else if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) )
|
||||
{
|
||||
String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD );
|
||||
|
||||
if ( passwd == null )
|
||||
{
|
||||
Console cons;
|
||||
char[] password;
|
||||
if ( ( cons = System.console() ) != null
|
||||
&& ( password = cons.readPassword( "Password:" ) ) != null )
|
||||
{
|
||||
// Cipher uses Strings
|
||||
passwd = String.copyValueOf( password );
|
||||
|
||||
// Sun/Oracle advises to empty the char array
|
||||
java.util.Arrays.fill( password, ' ' );
|
||||
}
|
||||
}
|
||||
|
||||
String configurationFile = dispatcher.getConfigurationFile();
|
||||
|
||||
|
|
Loading…
Reference in New Issue