Exemple #1
0
 /// <summary>Creates a copy of the given credentials scope.</summary>
 /// <remarks>Creates a copy of the given credentials scope.</remarks>
 public AuthScope(Apache.Http.Auth.AuthScope authscope) : base()
 {
     Args.NotNull(authscope, "Scope");
     this.host   = authscope.GetHost();
     this.port   = authscope.GetPort();
     this.realm  = authscope.GetRealm();
     this.scheme = authscope.GetScheme();
 }
Exemple #2
0
        /// <summary>Tests if the authentication scopes match.</summary>
        /// <remarks>Tests if the authentication scopes match.</remarks>
        /// <returns>
        /// the match factor. Negative value signifies no match.
        /// Non-negative signifies a match. The greater the returned value
        /// the closer the match.
        /// </returns>
        public virtual int Match(Apache.Http.Auth.AuthScope that)
        {
            int factor = 0;

            if (LangUtils.Equals(this.scheme, that.scheme))
            {
                factor += 1;
            }
            else
            {
                if (this.scheme != AnyScheme && that.scheme != AnyScheme)
                {
                    return(-1);
                }
            }
            if (LangUtils.Equals(this.realm, that.realm))
            {
                factor += 2;
            }
            else
            {
                if (this.realm != AnyRealm && that.realm != AnyRealm)
                {
                    return(-1);
                }
            }
            if (this.port == that.port)
            {
                factor += 4;
            }
            else
            {
                if (this.port != AnyPort && that.port != AnyPort)
                {
                    return(-1);
                }
            }
            if (LangUtils.Equals(this.host, that.host))
            {
                factor += 8;
            }
            else
            {
                if (this.host != AnyHost && that.host != AnyHost)
                {
                    return(-1);
                }
            }
            return(factor);
        }
Exemple #3
0
 /// <seealso cref="object.Equals(object)">object.Equals(object)</seealso>
 public override bool Equals(object o)
 {
     if (o == null)
     {
         return(false);
     }
     if (o == this)
     {
         return(true);
     }
     if (!(o is Apache.Http.Auth.AuthScope))
     {
         return(base.Equals(o));
     }
     Apache.Http.Auth.AuthScope that = (Apache.Http.Auth.AuthScope)o;
     return(LangUtils.Equals(this.host, that.host) && this.port == that.port && LangUtils
            .Equals(this.realm, that.realm) && LangUtils.Equals(this.scheme, that.scheme));
 }