Example usage for org.apache.commons.httpclient.auth AuthScope getPort

List of usage examples for org.apache.commons.httpclient.auth AuthScope getPort

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.auth AuthScope getPort.

Prototype

public int getPort() 

Source Link

Usage

From source file:edu.unc.lib.dl.httpclient.HttpClientUtilTest.java

@Test
public void testGetAuthenticationScope() {
    Map<String, Integer> urlsAndPorts = new HashMap<String, Integer>();
    urlsAndPorts.put("http://www.unc.edu", 80);
    urlsAndPorts.put("https://www.unc.edu", 443);
    urlsAndPorts.put("http://www.unc.edu:5143", 5143);
    urlsAndPorts.put("https://www.unc.edu:17", 17);
    for (Map.Entry<String, Integer> entry : urlsAndPorts.entrySet()) {
        AuthScope scope = HttpClientUtil.getAuthenticationScope(entry.getKey());
        Assert.assertEquals(entry.getValue().intValue(), scope.getPort());
    }/*from www.  j a  v  a 2s  .co m*/
}

From source file:com.gargoylesoftware.htmlunit.DefaultCredentialsProvider.java

/**
 * @param port the request port for which Credentials are asked
 * @param scope the configured authorization scope
 * @return <code>true</code> if the scope's port matches the provided one
 *///from   w ww . jav a 2s.  c o  m
protected boolean matchPort(final AuthScope scope, final int port) {
    return scope.getPort() == AuthScope.ANY_PORT || scope.getPort() == port;
}