Ejemplo n.º 1
0
        /// <summary>
        /// Writes this object out to a stream (i.e., serializes it).
        ///
        /// @serialData An initial {@code String} denoting the
        /// {@code type} is followed by a {@code String} denoting the
        /// {@code name} is followed by a {@code String} denoting the
        /// {@code actions} is followed by an {@code int} indicating the
        /// number of certificates to follow
        /// (a value of "zero" denotes that there are no certificates associated
        /// with this object).
        /// Each certificate is written out starting with a {@code String}
        /// denoting the certificate type, followed by an
        /// {@code int} specifying the length of the certificate encoding,
        /// followed by the certificate encoding itself which is written out as an
        /// array of bytes.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException
        private void WriteObject(java.io.ObjectOutputStream oos)
        {
            oos.DefaultWriteObject();

            if (Certs == null || Certs.Length == 0)
            {
                oos.WriteInt(0);
            }
            else
            {
                // write out the total number of certs
                oos.WriteInt(Certs.Length);
                // write out each cert, including its type
                for (int i = 0; i < Certs.Length; i++)
                {
                    java.security.cert.Certificate cert = Certs[i];
                    try
                    {
                        oos.WriteUTF(cert.Type);
                        sbyte[] encoded = cert.Encoded;
                        oos.WriteInt(encoded.Length);
                        oos.Write(encoded);
                    }
                    catch (CertificateEncodingException cee)
                    {
                        throw new IOException(cee.Message);
                    }
                }
            }
        }