Package org.apache.commons.httpclient.auth

Examples of org.apache.commons.httpclient.auth.HttpAuthRealm


     * @param token the {@link HttpAuthRealm authentication realm token}
     * @return the credentials
     *
     */
    private static Credentials matchCredentials(HashMap map, HttpAuthRealm token) {
        HttpAuthRealm key = token;
        Credentials creds = (Credentials) map.get(key);
        if (creds == null && token.getScheme() != null) {
            key = new HttpAuthRealm(token.getHost(), token.getPort(), token.getRealm());
            creds = (Credentials) map.get(key);
        }
        if (creds == null && token.getRealm() != null) {
            key = new HttpAuthRealm(token.getHost(), token.getPort());
            creds = (Credentials) map.get(key);
        }
        if (creds == null && token.getPort() >= 0) {
            key = new HttpAuthRealm(token.getHost(), -1);
            creds = (Credentials) map.get(key);
        }
        if (creds == null && token.getHost() != null) {
            key = new HttpAuthRealm();
            creds = (Credentials) map.get(key);
        }
        return creds;
    }
View Full Code Here


     * @see #setCredentials(String, String, Credentials)
     */
   
    public synchronized Credentials getCredentials(String realm, String host) {
        LOG.trace("enter HttpState.getCredentials(String, String");
        return matchCredentials(this.credMap, new HttpAuthRealm(host, realm));
    }
View Full Code Here

        String realm,
        String proxyHost,
        Credentials credentials
    ) {
        LOG.trace("enter HttpState.setProxyCredentials(String, String, Credentials");
        proxyCred.put(new HttpAuthRealm(proxyHost, realm), credentials);
    }
View Full Code Here

     * @return the credentials
     * @see #setProxyCredentials(String, String, Credentials)
     */
    public synchronized Credentials getProxyCredentials(String realm, String proxyHost) {
       LOG.trace("enter HttpState.getCredentials(String, String");
        return matchCredentials(this.proxyCred, new HttpAuthRealm(proxyHost, realm));
    }
View Full Code Here

        proxyclient.getHostConfiguration().setHost("www.yahoo.com");
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("10.0.1.1", 3128);
        // set the proxy credentials, only necessary for authenticating proxies
        proxyclient.getState().setProxyCredentials(
            new HttpAuthRealm("10.0.1.1", 3128, null),
            new UsernamePasswordCredentials("proxy", "proxy"));
       
        // create the socket
        ProxyClient.ConnectResponse response = proxyclient.connect();
       
View Full Code Here

            String host = conn.getVirtualHost();
            if (host == null) {
                host = conn.getHost();
            }
            int port = conn.getPort();
            HttpAuthRealm realm = new HttpAuthRealm(
                host, port,
                authscheme.getRealm(),
                authscheme.getSchemeName())
            if (LOG.isDebugEnabled()) {
                LOG.debug("Authenticating with " + realm);
View Full Code Here

        AuthScheme authscheme = method.getProxyAuthState().getAuthScheme();
        if (authscheme == null) {
            return;
        }
        if ((this.authProcess == AUTH_PROXY_REQUIRED) || (!authscheme.isConnectionBased())) {
            HttpAuthRealm realm = new HttpAuthRealm(
                conn.getProxyHost(), conn.getProxyPort(),
                authscheme.getRealm(),
                authscheme.getSchemeName())
            if (LOG.isDebugEnabled()) {
                LOG.debug("Authenticating with " + realm);
View Full Code Here

        String host = conn.getVirtualHost();
        if (host == null) {
            host = conn.getHost();
        }
        int port = conn.getPort();
        HttpAuthRealm realm = new HttpAuthRealm(
            host, port,
            authscheme.getRealm(),
            authscheme.getSchemeName())

        if ((this.authProcess == AUTH_WWW_REQUIRED) && (authscheme.isComplete())) {
View Full Code Here

            }
        }
        if (authscheme == null) {
            return false;
        }
        HttpAuthRealm realm = new HttpAuthRealm(
            conn.getProxyHost(), conn.getProxyPort(),
            authscheme.getRealm(),
            authscheme.getSchemeName())

        if ((this.authProcess == AUTH_PROXY_REQUIRED) && (authscheme.isComplete())) {
View Full Code Here

    // ------------------------------------------------------------------ Tests

    public void testSimpleAuthGet() throws Exception {
        HttpClient client = createHttpClient();
        client.getState().setCredentials(
            new HttpAuthRealm(getHost(), getPort(), "BasicAuthServlet"),
            new UsernamePasswordCredentials("jakarta","commons"));
        GetMethod method = new GetMethod("/" + getWebappContext() + "/auth/basic");
       
        try {
            client.executeMethod(method);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.auth.HttpAuthRealm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.