org.apache.maven.wagon.proxy.ProxyInfo Java Examples

The following examples show how to use org.apache.maven.wagon.proxy.ProxyInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NexusRepositoryIndexerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WagonHelper.WagonFetcher createFetcher(final Wagon wagon, TransferListener listener, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo) {
    if(isDiag()) {
        return new WagonHelper.WagonFetcher(wagon, listener, authenticationInfo, proxyInfo) {
            @Override
            public InputStream retrieve(String name) throws IOException, FileNotFoundException {
                String id = wagon.getRepository().getId();
                if(name.contains("properties") && System.getProperty("maven.diag.index.properties." + id) != null) { // NOI18N
                    LOGGER.log(Level.INFO, "maven indexer will use local properties file: {0}", System.getProperty("maven.diag.index.properties." + id)); // NOI18N
                    return new FileInputStream(new File(System.getProperty("maven.diag.index.properties." + id))); // NOI18N
                } else if(name.contains(".gz") && System.getProperty("maven.diag.index.gz." + id) != null) { // NOI18N
                    LOGGER.log(Level.INFO, "maven indexer will use gz file: {0}", System.getProperty("maven.diag.index.gz." + id)); // NOI18N
                    return new FileInputStream(new File(System.getProperty("maven.diag.index.gz." + id))); // NOI18N
                }
                return super.retrieve(name);
            }
        };
    } else {
        return new WagonHelper.WagonFetcher(wagon, listener, authenticationInfo, proxyInfo);
    }
}
 
Example #2
Source File: MavenRepositoryProxyHandler.java    From archiva with Apache License 2.0 6 votes vote down vote up
private void updateWagonProxyInfo(Map<String, NetworkProxy> proxyList) {
    this.networkProxyMap.clear();
    for (Map.Entry<String, NetworkProxy> proxyEntry : proxyList.entrySet()) {
        String key = proxyEntry.getKey();
        NetworkProxy networkProxyDef = proxyEntry.getValue();

        ProxyInfo proxy = new ProxyInfo();

        proxy.setType(networkProxyDef.getProtocol());
        proxy.setHost(networkProxyDef.getHost());
        proxy.setPort(networkProxyDef.getPort());
        proxy.setUserName(networkProxyDef.getUsername());
        proxy.setPassword(new String(networkProxyDef.getPassword()));

        this.networkProxyMap.put(key, proxy);
    }
}
 
Example #3
Source File: S3Utils.java    From lambadaframework with MIT License 5 votes vote down vote up
static ClientConfiguration getClientConfiguration(ProxyInfoProvider proxyInfoProvider) {
    ClientConfiguration clientConfiguration = new ClientConfiguration();

    if (proxyInfoProvider != null) {
        ProxyInfo proxyInfo = proxyInfoProvider.getProxyInfo("s3");
        if (proxyInfo != null) {
            clientConfiguration.withProxyHost(proxyInfo.getHost()).withProxyPort(proxyInfo.getPort());
        }
    }

    return clientConfiguration;
}
 
Example #4
Source File: NullProtectingProxyInfoProvider.java    From lambadaframework with MIT License 5 votes vote down vote up
@Override
public ProxyInfo getProxyInfo(String protocol) {
    if ((protocol == null) || (this.proxyInfo == null) || protocol.equalsIgnoreCase(this.proxyInfo.getType())) {
        return this.proxyInfo;
    } else {
        return null;
    }
}
 
Example #5
Source File: RemoteExistsMojo.java    From exists-maven-plugin with Apache License 2.0 5 votes vote down vote up
ProxyInfo getProxyInfo() {
  Proxy proxy = settings.getActiveProxy();
  if (proxy == null) {
    return null;
  }

  ProxyInfo proxyInfo = new ProxyInfo();
  proxyInfo.setHost(proxy.getHost());
  proxyInfo.setType(proxy.getProtocol());
  proxyInfo.setPort(proxy.getPort());
  proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
  proxyInfo.setUserName(proxy.getUsername());
  proxyInfo.setPassword(proxy.getPassword());
  return proxyInfo;
}
 
