Exemplo n.º 1
0
        /// <summary>
        /// Returns a Policy object of the specified type.
        ///
        /// <para> This method traverses the list of registered security providers,
        /// starting with the most preferred Provider.
        /// A new Policy object encapsulating the
        /// PolicySpi implementation from the first
        /// Provider that supports the specified type 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="type"> the specified Policy type.  See the Policy section in the
        ///    <a href=
        ///    "{@docRoot}/../technotes/guides/security/StandardNames.html#Policy">
        ///    Java Cryptography Architecture Standard Algorithm Name Documentation</a>
        ///    for a list of standard Policy types.
        /// </param>
        /// <param name="params"> parameters for the Policy, which may be null.
        /// </param>
        /// <returns> the new Policy object.
        /// </returns>
        /// <exception cref="SecurityException"> if the caller does not have permission
        ///          to get a Policy instance for the specified type.
        /// </exception>
        /// <exception cref="NullPointerException"> if the specified type is null.
        /// </exception>
        /// <exception cref="IllegalArgumentException"> if the specified parameters
        ///          are not understood by the PolicySpi implementation
        ///          from the selected Provider.
        /// </exception>
        /// <exception cref="NoSuchAlgorithmException"> if no Provider supports a PolicySpi
        ///          implementation for the specified type.
        /// </exception>
        /// <seealso cref= Provider
        /// @since 1.6 </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static Policy getInstance(String type, Policy.Parameters params) throws NoSuchAlgorithmException
        public static Policy GetInstance(String type, Policy.Parameters @params)
        {
            CheckPermission(type);
            try
            {
                GetInstance.Instance instance = GetInstance.getInstance("Policy", typeof(PolicySpi), type, @params);
                return(new PolicyDelegate((PolicySpi)instance.impl, instance.provider, type, @params));
            }
            catch (NoSuchAlgorithmException nsae)
            {
                return(HandleException(nsae));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a Policy object of the specified type.
        ///
        /// <para> A new Policy object encapsulating the
        /// PolicySpi implementation from the specified Provider
        /// object is returned.  Note that the specified Provider object
        /// does not have to be registered in the provider list.
        ///
        /// </para>
        /// </summary>
        /// <param name="type"> the specified Policy type.  See the Policy section in the
        ///    <a href=
        ///    "{@docRoot}/../technotes/guides/security/StandardNames.html#Policy">
        ///    Java Cryptography Architecture Standard Algorithm Name Documentation</a>
        ///    for a list of standard Policy types.
        /// </param>
        /// <param name="params"> parameters for the Policy, which may be null.
        /// </param>
        /// <param name="provider"> the Provider.
        /// </param>
        /// <returns> the new Policy object.
        /// </returns>
        /// <exception cref="SecurityException"> if the caller does not have permission
        ///          to get a Policy instance for the specified type.
        /// </exception>
        /// <exception cref="NullPointerException"> if the specified type is null.
        /// </exception>
        /// <exception cref="IllegalArgumentException"> if the specified Provider is null,
        ///          or if the specified parameters are not understood by
        ///          the PolicySpi implementation from the specified Provider.
        /// </exception>
        /// <exception cref="NoSuchAlgorithmException"> if the specified Provider does not
        ///          support a PolicySpi implementation for the specified type.
        /// </exception>
        /// <seealso cref= Provider
        /// @since 1.6 </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static Policy getInstance(String type, Policy.Parameters params, Provider provider) throws NoSuchAlgorithmException
        public static Policy GetInstance(String type, Policy.Parameters @params, Provider provider)
        {
            if (provider == null)
            {
                throw new IllegalArgumentException("missing provider");
            }

            CheckPermission(type);
            try
            {
                GetInstance.Instance instance = GetInstance.getInstance("Policy", typeof(PolicySpi), type, @params, provider);
                return(new PolicyDelegate((PolicySpi)instance.impl, instance.provider, type, @params));
            }
            catch (NoSuchAlgorithmException nsae)
            {
                return(HandleException(nsae));
            }
        }