示例#1
0
        /// <summary>
        /// Deletes the specified keychain.
        /// </summary>
        /// <param name="keychain">Keychain.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="keychain"/> was <c>null</c>.
        /// </exception>
        /// <exception cref="System.ObjectDisposedException">
        /// <paramref name="keychain"/> has been disposed.
        /// </exception>
        /// <exception cref="System.Exception">
        /// An unknown error deleting the keychain occurred.
        /// </exception>
        public static void Delete(SecKeychain keychain)
        {
            if (keychain == null)
            {
                throw new ArgumentNullException("keychain");
            }

            if (keychain.disposed)
            {
                throw new ObjectDisposedException("SecKeychain");
            }

            if (keychain.Handle == IntPtr.Zero)
            {
                throw new InvalidOperationException();
            }

            var status = SecKeychainDelete(keychain.Handle);

            if (status != OSStatus.Ok)
            {
                throw new Exception(GetError(status));
            }

            keychain.Dispose();
        }
示例#2
0
        public MacSecureMimeContext(string path, string password)
        {
            if (path == null)
                throw new ArgumentNullException ("path");

            if (password == null)
                throw new ArgumentNullException ("password");

            keychain = SecKeychain.Create (path, password);
        }
示例#3
0
        /// <summary>
        /// Deletes the specified keychain.
        /// </summary>
        /// <param name="keychain">Keychain.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="keychain"/> was <c>null</c>.
        /// </exception>
        /// <exception cref="System.ObjectDisposedException">
        /// <paramref name="keychain"/> has been disposed.
        /// </exception>
        /// <exception cref="System.Exception">
        /// An unknown error deleting the keychain occurred.
        /// </exception>
        public static void Delete(SecKeychain keychain)
        {
            if (keychain == null)
                throw new ArgumentNullException ("keychain");

            if (keychain.disposed)
                throw new ObjectDisposedException ("SecKeychain");

            if (keychain.Handle == IntPtr.Zero)
                throw new InvalidOperationException ();

            var status = SecKeychainDelete (keychain.Handle);
            if (status != OSStatus.Ok)
                throw new Exception (GetError (status));

            keychain.Dispose ();
        }
示例#4
0
 public MacSecureMimeContext()
 {
     keychain = SecKeychain.Default;
 }
示例#5
0
        /// <summary>
        /// Releases all resources used by the <see cref="MimeKit.Cryptography.MacSecureMimeContext"/> object.
        /// </summary>
        /// <param name="disposing">If <c>true</c>, this method is being called by
        /// <see cref="MimeKit.Cryptography.CryptographyContext.Dispose"/>;
        /// otherwise it is being called by the finalizer.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && keychain != SecKeychain.Default) {
                keychain.Dispose ();
                keychain = null;
            }

            base.Dispose (disposing);
        }