示例#1
0
 /// <summary>
 /// Adds an observer to the set of observers for this object, provided
 /// that it is not the same as some observer already in the set.
 /// The order in which notifications will be delivered to multiple
 /// observers is not specified. See the class comment.
 /// </summary>
 /// <param name="o">   an observer to be added. </param>
 /// <exception cref="NullPointerException">   if the parameter o is null. </exception>
 public virtual void AddObserver(Observer o)
 {
     lock (this)
     {
         if (o == null)
         {
             throw new NullPointerException();
         }
         if (!Obs.Contains(o))
         {
             Obs.AddElement(o);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Adds a certificate for this identity. If the identity has a public
        /// key, the public key in the certificate must be the same, and if
        /// the identity does not have a public key, the identity's
        /// public key is set to be that specified in the certificate.
        ///
        /// <para>First, if there is a security manager, its {@code checkSecurityAccess}
        /// method is called with {@code "addIdentityCertificate"}
        /// as its argument to see if it's ok to add a certificate.
        ///
        /// </para>
        /// </summary>
        /// <param name="certificate"> the certificate to be added.
        /// </param>
        /// <exception cref="KeyManagementException"> if the certificate is not valid,
        /// if the public key in the certificate being added conflicts with
        /// this identity's public key, or if another exception occurs.
        /// </exception>
        /// <exception cref="SecurityException">  if a security manager exists and its
        /// {@code checkSecurityAccess} method doesn't allow
        /// adding a certificate.
        /// </exception>
        /// <seealso cref= SecurityManager#checkSecurityAccess </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void addCertificate(Certificate certificate) throws KeyManagementException
        public virtual void AddCertificate(Certificate certificate)
        {
            Check("addIdentityCertificate");

            if (Certificates_Renamed == null)
            {
                Certificates_Renamed = new Vector <Certificate>();
            }
            if (PublicKey_Renamed != null)
            {
                if (!KeyEquals(PublicKey_Renamed, certificate.PublicKey))
                {
                    throw new KeyManagementException("public key different from cert public key");
                }
            }
            else
            {
                PublicKey_Renamed = certificate.PublicKey;
            }
            Certificates_Renamed.AddElement(certificate);
        }