/// <summary>Remove a certification from the key.</summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="certification">The certfication to be removed.</param> /// <returns>The modified key, null if the certification was not found.</returns> public static PgpPublicKey RemoveCertification( PgpPublicKey key, PgpSignature certification) { PgpPublicKey returnKey = new PgpPublicKey(key); IList sigs = returnKey.subSigs != null ? returnKey.subSigs : returnKey.keySigs; // bool found = sigs.Remove(certification); int pos = sigs.IndexOf(certification); bool found = pos >= 0; if (found) { sigs.RemoveAt(pos); } else { foreach (String id in key.GetUserIds()) { foreach (object sig in key.GetSignaturesForId(id)) { // TODO Is this the right type of equality test? if (certification == sig) { found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } } if (!found) { foreach (PgpUserAttributeSubpacketVector id in key.GetUserAttributes()) { foreach (object sig in key.GetSignaturesForUserAttribute(id)) { // TODO Is this the right type of equality test? if (certification == sig) { found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } } } } return(returnKey); }
/// <summary>Remove a certification from the key.</summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="certification">The certfication to be removed.</param> /// <returns>The modified key, null if the certification was not found.</returns> public static PgpPublicKey RemoveCertification(PgpPublicKey key, PgpSignature certification) { var returnKey = new PgpPublicKey(key); var sigs = returnKey.SubSigs ?? returnKey.KeySigs; // bool found = sigs.Remove(certification); var pos = sigs.IndexOf(certification); var found = pos >= 0; if (found) { sigs.RemoveAt(pos); } else { foreach (string id in key.GetUserIds()) { foreach (var sig in key.GetSignaturesForId(id)) { // TODO Is this the right type of equality test? if (certification != sig) { continue; } found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } if (!found) { foreach (IPgpUserAttributeSubpacketVector id in key.GetUserAttributes()) { foreach (var sig in key.GetSignaturesForUserAttribute(id)) { // TODO Is this the right type of equality test? if (certification != sig) { continue; } // found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } } } return(returnKey); }
/// <summary>Remove a certification from the key.</summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="certification">The certfication to be removed.</param> /// <returns>The modified key, null if the certification was not found.</returns> public static PgpPublicKey RemoveCertification(PgpPublicKey key, PgpSignature certification) { var returnKey = new PgpPublicKey(key); var sigs = returnKey.SubSigs ?? returnKey.KeySigs; // bool found = sigs.Remove(certification); var pos = sigs.IndexOf(certification); var found = pos >= 0; if (found) { sigs.RemoveAt(pos); } else { foreach (string id in key.GetUserIds()) { foreach (var sig in key.GetSignaturesForId(id)) { // TODO Is this the right type of equality test? if (certification != sig) continue; found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } if (!found) { foreach (IPgpUserAttributeSubpacketVector id in key.GetUserAttributes()) { foreach (var sig in key.GetSignaturesForUserAttribute(id)) { // TODO Is this the right type of equality test? if (certification != sig) continue; // found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } } } return returnKey; }
/// <summary>Remove a certification from the key.</summary> /// <param name="key">The key the certifications are to be removed from.</param> /// <param name="certification">The certfication to be removed.</param> /// <returns>The modified key, null if the certification was not found.</returns> public static PgpPublicKey RemoveCertification( PgpPublicKey key, PgpSignature certification) { PgpPublicKey returnKey = new PgpPublicKey(key); IList sigs = returnKey.subSigs != null ? returnKey.subSigs : returnKey.keySigs; // bool found = sigs.Remove(certification); int pos = sigs.IndexOf(certification); bool found = pos >= 0; if (found) { sigs.RemoveAt(pos); } else { foreach (String id in key.GetUserIds()) { foreach (object sig in key.GetSignaturesForId(id)) { // TODO Is this the right type of equality test? if (certification == sig) { found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } } if (!found) { foreach (PgpUserAttributeSubpacketVector id in key.GetUserAttributes()) { foreach (object sig in key.GetSignaturesForUserAttribute(id)) { // TODO Is this the right type of equality test? if (certification == sig) { found = true; returnKey = PgpPublicKey.RemoveCertification(returnKey, id, certification); } } } } } return returnKey; }
public static PgpPublicKey RemoveCertification(PgpPublicKey key, PgpSignature certification) { PgpPublicKey pgpPublicKey = new PgpPublicKey(key); global::System.Collections.IList list = ((pgpPublicKey.subSigs != null) ? pgpPublicKey.subSigs : pgpPublicKey.keySigs); int num = list.IndexOf((object)certification); bool flag = num >= 0; if (flag) { list.RemoveAt(num); } else { { global::System.Collections.IEnumerator enumerator = key.GetUserIds().GetEnumerator(); try { while (enumerator.MoveNext()) { string id = (string)enumerator.get_Current(); { global::System.Collections.IEnumerator enumerator2 = key.GetSignaturesForId(id).GetEnumerator(); try { while (enumerator2.MoveNext()) { object current = enumerator2.get_Current(); if (certification == current) { flag = true; pgpPublicKey = RemoveCertification(pgpPublicKey, id, certification); } } } 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(); } } } if (!flag) { global::System.Collections.IEnumerator enumerator = key.GetUserAttributes().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpUserAttributeSubpacketVector userAttributes = (PgpUserAttributeSubpacketVector)enumerator.get_Current(); { global::System.Collections.IEnumerator enumerator2 = key.GetSignaturesForUserAttribute(userAttributes).GetEnumerator(); try { while (enumerator2.MoveNext()) { object current2 = enumerator2.get_Current(); if (certification == current2) { flag = true; pgpPublicKey = RemoveCertification(pgpPublicKey, userAttributes, certification); } } } finally { global::System.IDisposable disposable4 = enumerator2 as global::System.IDisposable; if (disposable4 != null) { disposable4.Dispose(); } } } } return(pgpPublicKey); } finally { global::System.IDisposable disposable3 = enumerator as global::System.IDisposable; if (disposable3 != null) { disposable3.Dispose(); } } } } return(pgpPublicKey); }