**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Security.X509 / MemoryCertificateStore.cs
blobfb2470c7f91f5362b4a76cfef8598e93be6b597a
1 //
2 // MemoryCertificateStore.cs: Handles an in-memory certificate store.
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
10 using System;
12 namespace Microsoft.Web.Services.Security.X509 {
14 internal class MemoryCertificateStore : ICertificateStore {
16 private string _storeName;
17 private X509CertificateStore.StoreOpenFlags _flags;
18 private X509CertificateStore.StoreLocation _location;
19 private IntPtr _handle;
20 private X509CertificateCollection _coll;
22 public MemoryCertificateStore (X509CertificateStore.StoreLocation location, string storeName, X509CertificateStore.StoreOpenFlags flags)
24 _location = location;
25 _storeName = storeName;
26 _flags = flags;
27 _coll = new X509CertificateCollection ();
30 public void Close ()
34 public IntPtr Handle {
35 get { return (IntPtr) _coll.GetHashCode (); }
38 public X509CertificateCollection GetCollection ()
40 if (_flags == X509CertificateStore.StoreOpenFlags.ReadOnly) {
41 // return a copy of the collection so changes aren't persisted
42 X509CertificateCollection copy = new X509CertificateCollection ();
43 foreach (X509Certificate x in _coll) {
44 copy.Add (x);
46 return copy;
48 else
49 return _coll;