本文整理了Java中org.eclipse.aether.repository.Proxy
类的一些代码示例,展示了Proxy
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Proxy
类的具体详情如下:
包路径:org.eclipse.aether.repository.Proxy
类名称:Proxy
[英]A proxy to use for connections to a repository.
[中]用于连接到存储库的代理。
代码示例来源:origin: apache/storm
private static Proxy parseProxyArg(String proxyUrl, String proxyUsername, String proxyPassword) throws MalformedURLException {
URL url = new URL(proxyUrl);
if (StringUtils.isNotEmpty(proxyUsername) && StringUtils.isNotEmpty(proxyPassword)) {
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
authBuilder.addUsername(proxyUsername).addPassword(proxyPassword);
return new Proxy(url.getProtocol(), url.getHost(), url.getPort(), authBuilder.build());
} else {
return new Proxy(url.getProtocol(), url.getHost(), url.getPort());
}
}
代码示例来源:origin: apache/maven
p.setHost( proxy.getHost() );
p.setProtocol( proxy.getType() );
p.setPort( proxy.getPort() );
if ( proxy.getAuthentication() != null )
代码示例来源:origin: org.eclipse.aether/aether-api
@Override
public String toString()
{
return getHost() + ':' + getPort();
}
代码示例来源:origin: org.eclipse.aether/aether-transport-wagon
prox.setType( p.getType() );
prox.setHost( p.getHost() );
prox.setPort( p.getPort() );
代码示例来源:origin: org.apache.maven.resolver/maven-resolver-impl
if ( proxy != null )
buffer.append( " via " ).append( proxy.getHost() ).append( ':' ).append( proxy.getPort() );
auth = proxy.getAuthentication();
if ( auth != null )
代码示例来源:origin: org.jboss.galleon/galleon-cli
@Override
public Proxy getProxy(RemoteRepository repo) {
Proxy ret = null;
if (proxy.getType().equals(repo.getProtocol())) {
boolean match = false;
for (Pattern p : nonProxyHosts) {
if (p.matcher(repo.getHost()).matches()) {
match = true;
break;
}
}
if (!match) {
ret = proxy;
}
}
return ret;
}
}
代码示例来源:origin: org.eclipse.aether/aether-api
/**
* Gets an authentication context for the proxy of the specified repository.
*
* @param session The repository system session during which the repository is accessed, must not be {@code null}.
* @param repository The repository for whose proxy to create an authentication context, must not be {@code null}.
* @return An authentication context for the proxy or {@code null} if no proxy is set or no authentication is
* configured for it.
*/
public static AuthenticationContext forProxy( RepositorySystemSession session, RemoteRepository repository )
{
Proxy proxy = repository.getProxy();
return newInstance( session, repository, proxy, ( proxy != null ) ? proxy.getAuthentication() : null );
}
代码示例来源:origin: org.apache.maven.resolver/maven-resolver-api
@Override
public String toString()
{
return getHost() + ':' + getPort();
}
代码示例来源:origin: org.eclipse.aether/aether-connector-wagon
prox.setType( p.getType() );
prox.setHost( p.getHost() );
prox.setPort( p.getPort() );
代码示例来源:origin: org.eclipse.aether/aether-impl
if ( proxy != null )
buffer.append( " via " ).append( proxy.getHost() ).append( ':' ).append( proxy.getPort() );
auth = proxy.getAuthentication();
if ( auth != null )
代码示例来源:origin: org.eclipse.aether/aether-util
String key = proxy.proxy.getType().toLowerCase( Locale.ENGLISH );
if ( !candidates.containsKey( key ) )
代码示例来源:origin: org.apache.maven.resolver/maven-resolver-api
/**
* Gets an authentication context for the proxy of the specified repository.
*
* @param session The repository system session during which the repository is accessed, must not be {@code null}.
* @param repository The repository for whose proxy to create an authentication context, must not be {@code null}.
* @return An authentication context for the proxy or {@code null} if no proxy is set or no authentication is
* configured for it.
*/
public static AuthenticationContext forProxy( RepositorySystemSession session, RemoteRepository repository )
{
Proxy proxy = repository.getProxy();
return newInstance( session, repository, proxy, ( proxy != null ) ? proxy.getAuthentication() : null );
}
代码示例来源:origin: apache/incubator-druid
private DefaultTeslaAether createTeslaAether(List<Repository> remoteRepositories)
{
if (!useProxy) {
return new DefaultTeslaAether(
localRepository,
remoteRepositories.toArray(new Repository[0])
);
}
if (!StringUtils.toLowerCase(proxyType).equals(Proxy.TYPE_HTTP) && !StringUtils.toLowerCase(proxyType).equals(Proxy.TYPE_HTTPS)) {
throw new IllegalArgumentException("invalid proxy type: " + proxyType);
}
RepositorySystemSession repositorySystemSession = new RepositorySystemSessionProvider(new File(localRepository)).get();
List<RemoteRepository> rl = remoteRepositories.stream().map(r -> {
RemoteRepository.Builder builder = new RemoteRepository.Builder(r.getId(), "default", r.getUrl());
if (r.getUsername() != null && r.getPassword() != null) {
Authentication auth = new AuthenticationBuilder().addUsername(r.getUsername()).addPassword(r.getPassword()).build();
builder.setAuthentication(auth);
}
final Authentication proxyAuth;
if (Strings.isNullOrEmpty(proxyUsername)) {
proxyAuth = null;
} else {
proxyAuth = new AuthenticationBuilder().addUsername(proxyUsername).addPassword(proxyPassword).build();
}
builder.setProxy(new Proxy(proxyType, proxyHost, proxyPort, proxyAuth));
return builder.build();
}).collect(Collectors.toList());
return new DefaultTeslaAether(rl, repositorySystemSession);
}
代码示例来源:origin: org.eclipse.aether/aether-transport-http
private static HttpHost toHost( Proxy proxy )
{
HttpHost host = null;
if ( proxy != null )
{
host = new HttpHost( proxy.getHost(), proxy.getPort() );
}
return host;
}
代码示例来源:origin: apache/maven
p.setHost( proxy.getHost() );
p.setProtocol( proxy.getType() );
p.setPort( proxy.getPort() );
if ( proxy.getAuthentication() != null )
代码示例来源:origin: org.kie.soup/kie-soup-maven-integration
@Test
public void testProxies() {
String oldSettingsXmlPath = System.getProperty( CUSTOM_SETTINGS_PROPERTY );
try {
if (oldSettingsXmlPath != null) {
System.clearProperty( CUSTOM_SETTINGS_PROPERTY );
}
MavenSettings.reinitSettingsFromString( SETTINGS_WITH_PROXY );
Aether aether = Aether.getAether();
RemoteRepository remoteRepository = new RemoteRepository.Builder( "local", "default", "http://myserver.com" ).build();
Proxy proxy = aether.getSession().getProxySelector().getProxy( remoteRepository );
assertEquals("http", proxy.getType());
assertEquals("localhost", proxy.getHost());
assertEquals(8888, proxy.getPort());
} finally {
if (oldSettingsXmlPath != null) {
System.setProperty( CUSTOM_SETTINGS_PROPERTY, oldSettingsXmlPath );
}
MavenSettings.reinitSettings();
}
}
代码示例来源:origin: org.apache.maven.resolver/maven-resolver-util
String key = proxy.proxy.getType().toLowerCase( Locale.ENGLISH );
if ( !candidates.containsKey( key ) )
代码示例来源:origin: org.apache.maven.resolver/maven-resolver-api
/**
* Gets the fingerprint for the authentication of the specified repository's proxy.
*
* @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
* @param repository The repository whose proxy authentication is to be fingerprinted, must not be {@code null}.
* @return The fingerprint of the proxy authentication or an empty string if no proxy is present or if no proxy
* authentication is configured, never {@code null}.
*/
public static String forProxy( RepositorySystemSession session, RemoteRepository repository )
{
String digest = "";
Proxy proxy = repository.getProxy();
if ( proxy != null )
{
Authentication auth = proxy.getAuthentication();
if ( auth != null )
{
AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, proxy );
auth.digest( authDigest );
digest = authDigest.digest();
}
}
return digest;
}
代码示例来源:origin: apache/maven
private static Proxy toProxy( org.apache.maven.repository.Proxy proxy )
{
Proxy result = null;
if ( proxy != null )
{
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
authBuilder.addUsername( proxy.getUserName() ).addPassword( proxy.getPassword() );
result = new Proxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authBuilder.build() );
}
return result;
}
代码示例来源:origin: takari/takari-local-repository
private String getRepoKey(RepositorySystemSession session, RemoteRepository repository) {
StringBuilder buffer = new StringBuilder(128);
Proxy proxy = repository.getProxy();
if (proxy != null) {
buffer.append(AuthenticationDigest.forProxy(session, repository)).append('@');
buffer.append(proxy.getHost()).append(':').append(proxy.getPort()).append('>');
}
buffer.append(AuthenticationDigest.forRepository(session, repository)).append('@');
buffer.append(repository.getContentType()).append('-');
buffer.append(normalizeRepoUrl(repository.getUrl()));
return buffer.toString();
}
内容来源于网络,如有侵权,请联系作者删除!