Often PGP keyring files consist of multiple master keys, if you are trying to process or construct one of these you should use the PgpPublicKeyRingBundle class.
PgpPublicKeyRingBundle
/// <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); }
/// <summary> /// Returns a new key ring with the public key passed in either added or /// replacing an existing one. /// </summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be inserted.</param> /// <returns>A new <c>PgpPublicKeyRing</c></returns> public static PgpPublicKeyRing InsertPublicKey( PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { ArrayList keys = new ArrayList(pubRing.keys); bool found = false; for (int i = 0; i != keys.Count; i++) { PgpPublicKey key = (PgpPublicKey)keys[i]; if (key.KeyId == pubKey.KeyId) { found = true; keys[i] = pubKey; } } if (!found) { keys.Add(pubKey); } return(new PgpPublicKeyRing(keys)); }
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); }
/// <summary> /// Returns a new key ring with the public key passed in either added or /// replacing an existing one. /// </summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be inserted.</param> /// <returns>A new <c>PgpPublicKeyRing</c></returns> public static PgpPublicKeyRing InsertPublicKey( PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { ArrayList keys = new ArrayList(pubRing.keys); bool found = false; for (int i = 0; i != keys.Count; i++) { PgpPublicKey key = (PgpPublicKey) keys[i]; if (key.KeyId == pubKey.KeyId) { found = true; keys[i] = pubKey; } } if (!found) { keys.Add(pubKey); } return new PgpPublicKeyRing(keys); }
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)); }
public static byte[] ToAsc(byte[] pgp) { MemoryStream ms = new MemoryStream(); var ring = new PgpPublicKeyRing(GetStream(pgp)); var armored = new ArmoredOutputStream(ms); ring.Encode(armored); armored.Dispose(); return ms.ToArray(); }
public OpenPgpCrypter(PgpPublicKeyRing publicKeyRing, PgpSecretKeyRing privateKeyRing, char[] cPassword) { if ( publicKeyRing == null || privateKeyRing == null || cPassword == null) throw new ArgumentNullException("encryptionKeys", "encryptionKeys or password is null."); this.m_PublicKeyRing = publicKeyRing; this.m_PrivateKeyRing = privateKeyRing; this.m_cPassword = cPassword; }
/// <summary> /// Create a new e-mail address. /// </summary> /// <param name="OwnerName">The name of the owner of the e-mail address.</param> /// <param name="SimpleEMailAddress">A simple e-mail address.</param> /// <param name="SecretKeyRing">The secret key ring for an e-mail address.</param> /// <param name="PublicKeyRing">The public key ring for an e-mail address.</param> public EMailAddress(String OwnerName, SimpleEMailAddress SimpleEMailAddress, PgpSecretKeyRing SecretKeyRing = null, PgpPublicKeyRing PublicKeyRing = null) { this._OwnerName = OwnerName.Trim(); this._Address = SimpleEMailAddress; this._PublicKeyRing = PublicKeyRing; this._SecretKeyRing = SecretKeyRing; }
public void Encode( Stream outStr) { BcpgOutputStream bcpgOut = BcpgOutputStream.Wrap(outStr); foreach (long key in order) { PgpPublicKeyRing sec = (PgpPublicKeyRing)pubRings[key]; sec.Encode(bcpgOut); } }
/// <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)); }
/// <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)); }
/// <summary> /// Returns a new key ring with the public key passed in either added or /// replacing an existing one. /// </summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be inserted.</param> /// <returns>A new <c>PgpPublicKeyRing</c></returns> public static PgpPublicKeyRing InsertPublicKey( PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { IList keys = Platform.CreateArrayList(pubRing.keys); bool found = false; bool masterFound = false; for (int i = 0; i != keys.Count; i++) { PgpPublicKey key = (PgpPublicKey)keys[i]; if (key.KeyId == pubKey.KeyId) { found = true; keys[i] = pubKey; } if (key.IsMasterKey) { masterFound = true; } } if (!found) { if (pubKey.IsMasterKey) { if (masterFound) { throw new ArgumentException("cannot add a master key to a ring that already has one"); } keys.Insert(0, pubKey); } else { keys.Add(pubKey); } } return(new PgpPublicKeyRing(keys)); }
public static PgpPublicKeyRing RemovePublicKey(PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { global::System.Collections.IList list = Platform.CreateArrayList((global::System.Collections.ICollection)pubRing.keys); bool flag = false; for (int i = 0; i < ((global::System.Collections.ICollection)list).get_Count(); i++) { PgpPublicKey pgpPublicKey = (PgpPublicKey)list.get_Item(i); if (pgpPublicKey.KeyId == pubKey.KeyId) { flag = true; list.RemoveAt(i); } } if (!flag) { return(null); } return(new PgpPublicKeyRing(list)); }
/// <summary>Returns a new key ring with the public key passed in removed from the key ring.</summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be removed.</param> /// <returns>A new <c>PgpPublicKeyRing</c>, or null if pubKey is not found.</returns> public static PgpPublicKeyRing RemovePublicKey( PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { ArrayList keys = new ArrayList(pubRing.keys); bool found = false; for (int i = 0; i < keys.Count; i++) { PgpPublicKey key = (PgpPublicKey)keys[i]; if (key.KeyId == pubKey.KeyId) { found = true; keys.RemoveAt(i); } } return(found ? new PgpPublicKeyRing(keys) : null); }
/// <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)); }
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>Returns a new key ring with the public key passed in removed from the key ring.</summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be removed.</param> /// <returns>A new <c>PgpPublicKeyRing</c>, or null if pubKey is not found.</returns> public static PgpPublicKeyRing RemovePublicKey(PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { var keys = Platform.CreateArrayList(pubRing._keys); var found = false; for (var i = 0; i < keys.Count; i++) { var key = (PgpPublicKey)keys[i]; if (key.KeyId != pubKey.KeyId) { continue; } found = true; keys.RemoveAt(i); } return(found ? new PgpPublicKeyRing(keys) : null); }
/// <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 void Encode(Stream outStr) { BcpgOutputStream outStr2 = BcpgOutputStream.Wrap(outStr); global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)order).GetEnumerator(); try { while (enumerator.MoveNext()) { long num = (long)enumerator.get_Current(); PgpPublicKeyRing pgpPublicKeyRing = (PgpPublicKeyRing)pubRings.get_Item((object)num); pgpPublicKeyRing.Encode((Stream)(object)outStr2); } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public static PgpPublicKeyRing InsertPublicKey(PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) global::System.Collections.IList list = Platform.CreateArrayList((global::System.Collections.ICollection)pubRing.keys); bool flag = false; bool flag2 = false; for (int i = 0; i != ((global::System.Collections.ICollection)list).get_Count(); i++) { PgpPublicKey pgpPublicKey = (PgpPublicKey)list.get_Item(i); if (pgpPublicKey.KeyId == pubKey.KeyId) { flag = true; list.set_Item(i, (object)pubKey); } if (pgpPublicKey.IsMasterKey) { flag2 = true; } } if (!flag) { if (pubKey.IsMasterKey) { if (flag2) { throw new ArgumentException("cannot add a master key to a ring that already has one"); } list.Insert(0, (object)pubKey); } else { list.Add((object)pubKey); } } return(new PgpPublicKeyRing(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); }
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 = new Hashtable(bundle.pubRings); ArrayList newOrder = new ArrayList(bundle.order); newPubRings.Remove(key); newOrder.Remove(key); return new PgpPublicKeyRingBundle(newPubRings, newOrder); }
/// <summary> /// Create a new e-mail address. /// </summary> /// <param name="SimpleEMailAddress">A simple e-mail address.</param> /// <param name="SecretKeyRing">The secret key ring for an e-mail address.</param> /// <param name="PublicKeyRing">The public key ring for an e-mail address.</param> public EMailAddress(SimpleEMailAddress SimpleEMailAddress, PgpSecretKeyRing SecretKeyRing = null, PgpPublicKeyRing PublicKeyRing = null) : this("", SimpleEMailAddress, SecretKeyRing, PublicKeyRing) { }
/// <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 (); }
internal GenericAPI(RoamingNetwork RoamingNetwork, String HTTPServerName = DefaultHTTPServerName, IPPort HTTPServerPort = null, String URIPrefix = "", Func<String, Stream> GetRessources = null, String ServiceName = DefaultHTTPServerName, EMailAddress APIEMailAddress = null, PgpPublicKeyRing APIPublicKeyRing = null, PgpSecretKeyRing APISecretKeyRing = null, String APIPassphrase = null, EMailAddressList APIAdminEMail = null, SMTPClient APISMTPClient = null, DNSClient DNSClient = null, String LogfileName = DefaultLogfileName) : this(RoamingNetwork, new HTTPServer(DefaultServerName: DefaultHTTPServerName).AttachTCPPorts(HTTPServerPort != null ? HTTPServerPort : DefaultHTTPServerPort), URIPrefix, GetRessources, ServiceName, APIEMailAddress, APIPublicKeyRing, APISecretKeyRing, APIPassphrase, APIAdminEMail, APISMTPClient, LogfileName) { }
/// <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); }
/// <summary> /// Returns a new key ring with the public key passed in either added or /// replacing an existing one. /// </summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be inserted.</param> /// <returns>A new <c>PgpPublicKeyRing</c></returns> public static PgpPublicKeyRing InsertPublicKey( PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { IList keys = Platform.CreateArrayList(pubRing.keys); bool found = false; bool masterFound = false; for (int i = 0; i != keys.Count; i++) { PgpPublicKey key = (PgpPublicKey) keys[i]; if (key.KeyId == pubKey.KeyId) { found = true; keys[i] = pubKey; } if (key.IsMasterKey) { masterFound = true; } } if (!found) { if (pubKey.IsMasterKey) { if (masterFound) throw new ArgumentException("cannot add a master key to a ring that already has one"); keys.Insert(0, pubKey); } else { keys.Add(pubKey); } } return new PgpPublicKeyRing(keys); }
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>Returns a new key ring with the public key passed in removed from the key ring.</summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be removed.</param> /// <returns>A new <c>PgpPublicKeyRing</c>, or null if pubKey is not found.</returns> public static PgpPublicKeyRing RemovePublicKey( PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { IList keys = Platform.CreateArrayList(pubRing.keys); bool found = false; for (int i = 0; i < keys.Count; i++) { PgpPublicKey key = (PgpPublicKey) keys[i]; if (key.KeyId == pubKey.KeyId) { found = true; keys.RemoveAt(i); } } return found ? new PgpPublicKeyRing(keys) : null; }
/// <summary> /// Create a new e-mail address. /// </summary> /// <param name="OwnerName">The name of the owner of the e-mail address.</param> /// <param name="SimpleEMailAddressString">A string representation of a simple e-mail address.</param> /// <param name="SecretKeyRing">The public key ring for an e-mail address.</param> /// <param name="PublicKeyRing">The secret key ring for an e-mail address.</param> public EMailAddress(String OwnerName, String SimpleEMailAddressString, PgpSecretKeyRing SecretKeyRing = null, PgpPublicKeyRing PublicKeyRing = null) : this(OwnerName, SimpleEMailAddress.Parse(SimpleEMailAddressString), SecretKeyRing, PublicKeyRing) { }
public OpenPGPRing(PgpPublicKeyRing _pgpPublicKeyRing, PgpSecretKeyRing _pgpSecretKeyRing, char [] cPassword) { this.m_PublicKeyRing = _pgpPublicKeyRing; this.m_PrivateKeyRing = _pgpSecretKeyRing; this.m_cPassword = cPassword; }
public OpenPGPRing(PgpPublicKeyRing _pgpPublicKeyRing, PgpSecretKeyRing _pgpSecretKeyRing) { this.m_PublicKeyRing = _pgpPublicKeyRing; this.m_PrivateKeyRing = _pgpSecretKeyRing; }
/// <summary> /// Initialize the OCPI HTTP server using IPAddress.Any, http port 8080 and maybe start the server. /// </summary> internal GenericAPI(RoamingNetwork RoamingNetwork, HTTPServer HTTPServer, String URIPrefix = "/ext/OCPI", Func<String, Stream> GetRessources = null, String ServiceName = DefaultHTTPServerName, EMailAddress APIEMailAddress = null, PgpPublicKeyRing APIPublicKeyRing = null, PgpSecretKeyRing APISecretKeyRing = null, String APIPassphrase = null, EMailAddressList APIAdminEMail = null, SMTPClient APISMTPClient = null, String LogfileName = DefaultLogfileName) { #region Initial checks if (RoamingNetwork == null) throw new ArgumentNullException("RoamingNetwork", "The given parameter must not be null!"); if (HTTPServer == null) throw new ArgumentNullException("HTTPServer", "The given parameter must not be null!"); if (URIPrefix.IsNullOrEmpty()) throw new ArgumentNullException("URIPrefix", "The given parameter must not be null or empty!"); if (!URIPrefix.StartsWith("/")) URIPrefix = "/" + URIPrefix; #endregion #region Init data this._HTTPServer = HTTPServer; this._GetRessources = GetRessources; this._URIPrefix = URIPrefix; this._ServiceName = ServiceName; this._APIEMailAddress = APIEMailAddress; this._APIPublicKeyRing = APIPublicKeyRing; this._APISecretKeyRing = APISecretKeyRing; this._APIPassphrase = APIPassphrase; this._APIAdminEMail = APIAdminEMail; this._APISMTPClient = APISMTPClient; this._DNSClient = HTTPServer.DNSClient; #endregion RegisterURITemplates(); }
/// <summary>Returns a new key ring with the public key passed in removed from the key ring.</summary> /// <param name="pubRing">The public key ring to be modified.</param> /// <param name="pubKey">The public key to be removed.</param> /// <returns>A new <c>PgpPublicKeyRing</c>, or null if pubKey is not found.</returns> public static PgpPublicKeyRing RemovePublicKey(PgpPublicKeyRing pubRing, PgpPublicKey pubKey) { var keys = Platform.CreateArrayList(pubRing._keys); var found = false; for (var i = 0; i < keys.Count; i++) { var key = (PgpPublicKey)keys[i]; if (key.KeyId != pubKey.KeyId) continue; found = true; keys.RemoveAt(i); } return found ? new PgpPublicKeyRing(keys) : null; }