本文整理汇总了Java中org.apache.maven.settings.Proxy.getProtocol方法的典型用法代码示例。如果您正苦于以下问题:Java Proxy.getProtocol方法的具体用法?Java Proxy.getProtocol怎么用?Java Proxy.getProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Proxy
的用法示例。
在下文中一共展示了Proxy.getProtocol方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProxyConfig
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
static ProxyConfig getProxyConfig(MavenSession mavenSession) {
if (
mavenSession == null ||
mavenSession.getSettings() == null ||
mavenSession.getSettings().getActiveProxy() == null ||
!mavenSession.getSettings().getActiveProxy().isActive()
) {
return null;
} else {
Proxy mavenProxy = mavenSession.getSettings().getActiveProxy();
return new ProxyConfig(
mavenProxy.getProtocol(),
mavenProxy.getHost(),
mavenProxy.getPort(),
mavenProxy.getUsername(),
mavenProxy.getPassword());
}
}
示例2: ProxySettings
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
public ProxySettings(@Nonnull final Proxy mavenProxy) {
this.protocol = mavenProxy.getProtocol();
this.host = mavenProxy.getHost();
this.port = mavenProxy.getPort();
this.username = mavenProxy.getUsername();
this.password = mavenProxy.getPassword();
this.nonProxyHosts = mavenProxy.getNonProxyHosts();
}
示例3: setProxySystemProperties
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
public void setProxySystemProperties() {
Proxy activeProxy = session.getSettings().getActiveProxy();
if (activeProxy != null && activeProxy.getProtocol() != null && activeProxy.getProtocol().contains("http")) {
log.debug("Setting proxy properties");
System.setProperty("http.proxyHost", activeProxy.getHost());
System.setProperty("http.proxyPort", String.valueOf(activeProxy.getPort()));
System.setProperty("http.proxyUser", StringUtils.defaultString(activeProxy.getUsername(), ""));
System.setProperty("http.proxyPassword", StringUtils.defaultString(activeProxy.getPassword(), ""));
System.setProperty("http.nonProxyHosts", StringUtils.defaultString(activeProxy.getNonProxyHosts(), ""));
}
}
示例4: DependencyAuditor
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
/** Make a new dependency auditor with proxies
*/
public DependencyAuditor(List<Proxy> proxies) {
request = OssIndexApi.createPackageRequest();
for (Proxy proxy : proxies) {
String nonProxyHosts = proxy.getNonProxyHosts();
boolean ignore = false;
String protocol = proxy.getProtocol();
// We only support HTTP(S)
switch (protocol) {
case "http":
case "https":
break;
default:
ignore = true;
break;
}
// Were we told to ignore this proxy server?
if (nonProxyHosts != null) {
String[] tokens = nonProxyHosts.split("|");
for (String token : tokens) {
token = token.trim();
if ("ossindex.net".equalsIgnoreCase(token)) {
ignore = true;
}
}
}
// Should we use this proxy?
if (!ignore) {
request.addProxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), proxy.getPassword());
}
}
}
示例5: proxyConfiguration
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
/**
* Extract configuration from given maven proxy settings.
*
* @param proxy Proxy.
* @return Proxy configuration.
*/
public static ProxyConfig proxyConfiguration(Proxy proxy) {
return new ProxyConfig(
proxy.getProtocol(),
proxy.getUsername(),
proxy.getPassword(),
proxy.getHost(),
proxy.getPort()
);
}
示例6: activateProxy
import org.apache.maven.settings.Proxy; //导入方法依赖的package包/类
/**
* Called to install the plugins proxy settings.
*/
protected Object activateProxy()
{
if ( settings == null )
{
return null;
}
final Proxy proxy = settings.getActiveProxy();
if ( proxy == null )
{
return null;
}
final List<String> properties = new ArrayList<String>();
final String protocol = proxy.getProtocol();
final String prefix = isEmpty( protocol ) ? "" : ( protocol + "." );
final String host = proxy.getHost();
final String hostProperty = prefix + "proxyHost";
final String hostValue = isEmpty( host ) ? null : host;
setProperty( properties, hostProperty, hostValue );
final int port = proxy.getPort();
final String portProperty = prefix + "proxyPort";
final String portValue = ( port == 0 || port == -1 ) ? null : String.valueOf( port );
setProperty( properties, portProperty, portValue );
final String username = proxy.getUsername();
final String userProperty = prefix + "proxyUser";
final String userValue = isEmpty( username ) ? null : username;
setProperty( properties, userProperty, userValue );
final String password = proxy.getPassword();
final String passwordProperty = prefix + "proxyPassword";
final String passwordValue = isEmpty( password ) ? null : password;
setProperty( properties, passwordProperty, passwordValue );
final String nonProxyHosts = proxy.getNonProxyHosts();
final String nonProxyHostsProperty = prefix + "nonProxyHosts";
final String nonProxyHostsValue = isEmpty( nonProxyHosts ) ? null : nonProxyHosts.replace( ',', '|' );
setProperty( properties, nonProxyHostsProperty, nonProxyHostsValue );
getLog().debug( "Proxy settings: " + hostProperty + "=" + hostValue + ", " + portProperty + "=" + portValue
+ ", " + userProperty + "=" + userValue + ", " + passwordProperty + "="
+ ( passwordValue == null ? "null" : "<PasswordNotLogged>" ) + ", " + nonProxyHostsProperty + "="
+ nonProxyHostsValue );
return properties;
}