/// <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);
                    }
                }
            }
        }
Example #2
0
 public override global::java.lang.String engineGetCertificateAlias(java.security.cert.Certificate arg0)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallObjectMethod(this.JvmHandle, global::java.security.KeyStoreSpi_._engineGetCertificateAlias14845, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as java.lang.String);
     }
     else
     {
         return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::java.security.KeyStoreSpi_.staticClass, global::java.security.KeyStoreSpi_._engineGetCertificateAlias14845, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as java.lang.String);
     }
 }
Example #3
0
 public override void engineSetCertificateEntry(java.lang.String arg0, java.security.cert.Certificate arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     if (!IsClrObject)
     {
         @__env.CallVoidMethod(this.JvmHandle, global::java.security.KeyStoreSpi_._engineSetCertificateEntry14838, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
     else
     {
         @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::java.security.KeyStoreSpi_.staticClass, global::java.security.KeyStoreSpi_._engineSetCertificateEntry14838, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1));
     }
 }
Example #4
0
 public abstract global::java.lang.String engineGetCertificateAlias(java.security.cert.Certificate arg0);
Example #5
0
 public abstract void engineSetCertificateEntry(java.lang.String arg0, java.security.cert.Certificate arg1);
Example #6
0
        /// <summary>
        /// Resolves any unresolved permissions of type p.
        /// </summary>
        /// <param name="p"> the type of unresolved permission to resolve
        /// </param>
        /// <returns> PermissionCollection containing the unresolved permissions,
        ///  or null if there were no unresolved permissions of type p.
        ///  </returns>
        private PermissionCollection GetUnresolvedPermissions(Permission p)
        {
            // Called from within synchronized method so permsMap doesn't need lock

            UnresolvedPermissionCollection uc = (UnresolvedPermissionCollection)PermsMap[typeof(UnresolvedPermission)];

            // we have no unresolved permissions if uc is null
            if (uc == null)
            {
                return(null);
            }

            IList <UnresolvedPermission> unresolvedPerms = uc.GetUnresolvedPermissions(p);

            // we have no unresolved permissions of this type if unresolvedPerms is null
            if (unresolvedPerms == null)
            {
                return(null);
            }

            java.security.cert.Certificate[] certs = null;

            Object[] signers = p.GetType().Signers;

            int n = 0;

            if (signers != null)
            {
                for (int j = 0; j < signers.Length; j++)
                {
                    if (signers[j] is java.security.cert.Certificate)
                    {
                        n++;
                    }
                }
                certs = new java.security.cert.Certificate[n];
                n     = 0;
                for (int j = 0; j < signers.Length; j++)
                {
                    if (signers[j] is java.security.cert.Certificate)
                    {
                        certs[n++] = (java.security.cert.Certificate)signers[j];
                    }
                }
            }

            PermissionCollection pc = null;

            lock (unresolvedPerms)
            {
                int len = unresolvedPerms.Count;
                for (int i = 0; i < len; i++)
                {
                    UnresolvedPermission up   = unresolvedPerms[i];
                    Permission           perm = up.Resolve(p, certs);
                    if (perm != null)
                    {
                        if (pc == null)
                        {
                            pc = p.NewPermissionCollection();
                            if (pc == null)
                            {
                                pc = new PermissionsHash();
                            }
                        }
                        pc.Add(perm);
                    }
                }
            }
            return(pc);
        }