本文整理了Java中org.apache.commons.httpclient.ProxyHost.getPort()
方法的一些代码示例,展示了ProxyHost.getPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProxyHost.getPort()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.ProxyHost
类名称:ProxyHost
方法名:getPort
暂无
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Returns the proxyPort.
*
* @return the proxy port, or <code>-1</code> if not set
*
* @see #isProxySet()
*/
public synchronized int getProxyPort() {
if (this.proxyHost != null) {
return this.proxyHost.getPort();
} else {
return -1;
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Tests if the proxy configuration equals the configuration set on the
* connection. True only if the proxyHost and proxyPort are equal.
*
* @param connection the connection to test against
* @return <code>true</code> if the connection's proxy information equals that of this
* configuration
*
* @see #hostEquals(HttpConnection)
*/
public synchronized boolean proxyEquals(final HttpConnection connection) {
if (connection == null) {
throw new IllegalArgumentException("Connection may not be null");
}
if (this.proxyHost != null) {
return
this.proxyHost.getHostName().equalsIgnoreCase(connection.getProxyHost())
&& this.proxyHost.getPort() == connection.getProxyPort();
} else {
return connection.getProxyHost() == null;
}
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Returns the proxyPort.
*
* @return the proxy port, or <code>-1</code> if not set
*
* @see #isProxySet()
*/
public synchronized int getProxyPort() {
if (this.proxyHost != null) {
return this.proxyHost.getPort();
} else {
return -1;
}
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Returns the proxyPort.
*
* @return the proxy port, or <code>-1</code> if not set
*
* @see #isProxySet()
*/
public synchronized int getProxyPort() {
if (this.proxyHost != null) {
return this.proxyHost.getPort();
} else {
return -1;
}
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Returns the proxyPort.
*
* @return the proxy port, or <code>-1</code> if not set
*
* @see #isProxySet()
*/
public synchronized int getProxyPort() {
if (this.proxyHost != null) {
return this.proxyHost.getPort();
} else {
return -1;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Returns the proxyPort.
*
* @return the proxy port, or <code>-1</code> if not set
*
* @see #isProxySet()
*/
public synchronized int getProxyPort() {
if (this.proxyHost != null) {
return this.proxyHost.getPort();
} else {
return -1;
}
}
代码示例来源:origin: org.alfresco/alfresco-repository
/**
* Create suitable AuthScope for ProxyHost. If the ProxyHost is null, no AuthsScope will be created.
* @param proxyHost ProxyHost
* @return AuthScope for provided ProxyHost, null otherwise.
*/
private AuthScope createProxyAuthScope(final ProxyHost proxyHost)
{
AuthScope authScope = null;
if (proxyHost != null)
{
authScope = new AuthScope(proxyHost.getHostName(), proxyHost.getPort());
}
return authScope;
}
代码示例来源:origin: Alfresco/alfresco-repository
/**
* Create suitable AuthScope for ProxyHost. If the ProxyHost is null, no AuthsScope will be created.
* @param proxyHost ProxyHost
* @return AuthScope for provided ProxyHost, null otherwise.
*/
private AuthScope createProxyAuthScope(final ProxyHost proxyHost)
{
AuthScope authScope = null;
if (proxyHost != null)
{
authScope = new AuthScope(proxyHost.getHostName(), proxyHost.getPort());
}
return authScope;
}
代码示例来源:origin: org.alfresco/alfresco-repository
/**
* Create suitable AuthScope for ProxyHost.
* If the ProxyHost is null, no AuthsScope will be created.
* @param proxyHost ProxyHost
* @return Authscope for provided ProxyHost, null otherwise.
*/
private static AuthScope createProxyAuthScope(final ProxyHost proxyHost)
{
AuthScope authScope = null;
if (proxyHost != null)
{
authScope = new AuthScope(proxyHost.getHostName(), proxyHost.getPort());
}
return authScope;
}
代码示例来源:origin: Alfresco/alfresco-repository
/**
* Create suitable AuthScope for ProxyHost.
* If the ProxyHost is null, no AuthsScope will be created.
* @param proxyHost ProxyHost
* @return Authscope for provided ProxyHost, null otherwise.
*/
private static AuthScope createProxyAuthScope(final ProxyHost proxyHost)
{
AuthScope authScope = null;
if (proxyHost != null)
{
authScope = new AuthScope(proxyHost.getHostName(), proxyHost.getPort());
}
return authScope;
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Tests if the proxy configuration equals the configuration set on the
* connection. True only if the proxyHost and proxyPort are equal.
*
* @param connection the connection to test against
* @return <code>true</code> if the connection's proxy information equals that of this
* configuration
*
* @see #hostEquals(HttpConnection)
*/
public synchronized boolean proxyEquals(final HttpConnection connection) {
if (connection == null) {
throw new IllegalArgumentException("Connection may not be null");
}
if (this.proxyHost != null) {
return
this.proxyHost.getHostName().equalsIgnoreCase(connection.getProxyHost())
&& this.proxyHost.getPort() == connection.getProxyPort();
} else {
return connection.getProxyHost() == null;
}
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Tests if the proxy configuration equals the configuration set on the
* connection. True only if the proxyHost and proxyPort are equal.
*
* @param connection the connection to test against
* @return <code>true</code> if the connection's proxy information equals that of this
* configuration
*
* @see #hostEquals(HttpConnection)
*/
public synchronized boolean proxyEquals(final HttpConnection connection) {
if (connection == null) {
throw new IllegalArgumentException("Connection may not be null");
}
if (this.proxyHost != null) {
return
this.proxyHost.getHostName().equalsIgnoreCase(connection.getProxyHost())
&& this.proxyHost.getPort() == connection.getProxyPort();
} else {
return connection.getProxyHost() == null;
}
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Tests if the proxy configuration equals the configuration set on the
* connection. True only if the proxyHost and proxyPort are equal.
*
* @param connection the connection to test against
* @return <code>true</code> if the connection's proxy information equals that of this
* configuration
*
* @see #hostEquals(HttpConnection)
*/
public synchronized boolean proxyEquals(final HttpConnection connection) {
if (connection == null) {
throw new IllegalArgumentException("Connection may not be null");
}
if (this.proxyHost != null) {
return
this.proxyHost.getHostName().equalsIgnoreCase(connection.getProxyHost())
&& this.proxyHost.getPort() == connection.getProxyPort();
} else {
return connection.getProxyHost() == null;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Tests if the proxy configuration equals the configuration set on the
* connection. True only if the proxyHost and proxyPort are equal.
*
* @param connection the connection to test against
* @return <code>true</code> if the connection's proxy information equals that of this
* configuration
*
* @see #hostEquals(HttpConnection)
*/
public synchronized boolean proxyEquals(final HttpConnection connection) {
if (connection == null) {
throw new IllegalArgumentException("Connection may not be null");
}
if (this.proxyHost != null) {
return
this.proxyHost.getHostName().equalsIgnoreCase(connection.getProxyHost())
&& this.proxyHost.getPort() == connection.getProxyPort();
} else {
return connection.getProxyHost() == null;
}
}
代码示例来源:origin: org.n52.metadata/smarteditor-api
LOG.debug("Using proxy: " + "Host={};Port={};Scheme={}"
, lProxyHost.getHostName()
, lProxyHost.getPort()
, lProxyHost.getProtocol().getScheme());
代码示例来源:origin: org.n52.metadata/smarteditor-api
private void initClient() {
this.setClient(new HttpClient());
HostConfiguration lConfig = new HostConfiguration();
ProxyResolver proxyResolver = new ProxyResolver();
try {
URL lUrl = new URL(getEndpoint());
ProxyHost lProxyHost = proxyResolver.createProxyHost(lUrl);
lConfig.setProxyHost(lProxyHost);
if (lProxyHost != null) {
LOG.debug("Using proxy: Host={}; Port{};Scheme={}", lProxyHost.getHostName(), lProxyHost.getPort(), lProxyHost.getProtocol().getScheme());
} else {
LOG.debug("Using no proxy");
}
// set proxy authentication, if any
Credentials lCredentials = proxyResolver.createCredentials(lUrl);
if (lCredentials != null) {
LOG.info("Setting proxy credentials");
HttpState state = new HttpState();
state.setProxyCredentials(AuthScope.ANY, lCredentials);
getClient().setState(state);
}
} catch (MalformedURLException pEx) {
LOG.error("Error cleating proxy for URL " + getEndpoint() + ": " + pEx.getMessage());
}
getClient().setHostConfiguration(lConfig);
}
代码示例来源:origin: Alfresco/alfresco-repository
public void testHTTPSProxySettings()
{
String host = "testHost";
Integer port = 8444;
setHTTPSSystemProperties(host, port, "user1", "password", null);
ProxyHost proxyHost = HttpClientHelper.createProxyHost("https.proxyHost", "https.proxyPort", DEFAULT_HTTPS_PORT);
UsernamePasswordCredentials proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("https.proxyUser", "https.proxyPassword");
// Proxy hosts always use plain HTTP connection when communicating with clients (by commons.httpclient doc)
assertEquals(HTTP, proxyHost.getProtocol().getScheme());
assertEquals(host, proxyHost.getHostName());
assertEquals(port, Integer.valueOf(proxyHost.getPort()));
assertEquals("user1", proxyCredentials.getUserName());
assertEquals("password", proxyCredentials.getPassword());
// Test default port and no credentials
setHTTPSSystemProperties(host, null, null, null, null);
proxyHost = HttpClientHelper.createProxyHost("https.proxyHost", "https.proxyPort", DEFAULT_HTTPS_PORT);
proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("https.proxyUser", "https.proxyPassword");
assertEquals(host, proxyHost.getHostName());
assertEquals(DEFAULT_HTTPS_PORT, proxyHost.getPort());
assertNull(proxyCredentials);
}
代码示例来源:origin: Alfresco/alfresco-repository
public void testHTTPProxySettings()
{
String host = "testHost";
Integer port = 8080;
setHTTPSystemProperties(host, port, "user1", "password", null);
ProxyHost proxyHost = HttpClientHelper.createProxyHost("http.proxyHost", "http.proxyPort", DEFAULT_HTTP_PORT);
UsernamePasswordCredentials proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("http.proxyUser", "http.proxyPassword");
assertEquals(HTTP, proxyHost.getProtocol().getScheme());
assertEquals(host, proxyHost.getHostName());
assertEquals(port, Integer.valueOf(proxyHost.getPort()));
assertEquals("user1", proxyCredentials.getUserName());
assertEquals("password", proxyCredentials.getPassword());
// Test default port and no credentials
setHTTPSystemProperties(host, null, null, null, null);
proxyHost = HttpClientHelper.createProxyHost("http.proxyHost", "http.proxyPort", DEFAULT_HTTP_PORT);
proxyCredentials = (UsernamePasswordCredentials) HttpClientHelper.createProxyCredentials("http.proxyUser", "http.proxyPassword");
assertEquals(HTTP, proxyHost.getProtocol().getScheme());
assertEquals(host, proxyHost.getHostName());
assertEquals(DEFAULT_HTTP_PORT, proxyHost.getPort());
assertNull(proxyCredentials);
}
内容来源于网络,如有侵权,请联系作者删除!