Beispiel #1
0
        /// <summary>
        /// Returns a hashcode value for this certificate from its
        /// encoded form.
        /// </summary>
        /// <returns> the hashcode value. </returns>
        public override int HashCode()
        {
            int h = Hash;

            if (h == -1)
            {
                try
                {
                    h = Arrays.HashCode(X509CertImpl.getEncodedInternal(this));
                }
                catch (CertificateException)
                {
                    h = 0;
                }
                Hash = h;
            }
            return(h);
        }
Beispiel #2
0
        /// <summary>
        /// Compares this certificate for equality with the specified
        /// object. If the {@code other} object is an
        /// {@code instanceof} {@code Certificate}, then
        /// its encoded form is retrieved and compared with the
        /// encoded form of this certificate.
        /// </summary>
        /// <param name="other"> the object to test for equality with this certificate. </param>
        /// <returns> true iff the encoded forms of the two certificates
        /// match, false otherwise. </returns>
        public override bool Equals(Object other)
        {
            if (this == other)
            {
                return(true);
            }
            if (!(other is Certificate))
            {
                return(false);
            }
            try
            {
                sbyte[] thisCert  = X509CertImpl.getEncodedInternal(this);
                sbyte[] otherCert = X509CertImpl.getEncodedInternal((Certificate)other);

                return(Arrays.Equals(thisCert, otherCert));
            }
            catch (CertificateException)
            {
                return(false);
            }
        }