Examples of DigestScheme


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

            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

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

    private HttpContext createHttpContext() {
        // 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();
        // If we already know the realm name
        digestAuth.overrideParamter("realm", "Custom Realm Name");

        // digestAuth.overrideParamter("nonce", "MTM3NTU2OTU4MDAwNzoyYWI5YTQ5MTlhNzc5N2UxMGM5M2Y5M2ViOTc4ZmVhNg==");
        authCache.put(host, digestAuth);

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

Examples of org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme

    public void testParseHeaders1() throws Exception // no digest scheme
    {
        final DigestAuthenticator f = new DigestAuthenticator(new HttpAuthenticationFilter.Credentials("foo", "bar"), 10000);
        final Method method = DigestAuthenticator.class.getDeclaredMethod("parseAuthHeaders", List.class);
        method.setAccessible(true);
        final DigestScheme ds = (DigestScheme) method.invoke(f,
                Arrays.asList(new String[]{
                        "basic toto=tutu",
                        "basic toto=\"tutu\""
                }));
View Full Code Here

Examples of org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme

    public void testParseHeaders2() throws Exception // Two concurrent schemes
    {
        final DigestAuthenticator f = new DigestAuthenticator(new HttpAuthenticationFilter.Credentials("foo", "bar"), 10000);
        final Method method = DigestAuthenticator.class.getDeclaredMethod("parseAuthHeaders", List.class);
        method.setAccessible(true);
        final DigestScheme ds = (DigestScheme) method.invoke(f,
                Arrays.asList(new String[]{
                        "Digest realm=\"tata\"",
                        "basic  toto=\"tutu\""
                }));
        Assert.assertNotNull(ds);

        Assert.assertEquals("tata", ds.getRealm());
    }
View Full Code Here

Examples of org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme

    public void testParseHeaders3() throws Exception // Complex case, with comma inside value
    {
        final DigestAuthenticator f = new DigestAuthenticator(new HttpAuthenticationFilter.Credentials("foo", "bar"), 10000);
        final Method method = DigestAuthenticator.class.getDeclaredMethod("parseAuthHeaders", List.class);
        method.setAccessible(true);
        final DigestScheme ds = (DigestScheme) method.invoke(f,
                Arrays.asList(new String[]{
                        "digest realm=\"tata\",nonce=\"foo, bar\""
                }));

        Assert.assertNotNull(ds);
        Assert.assertEquals("tata", ds.getRealm());
        Assert.assertEquals("foo, bar", ds.getNonce());
    }
View Full Code Here

Examples of org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme

    public void testParseHeaders4() throws Exception // Spaces
    {
        final DigestAuthenticator f = new DigestAuthenticator(new HttpAuthenticationFilter.Credentials("foo", "bar"), 10000);
        final Method method = DigestAuthenticator.class.getDeclaredMethod("parseAuthHeaders", List.class);
        method.setAccessible(true);
        final DigestScheme ds = (DigestScheme) method.invoke(f,
                Arrays.asList(new String[]{
                        "    digest realm =   \"tata\"  ,  opaque=\"bar\" ,nonce=\"foo, bar\""
                }));

        Assert.assertNotNull(ds);
        Assert.assertEquals("tata", ds.getRealm());
        Assert.assertEquals("foo, bar", ds.getNonce());
        Assert.assertEquals("bar", ds.getOpaque());
    }
View Full Code Here

Examples of org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme

    public void testParseHeaders5() throws Exception // Mix of quotes and  non-quotes
    {
        final DigestAuthenticator f = new DigestAuthenticator(new HttpAuthenticationFilter.Credentials("foo", "bar"), 10000);
        final Method method = DigestAuthenticator.class.getDeclaredMethod("parseAuthHeaders", List.class);
        method.setAccessible(true);
        final DigestScheme ds = (DigestScheme) method.invoke(f,
                Arrays.asList(new String[]{
                        "    digest realm =   \"tata\"  ,  opaque =bar ,nonce=\"foo, bar\",   algorithm=md5"
                }));

        Assert.assertNotNull(ds);
        Assert.assertEquals("tata", ds.getRealm());
        Assert.assertEquals("foo, bar", ds.getNonce());
        Assert.assertEquals("bar", ds.getOpaque());
        Assert.assertEquals("MD5", ds.getAlgorithm().name());
    }
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.