2 // System.Security.Permissions.KeyContainerPermissionAccessEntry class
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2004-2005 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.Runtime.InteropServices;
33 using System.Security.Cryptography;
35 namespace System.Security.Permissions {
39 public sealed class KeyContainerPermissionAccessEntry {
41 private KeyContainerPermissionFlags _flags;
42 private string _containerName;
44 private string _store;
45 private string _providerName;
49 public KeyContainerPermissionAccessEntry (CspParameters csp, KeyContainerPermissionFlags flags)
52 throw new ArgumentNullException ("csp");
54 ProviderName = csp.ProviderName;
55 ProviderType = csp.ProviderType;
56 KeyContainerName = csp.KeyContainerName;
57 KeySpec = csp.KeyNumber;
61 public KeyContainerPermissionAccessEntry (string keyContainerName, KeyContainerPermissionFlags flags)
63 KeyContainerName = keyContainerName;
67 public KeyContainerPermissionAccessEntry (string keyStore, string providerName, int providerType,
68 string keyContainerName, int keySpec, KeyContainerPermissionFlags flags)
71 ProviderName = providerName;
72 ProviderType = providerType;
73 KeyContainerName = keyContainerName;
79 public KeyContainerPermissionFlags Flags {
80 get { return _flags; }
82 if ((value & KeyContainerPermissionFlags.AllFlags) != 0) {
83 string msg = String.Format (Locale.GetText ("Invalid enum {0}"), value);
84 throw new ArgumentException (msg, "KeyContainerPermissionFlags");
90 public string KeyContainerName {
91 get { return _containerName; }
92 set { _containerName = value; }
97 set { _spec = value; }
100 public string KeyStore {
101 get { return _store; }
102 set { _store = value; }
105 public string ProviderName {
106 get { return _providerName; }
107 set { _providerName = value; }
110 public int ProviderType {
111 get { return _type; }
112 set { _type = value; }
116 public override bool Equals (object obj)
120 KeyContainerPermissionAccessEntry kcpae = (obj as KeyContainerPermissionAccessEntry);
123 if (_flags != kcpae._flags)
125 if (_containerName != kcpae._containerName)
127 if (_store != kcpae._store)
129 if (_providerName != kcpae._providerName)
131 if (_type != kcpae._type)
136 public override int GetHashCode ()
138 int result = _type ^ _spec ^ (int) _flags;
139 if (_containerName != null)
140 result ^= _containerName.GetHashCode ();
142 result ^= _store.GetHashCode ();
143 if (_providerName != null)
144 result ^= _providerName.GetHashCode ();