Switch to compiler-tester
[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.Runtime.InteropServices;
32 using System.Security.AccessControl;
33 #endif
34 \r
35 namespace System.Security.Cryptography {\r
36 \r
37 #if NET_2_0
38         [ComVisible (true)]
39 #endif
40         public sealed class CspParameters {
41 \r
42                 private CspProviderFlags _Flags;\r
43         \r
44                 public CspParameters () 
45                         : this (1)
46                 {
47                 }\r
48                 \r
49                 public CspParameters (int dwTypeIn) 
50                         : this (dwTypeIn, null) 
51                 {
52                 }\r
53                 \r
54                 public CspParameters (int dwTypeIn, string strProviderNameIn)
55                         : this (dwTypeIn, null, null)
56                 {
57                 }\r
58                 \r
59                 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn)\r
60                 {\r
61                         ProviderType = dwTypeIn;\r
62                         ProviderName = strProviderNameIn;\r
63                         KeyContainerName = strContainerNameIn;\r
64                         \r
65                         // not defined in specs, only tested from M$ impl\r
66                         KeyNumber = -1;\r
67                 }\r
68                 \r
69                 public string KeyContainerName;\r
70                 \r
71                 public int KeyNumber;\r
72                 \r
73                 public string ProviderName;\r
74                 \r
75                 public int ProviderType;\r
76                 \r
77                 public CspProviderFlags Flags {\r
78                         get { return _Flags; }\r
79                         set { _Flags = value; }\r
80                 }
81
82 #if NET_2_0
83                 private SecureString _password;
84                 private IntPtr _windowHandle;
85
86                 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn, 
87                         CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle)
88                         : this (dwTypeIn, strProviderNameIn, strContainerNameIn)
89                 {
90                         if (cryptoKeySecurity != null)
91                                 CryptoKeySecurity = cryptoKeySecurity;
92                         _windowHandle = parentWindowHandle;
93                 }
94
95                 public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn, 
96                         CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword)
97                         : this (dwTypeIn, strProviderNameIn, strContainerNameIn)
98                 {
99                         if (cryptoKeySecurity != null)
100                                 CryptoKeySecurity = cryptoKeySecurity;
101                         _password = keyPassword;
102                 }
103
104                 [MonoTODO ("access control isn't implemented")]
105                 public CryptoKeySecurity CryptoKeySecurity {
106                         get { throw new NotImplementedException (); }
107                         set { throw new NotImplementedException (); }
108                 }
109
110                 public SecureString KeyPassword {
111                         get { return _password; }
112                         set { _password = value; }
113                 }
114
115                 public IntPtr ParentWindowHandle {
116                         get { return _windowHandle; }
117                         set { _windowHandle = value; }
118                 }
119 #endif\r
120         }\r
121 }\r