2 // System.Security.Permissions.KeyContainerPermissionAccessEntry class
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Globalization;
32 using System.Security.Cryptography;
34 namespace System.Security.Permissions {
37 public sealed class KeyContainerPermissionAccessEntry {
39 private KeyContainerPermissionFlags _flags;
40 private string _containerName;
42 private string _store;
43 private string _providerName;
47 public KeyContainerPermissionAccessEntry (CspParameters csp, KeyContainerPermissionFlags flags)
50 throw new ArgumentNullException ("csp");
52 ProviderName = csp.ProviderName;
53 ProviderType = csp.ProviderType;
54 KeyContainerName = csp.KeyContainerName;
55 KeySpec = csp.KeyNumber;
59 public KeyContainerPermissionAccessEntry (string keyContainerName, KeyContainerPermissionFlags flags)
61 KeyContainerName = keyContainerName;
65 public KeyContainerPermissionAccessEntry (string keyStore, string providerName, int providerType,
66 string keyContainerName, int keySpec, KeyContainerPermissionFlags flags)
69 ProviderName = providerName;
70 ProviderType = providerType;
71 KeyContainerName = keyContainerName;
77 public KeyContainerPermissionFlags Flags {
78 get { return _flags; }
80 if ((value & KeyContainerPermissionFlags.AllFlags) != 0) {
81 string msg = String.Format (Locale.GetText ("Invalid enum {0}"), value);
82 throw new ArgumentException (msg, "KeyContainerPermissionFlags");
88 public string KeyContainerName {
89 get { return _containerName; }
90 set { _containerName = value; }
95 set { _spec = value; }
98 public string KeyStore {
99 get { return _store; }
100 set { _store = value; }
103 public string ProviderName {
104 get { return _providerName; }
105 set { _providerName = value; }
108 public int ProviderType {
109 get { return _type; }
110 set { _type = value; }
114 public override bool Equals (object obj)
118 KeyContainerPermissionAccessEntry kcpae = (obj as KeyContainerPermissionAccessEntry);
121 if (_flags != kcpae._flags)
123 if (_containerName != kcpae._containerName)
125 if (_store != kcpae._store)
127 if (_providerName != kcpae._providerName)
129 if (_type != kcpae._type)
134 public override int GetHashCode ()
136 int result = _type ^ _spec ^ (int) _flags;
137 if (_containerName != null)
138 result ^= _containerName.GetHashCode ();
140 result ^= _store.GetHashCode ();
141 if (_providerName != null)
142 result ^= _providerName.GetHashCode ();