Bug 15572. Lookup KnownTypeCollection element types in MSSimpleNamespace
[mono.git] / mcs / class / System.IdentityModel / System.IdentityModel.Tokens / RsaSecurityKey.cs
1 //
2 // AsymmetricSecurityKey.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2005 Novell, Inc.  http://www.novell.com
8 //
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:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
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.
27 //
28 using System;
29 using System.Collections.Generic;
30 using System.Xml;
31 using System.IdentityModel.Policy;
32 using System.Security.Cryptography;
33
34 namespace System.IdentityModel.Tokens
35 {
36         public sealed class RsaSecurityKey : AsymmetricSecurityKey
37         {
38                 public RsaSecurityKey (RSA rsa)
39                 {
40                         this.rsa = rsa;
41                 }
42
43                 RSA rsa;
44
45                 // AsymmetricSecurityKey implementation
46
47                 [MonoTODO]
48                 public override AsymmetricAlgorithm GetAsymmetricAlgorithm (
49                         string algorithm, bool privateKey)
50                 {
51                         throw new NotImplementedException ();
52                 }
53
54                 [MonoTODO]
55                 public override HashAlgorithm GetHashAlgorithmForSignature (
56                         string algorithm)
57                 {
58                         throw new NotImplementedException ();
59                 }
60
61                 [MonoTODO]
62                 public override AsymmetricSignatureDeformatter GetSignatureDeformatter (string algorithm)
63                 {
64                         throw new NotImplementedException ();
65                 }
66
67                 [MonoTODO]
68                 public override AsymmetricSignatureFormatter GetSignatureFormatter (string algorithm)
69                 {
70                         throw new NotImplementedException ();
71                 }
72
73                 public override bool HasPrivateKey ()
74                 {
75                         RSACryptoServiceProvider rcsp = rsa as RSACryptoServiceProvider;
76                         if (rcsp != null)
77                                 return !rcsp.PublicOnly;
78                         try {
79                                 rcsp.ExportParameters (true);
80                                 return true;
81                         } catch (CryptographicException) {
82                                 return false;
83                         }
84                 }
85
86                 // SecurityKey implementation
87
88                 public override int KeySize {
89                         get { return rsa.KeySize; }
90                 }
91
92                 [MonoTODO]
93                 public override byte [] DecryptKey (string algorithm, byte [] keyData)
94                 {
95                         throw new NotImplementedException ();
96                 }
97
98                 [MonoTODO]
99                 public override byte [] EncryptKey (string algorithm, byte [] keyData)
100                 {
101                         throw new NotImplementedException ();
102                 }
103
104                 [MonoTODO]
105                 public override bool IsAsymmetricAlgorithm (string algorithm)
106                 {
107                         throw new NotImplementedException ();
108                 }
109
110                 [MonoTODO]
111                 public override bool IsSupportedAlgorithm (string algorithm)
112                 {
113                         throw new NotImplementedException ();
114                 }
115
116                 [MonoTODO]
117                 public override bool IsSymmetricAlgorithm (string algorithm)
118                 {
119                         throw new NotImplementedException ();
120                 }
121         }
122 }