Package org.glassfish.jersey.client.authentication.DigestAuthenticator

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


    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

    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

    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

    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

Related Classes of org.glassfish.jersey.client.authentication.DigestAuthenticator.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.