Package org.apache.http.impl.auth

Examples of org.apache.http.impl.auth.DigestScheme


            // Create AuthCache instance
            AuthCache authCache = new BasicAuthCache();
            // Generate DIGEST scheme object, initialize it and add it to the local
            // auth cache
            DigestScheme digestAuth = new DigestScheme();
            // Suppose we already know the realm name
            digestAuth.overrideParamter("realm", "some realm");
            // Suppose we already know the expected nonce value
            digestAuth.overrideParamter("nonce", "whatever");
            authCache.put(targetHost, digestAuth);

            // Add AuthCache to the execution context
            BasicHttpContext localcontext = new BasicHttpContext();
            localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here


            // Create AuthCache instance
            AuthCache authCache = new BasicAuthCache();
            // Generate DIGEST scheme object, initialize it and add it to the local
            // auth cache
            DigestScheme digestAuth = new DigestScheme();
            // Suppose we already know the realm name
            digestAuth.overrideParamter("realm", "some realm");
            // Suppose we already know the expected nonce value
            digestAuth.overrideParamter("nonce", "whatever");
            authCache.put(targetHost, digestAuth);

            // Add AuthCache to the execution context
            HttpClientContext localContext = HttpClientContext.create();
            localContext.setAuthCache(authCache);
View Full Code Here

               
                // preemptive mode:
                if (a.isPreemptive()) {
                    AuthCache authCache = new BasicAuthCache();
                    AuthSchemeBase authScheme = a instanceof BasicAuth?
                            new BasicScheme(): new DigestScheme();
                    authCache.put(new HttpHost(urlHost, urlPort, urlProtocol), authScheme);
                    HttpClientContext localContext = HttpClientContext.create();
                    localContext.setAuthCache(authCache);
                    httpContext = localContext;
                }
View Full Code Here

        // Create AuthCache instance
        AuthCache authCache = new BasicAuthCache();
        // Generate DIGEST scheme object, initialize it and add it to the local
        // auth cache
        DigestScheme digestAuth = new DigestScheme();
        // Suppose we already know the realm name
        digestAuth.overrideParamter("realm", "some realm");       
        // Suppose we already know the expected nonce value
        digestAuth.overrideParamter("nonce", "whatever");       
        authCache.put(targetHost, digestAuth);
       
        // Add AuthCache to the execution context
        BasicHttpContext localcontext = new BasicHttpContext();
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);       
View Full Code Here

        if (authentication.getScheme() == Authentication.Scheme.BASIC) {
          BasicScheme basic = new BasicScheme();
          scheme = basic;
        } else {
          //http://stackoverflow.com/questions/2954434/apache-httpclient-digest-authentication
          DigestScheme digest = new DigestScheme();
          digest.overrideParamter("realm", authentication.getRealm());
          digest.overrideParamter("nonce", authentication.getNonce());
          scheme = digest;
        }
        HttpHost host = new HttpHost(getHostUrl().getHost(), getHostUrl().getPort(), getHostUrl().getProtocol());
        AuthCache authCache = new BasicAuthCache();
        authCache.put(host, scheme);
View Full Code Here

    public String postWithDigestAuth(final String url, final String file) {
        String responseBodyAsString = "";
        try {
            final CloseableHttpResponse response = httpClient.execute(targetHost,
                    httpPost(url, MultipartEntityBuilder.create().addPart("bin", new FileBody(new File(file))).build()),
                    setAuth(targetHost, new DigestScheme()));
            responseBodyAsString = IOUtils.toString(response.getEntity().getContent());
            handler.logOutput("Http status: " + response.getStatusLine().getStatusCode(), true);
            InstallLog.getInstance().info("Http status: " + response.getStatusLine().getStatusCode());
            response.close();
        } catch (final IOException ex) {
View Full Code Here

        int status = 0;
        try {
            final HttpPost httPost = httpPost(url, new StringEntity(stringEntity));
            httPost.addHeader("Content-Type", ContentType.APPLICATION_JSON.getMimeType());
            final CloseableHttpResponse response = httpClient.execute(
                    targetHost, httPost, setAuth(targetHost, new DigestScheme()));
            status = response.getStatusLine().getStatusCode();
            handler.logOutput("Http status: " + status, true);
            InstallLog.getInstance().info("Http status: " + status);

            response.close();
View Full Code Here

                new UsernamePasswordCredentials("username", "password"));

        BasicHttpContext localcontext = new BasicHttpContext();
        // Generate DIGEST scheme object, initialize it and stick it to
        // the local execution context
        DigestScheme digestAuth = new DigestScheme();
        // Suppose we already know the realm name
        digestAuth.overrideParamter("realm", "some realm");       
        // Suppose we already know the expected nonce value
        digestAuth.overrideParamter("nonce", "whatever");       
        localcontext.setAttribute("preemptive-auth", digestAuth);
       
        // Add as the first request interceptor
        httpclient.addRequestInterceptor(new PreemptiveAuth(), 0);
        // Add as the last response interceptor
View Full Code Here

        // Create AuthCache instance
        AuthCache authCache = new BasicAuthCache();
        // Generate DIGEST scheme object, initialize it and add it to the local
        // auth cache
        DigestScheme digestAuth = new DigestScheme();
        // Suppose we already know the realm name
        digestAuth.overrideParamter("realm", "some realm");
        // Suppose we already know the expected nonce value
        digestAuth.overrideParamter("nonce", "whatever");
        authCache.put(targetHost, digestAuth);

        // Add AuthCache to the execution context
        BasicHttpContext localcontext = new BasicHttpContext();
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here

            httpclient.getCredentialsProvider().setCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials("user1", "user1Pass"));

            // Create AuthCache instance
            final AuthCache authCache = new BasicAuthCache();
            // Generate DIGEST scheme object, initialize it and add it to the local auth cache
            final DigestScheme digestAuth = new DigestScheme();
            // Suppose we already know the realm name
            digestAuth.overrideParamter("realm", "Custom Realm Name");

            // digestAuth.overrideParamter("nonce", "whatever");
            authCache.put(targetHost, digestAuth);

            // Add AuthCache to the execution context
View Full Code Here

TOP

Related Classes of org.apache.http.impl.auth.DigestScheme

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.