Beispiel #1
0
        /// <summary>
        /// Creates an instance of {@code PKIXParameters} that
        /// populates the set of most-trusted CAs from the trusted
        /// certificate entries contained in the specified {@code KeyStore}.
        /// Only keystore entries that contain trusted {@code X509Certificates}
        /// are considered; all other certificate types are ignored.
        /// </summary>
        /// <param name="keystore"> a {@code KeyStore} from which the set of
        /// most-trusted CAs will be populated </param>
        /// <exception cref="KeyStoreException"> if the keystore has not been initialized </exception>
        /// <exception cref="InvalidAlgorithmParameterException"> if the keystore does
        /// not contain at least one trusted certificate entry </exception>
        /// <exception cref="NullPointerException"> if the keystore is {@code null} </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public PKIXParameters(java.security.KeyStore keystore) throws java.security.KeyStoreException, java.security.InvalidAlgorithmParameterException
        public PKIXParameters(KeyStore keystore)
        {
            if (keystore == null)
            {
                throw new NullPointerException("the keystore parameter must be " + "non-null");
            }
            Set <TrustAnchor>    hashSet = new HashSet <TrustAnchor>();
            IEnumerator <String> aliases = keystore.Aliases();

            while (aliases.MoveNext())
            {
                String alias = aliases.Current;
                if (keystore.IsCertificateEntry(alias))
                {
                    Certificate cert = keystore.GetCertificate(alias);
                    if (cert is X509Certificate)
                    {
                        hashSet.Add(new TrustAnchor((X509Certificate)cert, null));
                    }
                }
            }
            TrustAnchors = hashSet;
            this.UnmodInitialPolicies     = System.Linq.Enumerable.Empty <String>();
            this.CertPathCheckers_Renamed = new List <PKIXCertPathChecker>();
            this.CertStores_Renamed       = new List <CertStore>();
        }
        public void RefreshItems()
        {
            _listItems.Clear();
            foreach (String alias in KeyStore.Aliases)
            {
                KeyStoreEntryType entryType;
                if (KeyStore.IsCertificateEntry(alias))
                {
                    entryType = KeyStoreEntryType.TrustCertEntry;
                }
                else if (KeyStore.IsKeyEntry(alias) && KeyStore.GetCertificateChain(alias) != null && KeyStore.GetCertificateChain(alias).Length != 0)
                {
                    entryType = KeyStoreEntryType.KeyPairEntry;
                }
                else
                {
                    entryType = KeyStoreEntryType.KeyEntry;
                }

                _listItems.Add(new ListItemEntry(entryType, alias, KeyStore.GetCertificate(alias).Certificate));
            }
        }