示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private KeyFactory(String algorithm) throws NoSuchAlgorithmException
        private KeyFactory(String algorithm)
        {
            this.Algorithm_Renamed = algorithm;
            List <Service> list = GetInstance.getServices("KeyFactory", algorithm);

            ServiceIterator = list.Iterator();
            // fetch and instantiate initial spi
            if (NextSpi(null) == null)
            {
                throw new NoSuchAlgorithmException(algorithm + " KeyFactory not available");
            }
        }
示例#2
0
        /// <summary>
        /// Returns a KeyPairGenerator object that generates public/private
        /// key pairs for the specified algorithm.
        ///
        /// <para> This method traverses the list of registered security Providers,
        /// starting with the most preferred Provider.
        /// A new KeyPairGenerator object encapsulating the
        /// KeyPairGeneratorSpi implementation from the first
        /// Provider that supports the specified algorithm is returned.
        ///
        /// </para>
        /// <para> Note that the list of registered providers may be retrieved via
        /// the <seealso cref="Security#getProviders() Security.getProviders()"/> method.
        ///
        /// </para>
        /// </summary>
        /// <param name="algorithm"> the standard string name of the algorithm.
        /// See the KeyPairGenerator section in the <a href=
        /// "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
        /// Java Cryptography Architecture Standard Algorithm Name Documentation</a>
        /// for information about standard algorithm names.
        /// </param>
        /// <returns> the new KeyPairGenerator object.
        /// </returns>
        /// <exception cref="NoSuchAlgorithmException"> if no Provider supports a
        ///          KeyPairGeneratorSpi implementation for the
        ///          specified algorithm.
        /// </exception>
        /// <seealso cref= Provider </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static KeyPairGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
        public static KeyPairGenerator GetInstance(String algorithm)
        {
            List <Service>     list = GetInstance.getServices("KeyPairGenerator", algorithm);
            Iterator <Service> t    = list.Iterator();

            if (t.HasNext() == false)
            {
                throw new NoSuchAlgorithmException(algorithm + " KeyPairGenerator not available");
            }
            // find a working Spi or KeyPairGenerator subclass
            NoSuchAlgorithmException failure = null;

            do
            {
                Service s = t.Next();
                try
                {
                    Instance instance = GetInstance.getInstance(s, typeof(KeyPairGeneratorSpi));
                    if (instance.impl is KeyPairGenerator)
                    {
                        return(GetInstance(instance, algorithm));
                    }
                    else
                    {
                        return(new Delegate(instance, t, algorithm));
                    }
                }
                catch (NoSuchAlgorithmException e)
                {
                    if (failure == null)
                    {
                        failure = e;
                    }
                }
            } while (t.HasNext());
            throw failure;
        }