Package org.fcrepo.common.http

Examples of org.fcrepo.common.http.PreemptiveAuth


            httpHost =
                    new HttpHost(url.getHost(), url.getPort(), url
                            .getProtocol());

            if (username != null && password != null) {
                client = new PreemptiveAuth();

                AuthScope authScope =
                     new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
                Credentials credentials =
                        new UsernamePasswordCredentials(username, password);
View Full Code Here


    public InputStream get(String url) throws IOException {
        HttpGet get = null;
        boolean ok = false;
        try {
            // don't bother with challenges
            DefaultHttpClient client = new PreemptiveAuth(m_cManager);
            client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20000);
            client.getCredentialsProvider().setCredentials(m_authScope, m_creds);
            int redirectCount = 0; // how many redirects did we follow
            int resultCode = 300; // not really, but enter the loop that way
            Dimension d = null;
            HttpResponse response = null;
            while (resultCode > 299 && resultCode < 400 && redirectCount < 25) {
                get = new HttpGet(url);
                client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
                if (Administrator.INSTANCE != null) {
                    d = Administrator.PROGRESS.getSize();
                    // if they're using Administrator, tell them we're downloading...
                    Administrator.PROGRESS.setString("Downloading " + url
                            + " . . .");
                    Administrator.PROGRESS.setValue(100);
                    Administrator.PROGRESS.paintImmediately(0, 0, (int) d
                            .getWidth() - 1, (int) d.getHeight() - 1);
                }
                response = client.execute(get);
                resultCode = response.getStatusLine().getStatusCode();
                if (resultCode > 299 && resultCode < 400) {
                    redirectCount++;
                    url = response.getFirstHeader(HttpHeaders.LOCATION).getValue();
                }
View Full Code Here

    }
   
    public DefaultHttpClient getHttpClient(boolean followRedirects, boolean preemptiveAuth) {
        // handle pre-emptive AuthN
        getConnectionManager();
        DefaultHttpClient client = preemptiveAuth ? new PreemptiveAuth(m_cManager) :
            new DefaultHttpClient(m_cManager);
        // set the connection timeout properties
        client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, TIMEOUT_SECONDS * 1000);
        client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, SOCKET_TIMEOUT_SECONDS * 1000);
        // follow redirects
View Full Code Here

        httpMethod.setHeader(HttpHeaders.CONNECTION, "Keep-Alive");
        return httpMethod;
    }

    private HttpClient getHttpClient() {
        DefaultHttpClient client = new PreemptiveAuth();
        client.getCredentialsProvider().setCredentials(
                new AuthScope(host, Integer.valueOf(port), "realm"),
                new UsernamePasswordCredentials(username, password));
        return client;
    }
View Full Code Here


// helper methods

    private HttpClient getClient(boolean auth) {
        DefaultHttpClient client = new PreemptiveAuth();
        if (auth) {
            client
                    .getCredentialsProvider()
                    .setCredentials(new AuthScope(getHost(), Integer
                            .valueOf(getPort())),
                                    new UsernamePasswordCredentials(getUsername(),
                                                                    getPassword()));
View Full Code Here

TOP

Related Classes of org.fcrepo.common.http.PreemptiveAuth

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.