[docs] Import of Microsoft BCL Documentation.
[mono.git] / mcs / class / corlib / System.Security.Cryptography / CspParameters.cs
old mode 100755 (executable)
new mode 100644 (file)
index 7c84eaf..0df9566
@@ -1,29 +1,58 @@
 //\r
-// System.Security.Cryptography CspParameters.cs\r
+// System.Security.Cryptography.CspParameters.cs\r
 //\r
-// Author:\r
-//   Thomas Neidhart (tome@sbox.tugraz.at)\r
+// Authors:\r
+//     Thomas Neidhart (tome@sbox.tugraz.at)\r
+//     Sebastien Pouliot  <sebastien@ximian.com>
 //\r
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Runtime.InteropServices;
+using System.Security.AccessControl;
 \r
-using System;\r
+namespace System.Security.Cryptography {\r
 \r
-namespace System.Security.Cryptography\r
-{\r
+       [ComVisible (true)]
+       public sealed class CspParameters {
 \r
-       /// <summary>\r
-       /// Contains information passed to Crypto Service Providers (CSP)\r
-       /// </summary>\r
-       public sealed class CspParameters\r
-       {\r
                private CspProviderFlags _Flags;\r
        \r
-               public CspParameters() : this(1) {}\r
+               public CspParameters () 
+                       : this (1)
+               {
+               }\r
                \r
-               public CspParameters(int dwTypeIn) : this(dwTypeIn, null) {}\r
+               public CspParameters (int dwTypeIn) 
+                       : this (dwTypeIn, null) 
+               {
+               }\r
                \r
-               public CspParameters(int dwTypeIn, string strProviderNameIn) : this(dwTypeIn, null, null) {}\r
+               public CspParameters (int dwTypeIn, string strProviderNameIn)
+                       : this (dwTypeIn, null, null)
+               {
+               }\r
                \r
-               public CspParameters(int dwTypeIn, string strProviderNameIn, string strContainerNameIn)\r
+               public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn)\r
                {\r
                        ProviderType = dwTypeIn;\r
                        ProviderName = strProviderNameIn;\r
@@ -32,7 +61,7 @@ namespace System.Security.Cryptography
                        // not defined in specs, only tested from M$ impl\r
                        KeyNumber = -1;\r
                }\r
-               \r
+\r
                public string KeyContainerName;\r
                \r
                public int KeyNumber;\r
@@ -41,17 +70,58 @@ namespace System.Security.Cryptography
                \r
                public int ProviderType;\r
                \r
-               public CspProviderFlags Flags \r
+               public CspProviderFlags Flags {\r
+                       get { return _Flags; }\r
+                       set { _Flags = value; }\r
+               }
+
+               private SecureString _password;
+               private IntPtr _windowHandle;
+
+               public CspParameters (int providerType, string providerName, string keyContainerName, 
+                       CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle)
+                       : this (providerType, providerName, keyContainerName)
+               {
+                       if (cryptoKeySecurity != null)
+                               CryptoKeySecurity = cryptoKeySecurity;
+                       _windowHandle = parentWindowHandle;
+               }
+
+               public CspParameters (int providerType, string providerName, string keyContainerName, 
+                       CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword)
+                       : this (providerType, providerName, keyContainerName)
+               {
+                       if (cryptoKeySecurity != null)
+                               CryptoKeySecurity = cryptoKeySecurity;
+                       _password = keyPassword;
+               }\r
+\r
+               internal CspParameters(CspParameters parameters)\r
+                       : this(parameters.ProviderType, parameters.ProviderName, parameters.KeyContainerName)\r
                {\r
-                       get {\r
-                               return _Flags;\r
-                       }\r
-                       \r
-                       set {\r
-                               _Flags = value;\r
-                       }\r
+                       if (parameters.CryptoKeySecurity != null)\r
+                               CryptoKeySecurity = parameters.CryptoKeySecurity;\r
+\r
+                       _Flags = parameters.Flags;\r
+                       KeyNumber = parameters.KeyNumber;\r
+                       _password = parameters.KeyPassword;\r
+                       _windowHandle = parameters.ParentWindowHandle;\r
                }\r
-               \r
-       } // CspParameters\r
-       \r
-} // System.Security.Cryptography\r
+
+               [MonoTODO ("access control isn't implemented")]
+               public CryptoKeySecurity CryptoKeySecurity {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               public SecureString KeyPassword {
+                       get { return _password; }
+                       set { _password = value; }
+               }
+
+               public IntPtr ParentWindowHandle {
+                       get { return _windowHandle; }
+                       set { _windowHandle = value; }
+               }
+       }\r
+}\r