2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Security / AuthenticationKey.cs
1 //\r
2 // AuthenticationKey.cs: Handles WS-Security AuthenticationKey\r
3 //\r
4 // Author:\r
5 //      Sebastien Pouliot (spouliot@motus.com)\r
6 //\r
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)\r
8 //\r
9 // Licensed under MIT X11 (see LICENSE) with this specific addition:\r
10 //\r
11 // \93This source code may incorporate intellectual property owned by Microsoft \r
12 // Corporation. Our provision of this source code does not include any licenses\r
13 // or any other rights to you under any Microsoft intellectual property. If you\r
14 // would like a license from Microsoft (e.g. rebrand, redistribute), you need \r
15 // to contact Microsoft directly.\94 \r
16 //\r
17 \r
18 using System.Security.Cryptography;\r
19 // temp\r
20 //using System.Security.Cryptography.Xml;\r
21 \r
22 namespace Microsoft.Web.Services.Security {\r
23 \r
24         public class AuthenticationKey {\r
25 \r
26                 private AsymmetricAlgorithm asymKey;\r
27                 private SymmetricAlgorithm symKey;\r
28 \r
29                 public AuthenticationKey (AsymmetricAlgorithm key) \r
30                 {\r
31                         asymKey = key;\r
32                 }\r
33 \r
34                 public AuthenticationKey (SymmetricAlgorithm key) \r
35                 {\r
36                         symKey = key;\r
37                 }\r
38 \r
39                 public bool CheckSignature (SignedXml signedXml) \r
40                 {\r
41                         if (asymKey != null) {\r
42                                 return signedXml.CheckSignature (asymKey);\r
43                         }\r
44                         else {\r
45                                 HMACSHA1 hmac = new HMACSHA1 (symKey.Key);\r
46                                 return signedXml.CheckSignature (hmac);\r
47                         }\r
48                 }\r
49         }\r
50 }\r