Example #6
Source File: WagonUtils.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience method to create a wagon.
 *
 * @param serverId The serverId to use if the wagonManager needs help.
 * @param url The url to create a wagon for.
 * @param wagonManager The wgaon manager to use.
 * @param settings The settings to use.
 * @param logger The logger to use.
 * @return The wagon to connect to the url.
 * @throws org.apache.maven.wagon.UnsupportedProtocolException if the protocol is not supported.
 * @throws org.apache.maven.artifact.manager.WagonConfigurationException if the wagon cannot be configured.
 * @throws org.apache.maven.wagon.ConnectionException If the connection cannot be established.
 * @throws org.apache.maven.wagon.authentication.AuthenticationException If the connection cannot be authenticated.
 */
public static Wagon createWagon( String serverId, String url, WagonManager wagonManager, Settings settings,
                                 Log logger )
                                     throws UnsupportedProtocolException, WagonConfigurationException,
                                     ConnectionException, AuthenticationException
{
    Repository repository = new Repository( serverId, url );
    Wagon wagon = wagonManager.getWagon( repository );

    if ( logger.isDebugEnabled() )
    {
        Debug debug = new Debug();
        wagon.addSessionListener( debug );
        wagon.addTransferListener( debug );
    }

    ProxyInfo proxyInfo = getProxyInfo( settings );
    if ( proxyInfo != null )
    {
        wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ), proxyInfo );
    }
    else
    {
        wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ) );
    }
    return wagon;
}
 
Example #7
Source File: AbstractDeployMojo.java    From opoopress with Apache License 2.0 5 votes vote down vote up
public static ProxyInfo getProxyInfo(Repository repository, WagonManager wagonManager) {
    ProxyInfo proxyInfo = wagonManager.getProxy(repository.getProtocol());

    if (proxyInfo == null) {
        return null;
    }

    String host = repository.getHost();
    String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
    for (String nonProxyHost : StringUtils.split(nonProxyHostsAsString, ",;|")) {
        if (org.apache.commons.lang.StringUtils.contains(nonProxyHost, "*")) {
            // Handle wildcard at the end, beginning or middle of the nonProxyHost
            final int pos = nonProxyHost.indexOf('*');
            String nonProxyHostPrefix = nonProxyHost.substring(0, pos);
            String nonProxyHostSuffix = nonProxyHost.substring(pos + 1);
            // prefix*
            if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
                    && StringUtils.isEmpty(nonProxyHostSuffix)) {
                return null;
            }
            // *suffix
            if (StringUtils.isEmpty(nonProxyHostPrefix)
                    && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
                return null;
            }
            // prefix*suffix
            if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
                    && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
                return null;
            }
        } else if (host.equals(nonProxyHost)) {
            return null;
        }
    }
    return proxyInfo;
}
 
Example #8
Source File: NullProtectingProxyInfoProvider.java    From lambadaframework with MIT License 4 votes vote down vote up
NullProtectingProxyInfoProvider(ProxyInfo proxyInfo) {
    this.proxyInfo = proxyInfo;
}
 
Example #9
Source File: AbstractWagon.java    From lambadaframework with MIT License 4 votes vote down vote up
@Override
public final void connect(Repository source, ProxyInfo proxyInfo) throws ConnectionException,
        AuthenticationException {
    connect(source, null, proxyInfo);
}
 
Example #10
Source File: AbstractWagon.java    From lambadaframework with MIT License 4 votes vote down vote up
@Override
public final void connect(Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo)
        throws ConnectionException, AuthenticationException {
    connect(source, authenticationInfo, new NullProtectingProxyInfoProvider(proxyInfo));
}
 
Example #11
Source File: WagonDelegate.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public void connect( Repository source, ProxyInfo proxyInfo )
    throws ConnectionException, AuthenticationException
{
    delegate.connect( source, proxyInfo );
}
 
Example #12
Source File: WagonDelegate.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
    throws ConnectionException, AuthenticationException
{
    delegate.connect( source, authenticationInfo, proxyInfo );
}
 
Example #13
Source File: MockWagon.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public void connect( Repository repository, ProxyInfo proxyInfo )
    throws ConnectionException, AuthenticationException
{

}
 
Example #14
Source File: MockWagon.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
    throws ConnectionException, AuthenticationException
{

}