Package sun.net.www

Examples of sun.net.www.HeaderParser


     * returning true means the request can be retried with the same userid/password
     * returning false means we have to go back to the user to ask for a new
     * username password.
     */
    boolean isAuthorizationStale (String header) {
        HeaderParser p = new HeaderParser (header);
        String s = p.findValue ("stale");
        if (s == null || !s.equals("true"))
            return false;
        String newNonce = p.findValue ("nonce");
        if (newNonce == null || "".equals(newNonce)) {
            return false;
        }
        params.setNonce (newNonce);
        return true;
View Full Code Here


                ncstring = zeroPad [len] + ncstring;
        }
        try {
            String expected = computeDigest(false, username,passwd,realm,
                                        method, uri, nonce, cnonce, ncstring);
            HeaderParser p = new HeaderParser (header);
            String rspauth = p.findValue ("rspauth");
            if (rspauth == null) {
                throw new ProtocolException ("No digest in response");
            }
            if (!rspauth.equals (expected)) {
                throw new ProtocolException ("Response digest invalid");
            }
            /* Check if there is a nextnonce field */
            String nextnonce = p.findValue ("nextnonce");
            if (nextnonce != null && ! "".equals(nextnonce)) {
                params.setNonce (nextnonce);
            }

        } catch (NoSuchAlgorithmException ex) {
View Full Code Here

        Iterator iter = head.multiValueIterator ("Foo");
        checkHeader (iter, s1_Foo);
        iter = head.multiValueIterator ("Fub");
        checkHeader (iter, s1_Fub);

        HeaderParser hp = new HeaderParser (s2).subsequence (1,12);
        check (hp, s23_expect);

        hp = new HeaderParser (s3).subsequence (1,12);
        check (hp, s23_expect);

        hp = new HeaderParser (s3).subsequence (0,11);
        check (hp, s23_expect1);

        hp = new HeaderParser (s2).subsequence (4,6);
        check (hp, s23_expect2);
    }
View Full Code Here

    }

    static void checkHeader (Iterator iter, String[][][] expect) {
        for (int i=0; iter.hasNext (); ) {
            String s = (String) iter.next();
            HeaderParser p = new HeaderParser (s);
            boolean empty = check (p, expect[i]);
            if (!empty) {
                i++;
            }
        }
View Full Code Here

    static String test = "WWW-Authenticate: Digest realm=\"testrealm\","+
                      "nonce=\"Ovqrpw==b20ff3b0ea3f3a18f1d6293331edaafdb98f5bef\", algorithm=MD5,"+
                      "domain=\"http://bakedbean.ireland/authtest/\", qop=\"auth\"";

    public static void main (String args[]) {
        HeaderParser hp = new HeaderParser (test);
        String r1 = hp.findValue ("nonce");
        if (r1 == null || !r1.equals ("Ovqrpw==b20ff3b0ea3f3a18f1d6293331edaafdb98f5bef")) {
            throw new RuntimeException ("first findValue returned wrong result: " + r1);
        }
        r1 = hp.findValue ("AlGoRiThm");
        if (r1 == null || !r1.equals ("MD5")) {
            throw new RuntimeException ("second findValue returned wrong result: " + r1);
        }
    }
View Full Code Here

TOP

Related Classes of sun.net.www.HeaderParser

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.