throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
{
// TODO: remove when components.xml can be used to configure this instead
try
{
DefaultWagonManager wagonManager = (DefaultWagonManager) container.lookup( WagonManager.ROLE );
String oldUserAgent = wagonManager.getHttpUserAgent();
int firstSpace = oldUserAgent == null ? -1 : oldUserAgent.indexOf( " " );
StringBuffer buffer = new StringBuffer();
buffer.append( "Apache-Maven/" );
ArtifactVersion version = runtimeInformation.getApplicationVersion();
if ( version != null )
{
buffer.append( version.getMajorVersion() );
buffer.append( '.' );
buffer.append( version.getMinorVersion() );
}
else
{
buffer.append( "unknown" );
}
buffer.append( ' ' );
if ( firstSpace > -1 )
{
buffer.append( oldUserAgent.substring( firstSpace + 1 ) );
buffer.append( ' ' );
buffer.append( oldUserAgent.substring( 0, firstSpace ) );
}
else
{
buffer.append( oldUserAgent );
}
wagonManager.setHttpUserAgent( buffer.toString() );
}
catch ( ClassCastException e )
{
// ignore
}
WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );
SecDispatcher sd = null;
try
{
Proxy proxy = settings.getActiveProxy();
try
{
sd = (SecDispatcher) container.lookup( SecDispatcher.ROLE, "maven" );
}
catch (Exception e)
{
getLogger().warn( "Security features are disabled. Cannot find plexus component "+SecDispatcher.ROLE + ":maven" );
line();
}
if ( proxy != null )
{
if ( proxy.getHost() == null )
{
throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
}
String pass = proxy.getPassword();
if ( sd != null )
{
try
{
pass = sd.decrypt( pass );
}
catch ( SecDispatcherException e )
{
reportSecurityConfigurationError( "password for proxy '" + proxy.getId() + "'", e );
}
}
wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(),
pass, proxy.getNonProxyHosts() );
}
for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
{
Server server = (Server) i.next();
String passWord = server.getPassword();
if ( sd != null )
{
try
{
passWord = sd.decrypt( passWord );
}
catch ( SecDispatcherException e )
{
reportSecurityConfigurationError( "password for server '" + server.getId() + "'", e );
}
}
String passPhrase = server.getPassphrase();
if ( sd != null )
{
try
{
passPhrase = sd.decrypt( passPhrase );
}
catch ( SecDispatcherException e )
{
reportSecurityConfigurationError( "passphrase for server '" + server.getId() + "'", e );
}
}
wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), passWord,
server.getPrivateKey(), passPhrase );
wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
server.getDirectoryPermissions() );
if ( server.getConfiguration() != null )
{
wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
}
}
for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
{
Mirror mirror = (Mirror) i.next();
wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
}
}
finally
{
container.release( wagonManager );