/// <summary> /// Replace the public key set on the secret ring with the corresponding key off the public ring. /// </summary> /// <param name="secretRing">Secret ring to be changed.</param> /// <param name="publicRing">Public ring containing the new public key set.</param> public static PgpSecretKeyRing ReplacePublicKeys( PgpSecretKeyRing secretRing, PgpPublicKeyRing publicRing) { IList newList = Platform.CreateArrayList(secretRing.keys.Count); foreach (PgpSecretKey sk in secretRing.keys) { PgpPublicKey pk = publicRing.GetPublicKey(sk.KeyId); newList.Add(PgpSecretKey.ReplacePublicKey(sk, pk)); } return new PgpSecretKeyRing(newList); }
public PgpPublicKeyRingBundle(global::System.Collections.IEnumerable e) { pubRings = Platform.CreateHashtable(); order = Platform.CreateArrayList(); global::System.Collections.IEnumerator enumerator = e.GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); PgpPublicKeyRing pgpPublicKeyRing = current as PgpPublicKeyRing; if (pgpPublicKeyRing == null) { throw new PgpException(Platform.GetTypeName(current) + " found where PgpPublicKeyRing expected"); } long keyId = pgpPublicKeyRing.GetPublicKey().KeyId; pubRings.Add((object)keyId, (object)pgpPublicKeyRing); order.Add((object)keyId); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public PgpPublicKeyRing GetPublicKeyRing(long keyId) { if (pubRings.Contains((object)keyId)) { return((PgpPublicKeyRing)pubRings.get_Item((object)keyId)); } global::System.Collections.IEnumerator enumerator = GetKeyRings().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpPublicKeyRing pgpPublicKeyRing = (PgpPublicKeyRing)enumerator.get_Current(); PgpPublicKey publicKey = pgpPublicKeyRing.GetPublicKey(keyId); if (publicKey != null) { return(pgpPublicKeyRing); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(null); }
public global::System.Collections.IEnumerable GetKeyRings(string userId, bool matchPartial, bool ignoreCase) { global::System.Collections.IList list = Platform.CreateArrayList(); if (ignoreCase) { userId = Platform.ToUpperInvariant(userId); } global::System.Collections.IEnumerator enumerator = GetKeyRings().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpPublicKeyRing pgpPublicKeyRing = (PgpPublicKeyRing)enumerator.get_Current(); { global::System.Collections.IEnumerator enumerator2 = pgpPublicKeyRing.GetPublicKey().GetUserIds().GetEnumerator(); try { while (enumerator2.MoveNext()) { string text = (string)enumerator2.get_Current(); string text2 = text; if (ignoreCase) { text2 = Platform.ToUpperInvariant(text2); } if (matchPartial) { if (Platform.IndexOf(text2, userId) > -1) { list.Add((object)pgpPublicKeyRing); } } else if (text2.Equals(userId)) { list.Add((object)pgpPublicKeyRing); } } } finally { global::System.IDisposable disposable2 = enumerator2 as global::System.IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new EnumerableProxy((global::System.Collections.IEnumerable)list)); }
/// <summary> /// Replace the public key set on the secret ring with the corresponding key off the public ring. /// </summary> /// <param name="secretRing">Secret ring to be changed.</param> /// <param name="publicRing">Public ring containing the new public key set.</param> public static PgpSecretKeyRing ReplacePublicKeys(PgpSecretKeyRing secretRing, PgpPublicKeyRing publicRing) { var newList = Platform.CreateArrayList(secretRing.SecretKeyCount); foreach (PgpSecretKey sk in secretRing.GetSecretKeys()) { var pk = publicRing.GetPublicKey(sk.KeyId); newList.Add(PgpSecretKey.ReplacePublicKey(sk, pk)); } return(new PgpSecretKeyRing(newList)); }
public static PgpPublicKeyRingBundle RemovePublicKeyRing(PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) long keyId = publicKeyRing.GetPublicKey().KeyId; if (!bundle.pubRings.Contains((object)keyId)) { throw new ArgumentException("Bundle does not contain a key with a keyId for the passed in ring."); } IDictionary val = Platform.CreateHashtable(bundle.pubRings); global::System.Collections.IList list = Platform.CreateArrayList((global::System.Collections.ICollection)bundle.order); val.Remove((object)keyId); list.Remove((object)keyId); return(new PgpPublicKeyRingBundle(val, list)); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle with /// the passed in public key ring removed. /// </summary> /// <param name="bundle">The <c>PgpPublicKeyRingBundle</c> the key ring is to be removed from.</param> /// <param name="publicKeyRing">The key ring to be removed.</param> /// <returns>A new <c>PgpPublicKeyRingBundle</c> not containing the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is not present.</exception> public static PgpPublicKeyRingBundle RemovePublicKeyRing( PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing) { long key = publicKeyRing.GetPublicKey().KeyId; if (!bundle.pubRings.Contains(key)) { throw new ArgumentException("Bundle does not contain a key with a keyId for the passed in ring."); } IDictionary newPubRings = Platform.CreateHashtable(bundle.pubRings); IList newOrder = Platform.CreateArrayList(bundle.order); newPubRings.Remove(key); newOrder.Remove(key); return(new PgpPublicKeyRingBundle(newPubRings, newOrder)); }
public PgpPublicKeyRingBundle( IEnumerable e) { this.pubRings = Platform.CreateHashtable(); this.order = Platform.CreateArrayList(); foreach (object obj in e) { PgpPublicKeyRing pgpPub = obj as PgpPublicKeyRing; if (pgpPub == null) { throw new PgpException(obj.GetType().FullName + " found where PgpPublicKeyRing expected"); } long key = pgpPub.GetPublicKey().KeyId; pubRings.Add(key, pgpPub); order.Add(key); } }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle and /// the passed in public key ring. /// </summary> /// <param name="bundle">The <c>PgpPublicKeyRingBundle</c> the key ring is to be added to.</param> /// <param name="publicKeyRing">The key ring to be added.</param> /// <returns>A new <c>PgpPublicKeyRingBundle</c> merging the current one with the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is already present.</exception> public static PgpPublicKeyRingBundle AddPublicKeyRing( PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing) { long key = publicKeyRing.GetPublicKey().KeyId; if (bundle.pubRings.Contains(key)) { throw new ArgumentException("Bundle already contains a key with a keyId for the passed in ring."); } IDictionary newPubRings = new Hashtable(bundle.pubRings); ArrayList newOrder = new ArrayList(bundle.order); newPubRings[key] = publicKeyRing; newOrder.Add(key); return(new PgpPublicKeyRingBundle(newPubRings, newOrder)); }
/// <summary> /// Replace the public key set on the secret ring with the corresponding key off the public ring. /// </summary> /// <param name="secretRing">Secret ring to be changed.</param> /// <param name="publicRing">Public ring containing the new public key set.</param> public static PgpSecretKeyRing ReplacePublicKeys( PgpSecretKeyRing secretRing, PgpPublicKeyRing publicRing) { IList newList = Platform.CreateArrayList(secretRing.keys.Count); foreach (PgpSecretKey sk in secretRing.keys) { PgpPublicKey pk = null; try { pk = publicRing.GetPublicKey(sk.KeyId); } catch (PgpException e) { throw new InvalidOperationException(e.Message, e); } newList.Add(PgpSecretKey.ReplacePublicKey(sk, pk)); } return(new PgpSecretKeyRing(newList)); }
public static PgpSecretKeyRing ReplacePublicKeys(PgpSecretKeyRing secretRing, PgpPublicKeyRing publicRing) { global::System.Collections.IList list = Platform.CreateArrayList(((global::System.Collections.ICollection)secretRing.keys).get_Count()); global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)secretRing.keys).GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSecretKey pgpSecretKey = (PgpSecretKey)enumerator.get_Current(); PgpPublicKey publicKey = publicRing.GetPublicKey(pgpSecretKey.KeyId); list.Add((object)PgpSecretKey.ReplacePublicKey(pgpSecretKey, publicKey)); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new PgpSecretKeyRing(list)); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle and /// the passed in public key ring. /// </summary> /// <param name="bundle">The <c>PgpPublicKeyRingBundle</c> the key ring is to be added to.</param> /// <param name="publicKeyRing">The key ring to be added.</param> /// <returns>A new <c>PgpPublicKeyRingBundle</c> merging the current one with the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is already present.</exception> public static PgpPublicKeyRingBundle AddPublicKeyRing( PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing) { long key = publicKeyRing.GetPublicKey().KeyId; if (bundle.pubRings.Contains(key)) { throw new ArgumentException("Bundle already contains a key with a keyId for the passed in ring."); } IDictionary newPubRings = Platform.CreateHashtable(bundle.pubRings); IList newOrder = Platform.CreateArrayList(bundle.order); newPubRings[key] = publicKeyRing; newOrder.Add(key); return new PgpPublicKeyRingBundle(newPubRings, newOrder); }
/// <summary> /// Return a new bundle containing the contents of the passed in bundle with /// the passed in public key ring removed. /// </summary> /// <param name="bundle">The <c>PgpPublicKeyRingBundle</c> the key ring is to be removed from.</param> /// <param name="publicKeyRing">The key ring to be removed.</param> /// <returns>A new <c>PgpPublicKeyRingBundle</c> not containing the passed in key ring.</returns> /// <exception cref="ArgumentException">If the keyId for the passed in key ring is not present.</exception> public static PgpPublicKeyRingBundle RemovePublicKeyRing( PgpPublicKeyRingBundle bundle, PgpPublicKeyRing publicKeyRing) { long key = publicKeyRing.GetPublicKey().KeyId; if (!bundle.pubRings.Contains(key)) { throw new ArgumentException("Bundle does not contain a key with a keyId for the passed in ring."); } IDictionary newPubRings = new Hashtable(bundle.pubRings); ArrayList newOrder = new ArrayList(bundle.order); newPubRings.Remove(key); newOrder.Remove(key); return new PgpPublicKeyRingBundle(newPubRings, newOrder); }
/// <summary> /// Imports a public pgp keyring. /// </summary> /// <remarks> /// Imports a public pgp keyring. /// </remarks> /// <param name="keyring">The pgp keyring.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="keyring"/> is <c>null</c>. /// </exception> public void Import (PgpPublicKeyRing keyring) { if (keyring == null) throw new ArgumentNullException (nameof (keyring)); if (PublicKeyRingBundle.Contains (keyring.GetPublicKey ().KeyId)) return; PublicKeyRingBundle = PgpPublicKeyRingBundle.AddPublicKeyRing (PublicKeyRingBundle, keyring); SavePublicKeyRingBundle (); }
/// <summary> /// Replace the public key set on the secret ring with the corresponding key off the public ring. /// </summary> /// <param name="secretRing">Secret ring to be changed.</param> /// <param name="publicRing">Public ring containing the new public key set.</param> public static PgpSecretKeyRing ReplacePublicKeys( PgpSecretKeyRing secretRing, PgpPublicKeyRing publicRing) { IList newList = new ArrayList(secretRing.keys.Count); foreach (PgpSecretKey sk in secretRing.keys) { PgpPublicKey pk = null; try { pk = publicRing.GetPublicKey(sk.KeyId); } catch (PgpException e) { throw new InvalidOperationException(e.Message, e); } newList.Add(PgpSecretKey.ReplacePublicKey(sk, pk)); } return new PgpSecretKeyRing(newList); }