Examples of DigestScheme


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

        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\""));

        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();

        this.authState.setState(AuthProtocolState.CHALLENGED);
        this.authState.update(new DigestScheme(), this.credentials);

        Assert.assertTrue(this.httpAuthenticator.authenticate(host,
                response, authStrategy, this.authState, this.context));

        Assert.assertEquals(AuthProtocolState.HANDSHAKE, this.authState.getState());
View Full Code Here

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

                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

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

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
            HttpClientContext localContext = HttpClientContext.create();
            localContext.setAuthCache(authCache);
View Full Code Here

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

               
                // 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

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

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

        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

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

    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

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

        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

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

                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
TOP
Copyright © 2018 www.massapi.com. 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.