2005-06-05 Peter Bartok <pbartok@novell.com>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / CspParameters.cs
1 //\r
2 // System.Security.Cryptography CspParameters.cs\r
3 //\r
4 // Authors:\r
5 //      Thomas Neidhart (tome@sbox.tugraz.at)\r
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //\r
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 #if NET_2_0
31 using System.Security.AccessControl;
32 #endif
33 \r
34 namespace System.Security.Cryptography {\r
35 \r
36         public sealed class CspParameters {
37 \r
38                 private CspProviderFlags _Flags;\r
39         \r
40                 public CspParameters () 
41                         : this (1)
42                 {
43                 }\r
44                 \r
45                 public CspParameters (int dwTypeIn) 
46                         : this (dwTypeIn, null) 
47                 {
48                 }\r
49                 \r
50                 public CspParameters (int dwTypeIn, string strProviderNameIn)
51                         : this (dwTypeIn, null, null)
52                 {
53                 }\r
54                 \r
55                 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn)\r
56                 {\r
57                         ProviderType = dwTypeIn;\r
58                         ProviderName = strProviderNameIn;\r
59                         KeyContainerName = strContainerNameIn;\r
60                         \r
61                         // not defined in specs, only tested from M$ impl\r
62                         KeyNumber = -1;\r
63                 }\r
64                 \r
65                 public string KeyContainerName;\r
66                 \r
67                 public int KeyNumber;\r
68                 \r
69                 public string ProviderName;\r
70                 \r
71                 public int ProviderType;\r
72                 \r
73                 public CspProviderFlags Flags {\r
74                         get { return _Flags; }\r
75                         set { _Flags = value; }\r
76                 }
77
78 #if NET_2_0
79                 private SecureString _password;
80                 private IntPtr _windowHandle;
81
82                 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn, 
83                         CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle)
84                         : this (dwTypeIn, strProviderNameIn, strContainerNameIn)
85                 {
86                         if (cryptoKeySecurity != null)
87                                 CryptoKeySecurity = cryptoKeySecurity;
88                         _windowHandle = parentWindowHandle;
89                 }
90
91                 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn, 
92                         CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword)
93                         : this (dwTypeIn, strProviderNameIn, strContainerNameIn)
94                 {
95                         if (cryptoKeySecurity != null)
96                                 CryptoKeySecurity = cryptoKeySecurity;
97                         _password = keyPassword;
98                 }
99
100                 [MonoTODO ("access control isn't implemented")]
101                 public CryptoKeySecurity CryptoKeySecurity {
102                         get { throw new NotImplementedException (); }
103                         set { throw new NotImplementedException (); }
104                 }
105
106                 public SecureString KeyPassword {
107                         get { return _password; }
108                         set { _password = value; }
109                 }
110
111                 public IntPtr ParentWindowHandle {
112                         get { return _windowHandle; }
113                         set { _windowHandle = value; }
114                 }
115 #endif\r
116         }\r
117 }\r