mirror of https://github.com/apache/maven.git
[MNG-4033] migrated password encryption from 2.1.x trunk
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@743912 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
84e363c313
commit
9737a2f1d9
|
@ -34,6 +34,7 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -53,6 +54,9 @@ public class DefaultMavenSettingsBuilder
|
||||||
@Requirement
|
@Requirement
|
||||||
private SettingsValidator validator;
|
private SettingsValidator validator;
|
||||||
|
|
||||||
|
@Requirement( hint = "maven" )
|
||||||
|
private SecDispatcher securityDispatcher;
|
||||||
|
|
||||||
/** @since 2.1 */
|
/** @since 2.1 */
|
||||||
public Settings buildSettings( MavenExecutionRequest request )
|
public Settings buildSettings( MavenExecutionRequest request )
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
|
@ -101,6 +105,8 @@ public class DefaultMavenSettingsBuilder
|
||||||
|
|
||||||
userSettings = interpolate( userSettings, request );
|
userSettings = interpolate( userSettings, request );
|
||||||
|
|
||||||
|
decrypt( userSettings );
|
||||||
|
|
||||||
// for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
|
// for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
|
||||||
String localRepository = userSettings.getLocalRepository();
|
String localRepository = userSettings.getLocalRepository();
|
||||||
if ( localRepository != null && localRepository.length() > 0 )
|
if ( localRepository != null && localRepository.length() > 0 )
|
||||||
|
@ -115,6 +121,36 @@ public class DefaultMavenSettingsBuilder
|
||||||
return userSettings;
|
return userSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* decrypt settings passwords and passphrases
|
||||||
|
*
|
||||||
|
* @param settings settings to process
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void decrypt( Settings settings )
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
List<Server> servers = settings.getServers();
|
||||||
|
|
||||||
|
if( servers != null && !servers.isEmpty() )
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for( Server server : servers )
|
||||||
|
{
|
||||||
|
if( server.getPassword() != null )
|
||||||
|
server.setPassword( securityDispatcher.decrypt( server.getPassword() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
// 2009-02-12 Oleg: get do this because 2 levels up Exception is
|
||||||
|
// caught, not exception type does not matter
|
||||||
|
throw new IOException( e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Settings interpolate( Settings settings, MavenExecutionRequest request )
|
private Settings interpolate( Settings settings, MavenExecutionRequest request )
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue