SigningCredentials.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // SigningCredentials.cs
  3. //
  4. // Author: Atsushi Enomoto <[email protected]>
  5. //
  6. // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using System.Collections.ObjectModel;
  29. using System.Runtime.Serialization;
  30. namespace System.IdentityModel.Tokens
  31. {
  32. public class SigningCredentials
  33. {
  34. SecurityKey key;
  35. string sig_alg;
  36. string dig_alg;
  37. SecurityKeyIdentifier identifier;
  38. public SigningCredentials (SecurityKey signingKey, string signatureAlgorithm, string digestAlgorithm)
  39. {
  40. if (signingKey == null)
  41. throw new ArgumentNullException ("signingKey");
  42. if (signatureAlgorithm == null)
  43. throw new ArgumentNullException ("signatureAlgorithm");
  44. if (digestAlgorithm == null)
  45. throw new ArgumentNullException ("digestAlgorithm");
  46. this.key = signingKey;
  47. this.sig_alg = signatureAlgorithm;
  48. this.dig_alg = digestAlgorithm;
  49. }
  50. public SigningCredentials (SecurityKey signingKey, string signatureAlgorithm, string digestAlgorithm, SecurityKeyIdentifier signingKeyIdentifier)
  51. : this (signingKey, signatureAlgorithm, digestAlgorithm)
  52. {
  53. if (signingKeyIdentifier == null)
  54. throw new ArgumentNullException ("signingKeyIdentifier");
  55. this.identifier = signingKeyIdentifier;
  56. }
  57. public string DigestAlgorithm {
  58. get { return dig_alg; }
  59. }
  60. public string SignatureAlgorithm {
  61. get { return sig_alg; }
  62. }
  63. public SecurityKey SigningKey {
  64. get { return key; }
  65. }
  66. public SecurityKeyIdentifier SigningKeyIdentifier {
  67. get { return identifier; }
  68. }
  69. }
  70. }