Example #1
0
        /// <summary>
        /// Loads the keystore using the given
        /// {@code KeyStore.LoadStoreParameter}.
        ///
        /// <para> Note that if this KeyStore has already been loaded, it is
        /// reinitialized and loaded again from the given parameter.
        ///
        /// </para>
        /// </summary>
        /// <param name="param"> the {@code KeyStore.LoadStoreParameter}
        ///          that specifies how to load the keystore,
        ///          which may be {@code null}
        /// </param>
        /// <exception cref="IllegalArgumentException"> if the given
        ///          {@code KeyStore.LoadStoreParameter}
        ///          input is not recognized </exception>
        /// <exception cref="IOException"> if there is an I/O or format problem with the
        ///          keystore data. If the error is due to an incorrect
        ///         {@code ProtectionParameter} (e.g. wrong password)
        ///         the <seealso cref="Throwable#getCause cause"/> of the
        ///         {@code IOException} should be an
        ///         {@code UnrecoverableKeyException} </exception>
        /// <exception cref="NoSuchAlgorithmException"> if the algorithm used to check
        ///          the integrity of the keystore cannot be found </exception>
        /// <exception cref="CertificateException"> if any of the certificates in the
        ///          keystore could not be loaded
        ///
        /// @since 1.5 </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void engineLoad(KeyStore.LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, java.security.cert.CertificateException
        public virtual void EngineLoad(KeyStore.LoadStoreParameter param)
        {
            if (param == null)
            {
                EngineLoad((InputStream)null, (char[])null);
                return;
            }

            if (param is KeyStore.SimpleLoadStoreParameter)
            {
                ProtectionParameter protection = param.ProtectionParameter;
                char[] password;
                if (protection is PasswordProtection)
                {
                    password = ((PasswordProtection)protection).Password;
                }
                else if (protection is CallbackHandlerProtection)
                {
                    CallbackHandler  handler  = ((CallbackHandlerProtection)protection).CallbackHandler;
                    PasswordCallback callback = new PasswordCallback("Password: "******"Could not obtain password", e);
                    }
                    password = callback.Password;
                    callback.clearPassword();
                    if (password == null)
                    {
                        throw new NoSuchAlgorithmException("No password provided");
                    }
                }
                else
                {
                    throw new NoSuchAlgorithmException("ProtectionParameter must" + " be PasswordProtection or CallbackHandlerProtection");
                }
                EngineLoad(null, password);
                return;
            }

            throw new UnsupportedOperationException();
        }
Example #2
0
        /// <summary>
        /// Stores this keystore using the given
        /// {@code KeyStore.LoadStoreParmeter}.
        /// </summary>
        /// <param name="param"> the {@code KeyStore.LoadStoreParmeter}
        ///          that specifies how to store the keystore,
        ///          which may be {@code null}
        /// </param>
        /// <exception cref="IllegalArgumentException"> if the given
        ///          {@code KeyStore.LoadStoreParmeter}
        ///          input is not recognized </exception>
        /// <exception cref="IOException"> if there was an I/O problem with data </exception>
        /// <exception cref="NoSuchAlgorithmException"> if the appropriate data integrity
        ///          algorithm could not be found </exception>
        /// <exception cref="CertificateException"> if any of the certificates included in
        ///          the keystore data could not be stored
        ///
        /// @since 1.5 </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void engineStore(KeyStore.LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, java.security.cert.CertificateException
        public virtual void EngineStore(KeyStore.LoadStoreParameter param)
        {
            throw new UnsupportedOperationException();
        }