Esempio n. 1
0
        /// <summary>
        /// Returns DIGEST-MD5 "digest-challenge" string.
        /// </summary>
        /// <returns>Returns DIGEST-MD5 "digest-challenge" string.</returns>
        public string ToChallenge()
        {
            /* RFC 2831 2.1.1.
             *  The server starts by sending a challenge. The data encoded in the
             *  challenge contains a string formatted according to the rules for a
             *  "digest-challenge" defined as follows:
             *
             *  digest-challenge  =
             *                      1#( realm | nonce | qop-options | stale | maxbuf | charset
             *                          algorithm | cipher-opts | auth-param )
             *
             *  realm             = "realm" "=" <"> realm-value <">
             *  realm-value       = qdstr-val
             *  nonce             = "nonce" "=" <"> nonce-value <">
             *  nonce-value       = qdstr-val
             *  qop-options       = "qop" "=" <"> qop-list <">
             *  qop-list          = 1#qop-value
             *  qop-value         = "auth" | "auth-int" | "auth-conf" | token
             *  stale             = "stale" "=" "true"
             *  maxbuf            = "maxbuf" "=" maxbuf-value
             *  maxbuf-value      = 1*DIGIT
             *  charset           = "charset" "=" "utf-8"
             *  algorithm         = "algorithm" "=" "md5-sess"
             *  cipher-opts       = "cipher" "=" <"> 1#cipher-value <">
             *  cipher-value      = "3des" | "des" | "rc4-40" | "rc4" | "rc4-56" | token
             *  auth-param        = token "=" ( token | quoted-string )
             */

            StringBuilder retVal = new StringBuilder();

            retVal.Append("realm=\"" + Net_Utils.ArrayToString(this.Realm, ",") + "\"");
            retVal.Append(",nonce=\"" + this.Nonce + "\"");
            if (this.QopOptions != null)
            {
                retVal.Append(",qop=\"" + Net_Utils.ArrayToString(this.QopOptions, ",") + "\"");
            }
            if (this.Stale)
            {
                retVal.Append(",stale=true");
            }
            if (this.Maxbuf > 0)
            {
                retVal.Append(",maxbuf=" + this.Maxbuf);
            }
            if (!string.IsNullOrEmpty(this.Charset))
            {
                retVal.Append(",charset=" + this.Charset);
            }
            retVal.Append(",algorithm=" + this.Algorithm);
            if (!string.IsNullOrEmpty(this.CipherOpts))
            {
                retVal.Append(",cipher-opts=\"" + this.CipherOpts + "\"");
            }
            //if(!string.IsNullOrEmpty(this.AuthParam)){
            //    retVal.Append("auth-param=\"" + this.AuthParam + "\"");
            //}

            return(retVal.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// Returns this as string.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("BADCHARSET " + Net_Utils.ArrayToString(m_pCharsets, " "));
 }
 /// <summary>
 /// Returns this as string.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("CAPABILITY (" + Net_Utils.ArrayToString(m_pCapabilities, " ") + ")");
 }
 /// <summary>
 /// Returns this as string.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("PERMANENTFLAGS (" + Net_Utils.ArrayToString(m_pFlags, " ") + ")");
 }