public static WwwAuthenticate buildFromString(String challenge)
        {
            WwwAuthenticate answer = new WwwAuthenticate();

            AuthenticationHeaderScanner authenticationHeaderScanner = new AuthenticationHeaderScanner(challenge);

            authenticationHeaderScanner.scanPastDigestString();

            String name = authenticationHeaderScanner.scanName();

            while (null != name) 
            {
                if ("nonce".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._nonce = value;
                }
                else if ("opaque".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._opaque = value;

                }
                else if ("qop".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._qop = value;

                }
                else if ("realm".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._realm = value;

                }
                else
                {
                    // 'auth-param' in section 3.2.1 of RFC-2617 says ... 
                    // Any unrecognized directive MUST be ignored.

                    String value = authenticationHeaderScanner.scanValue();

                    String warning = String.Format("unrecognised name-value pair. name = '{0}', value = '{1}'", name, value);
                    log.warn(warning);

                }
                name = authenticationHeaderScanner.scanName();

            }

            return answer;
        }
        ///////////////////////////////////////////////////////////////////////


        public static Authorization buildFromString( String credentials ) {

            Authorization answer = new Authorization();

            AuthenticationHeaderScanner authenticationHeaderScanner = new AuthenticationHeaderScanner(credentials);

            authenticationHeaderScanner.scanPastDigestString();


            String name = authenticationHeaderScanner.scanName();

            while (null != name)
            {
                if ("cnonce".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._cnonce = value;
                }
                else if ("nc".Equals(name))
                {
                    uint value = authenticationHeaderScanner.scanHexUInt32();

                    answer._nc = value;
                }
                else if ("nonce".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._nonce = value;

                }
                else if ("opaque".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._opaque = value;
                }
                else if ("qop".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanValue();

                    answer._qop = value;
                }
                else if ("realm".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._realm = value;

                }
                else if ("response".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._response = value;
                }
                else if ("uri".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._uri = value;

                }
                else if ("username".Equals(name))
                {

                    String value = authenticationHeaderScanner.scanQuotedValue();
                    log.debug(value, "value");

                    answer._username = value;

                }
                else
                {
                    // 'auth-param' is permitted according to 3.2.2 of RFC-2617
                    // 'auth-param' in section 3.2.1 of RFC-2617 says ... 
                    // Any unrecognized directive MUST be ignored.
                    // 

                    String value = authenticationHeaderScanner.scanValue();

                    String warning = String.Format("unrecognised name-value pair. name = '{0}', value = '{1}'", name, value);
                    log.warn(warning);

                }

                name = authenticationHeaderScanner.scanName();

            }


            return answer;

        }
        ///////////////////////////////////////////////////////////////////////

        public static AuthenticationInfo buildFromString(String authInfo)
        {
            AuthenticationInfo answer = new AuthenticationInfo();

            AuthenticationHeaderScanner authenticationHeaderScanner = new AuthenticationHeaderScanner(authInfo);

            authenticationHeaderScanner.scanPastDigestString();

            String name = authenticationHeaderScanner.scanName();

            while (null != name)
            {
                if ("cnonce".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._cnonce = value;
                }
                else if ("nextnonce".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._nextnonce = value;
                    
                }
                else if ("nc".Equals(name))
                {
                    uint value = authenticationHeaderScanner.scanHexUInt32();

                    answer._nc = value;
                }
                else if ("qop".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanValue();

                    answer._qop = value;
                }
                else if ("rspauth".Equals(name))
                {
                    String value = authenticationHeaderScanner.scanQuotedValue();

                    answer._rspauth = value;

                } else {

                    // 'auth-param' is not permitted according to 3.2.3 of RFC-2617
                    // 'auth-param' in section 3.2.1 of RFC-2617 says ... 
                    // Any unrecognized directive MUST be ignored.
                    //
                    // For consistency, we mimic the behaviour specified in sections 3.2.1 & 3.2.2 in relation to 'auth-param'

                    String value = authenticationHeaderScanner.scanQuotedValue();
                    String warning = String.Format("unrecognised name-value pair. name = '{0}', value = '{1}'", name, value);
                    log.warn(warning);

                }

                name = authenticationHeaderScanner.scanName();

            }




            return answer;

        }