ServiceModelSecurityTokenRequirement.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. //
  2. // ServiceModelSecurityTokenRequirement.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2006 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.Collections.Generic;
  29. using System.IdentityModel.Selectors;
  30. using System.IdentityModel.Tokens;
  31. using System.ServiceModel.Channels;
  32. using System.ServiceModel.Security;
  33. using System.Text;
  34. namespace System.ServiceModel.Security.Tokens
  35. {
  36. public abstract class ServiceModelSecurityTokenRequirement :
  37. SecurityTokenRequirement
  38. {
  39. protected ServiceModelSecurityTokenRequirement ()
  40. {
  41. }
  42. protected const string Namespace = "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement";
  43. public static string AuditLogLocationProperty {
  44. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/AuditLogLocation"; }
  45. }
  46. public static string ChannelParametersCollectionProperty {
  47. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/ChannelParametersCollection"; }
  48. }
  49. public static string DuplexClientLocalAddressProperty {
  50. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/DuplexClientLocalAddress"; }
  51. }
  52. public static string EndpointFilterTableProperty {
  53. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/EndpointFilterTable"; }
  54. }
  55. public static string HttpAuthenticationSchemeProperty {
  56. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/HttpAuthenticationScheme"; }
  57. }
  58. public static string IsInitiatorProperty {
  59. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IsInitiator"; }
  60. }
  61. public static string IsOutOfBandTokenProperty {
  62. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IsOutOfBandToken"; }
  63. }
  64. public static string IssuedSecurityTokenParametersProperty {
  65. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuedSecurityTokenParameters"; }
  66. }
  67. public static string IssuerAddressProperty {
  68. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerAddress"; }
  69. }
  70. public static string IssuerBindingContextProperty {
  71. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerBindingContext"; }
  72. }
  73. public static string IssuerBindingProperty {
  74. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerBinding"; }
  75. }
  76. public static string ListenUriProperty {
  77. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/ListenUri"; }
  78. }
  79. public static string MessageAuthenticationAuditLevelProperty {
  80. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageAuthenticationAuditLevel"; }
  81. }
  82. public static string MessageDirectionProperty {
  83. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageDirection"; }
  84. }
  85. public static string MessageSecurityVersionProperty {
  86. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageSecurityVersion"; }
  87. }
  88. public static string PrivacyNoticeUriProperty {
  89. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/PrivacyNoticeUri"; }
  90. }
  91. public static string PrivacyNoticeVersionProperty {
  92. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/PrivacyNoticeVersion"; }
  93. }
  94. public static string SecureConversationSecurityBindingElementProperty {
  95. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecureConversationSecurityBindingElement"; }
  96. }
  97. public static string SecurityAlgorithmSuiteProperty {
  98. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecurityAlgorithmSuite"; }
  99. }
  100. public static string SecurityBindingElementProperty {
  101. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecurityBindingElement"; }
  102. }
  103. public static string SupportingTokenAttachmentModeProperty {
  104. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SupportingTokenAttachmentMode"; }
  105. }
  106. public static string SupportSecurityContextCancellationProperty {
  107. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SupportSecurityContextCancellation"; }
  108. }
  109. public static string SuppressAuditFailureProperty {
  110. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SuppressAuditFailure"; }
  111. }
  112. public static string TargetAddressProperty {
  113. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/TargetAddress"; }
  114. }
  115. public static string TransportSchemeProperty {
  116. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/TransportScheme"; }
  117. }
  118. public static string ViaProperty {
  119. get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/Via"; }
  120. }
  121. public bool IsInitiator {
  122. get {
  123. bool ret;
  124. if (TryGetProperty<bool> (IsInitiatorProperty, out ret))
  125. return ret;
  126. return false;
  127. }
  128. }
  129. public EndpointAddress IssuerAddress {
  130. get {
  131. EndpointAddress ret;
  132. TryGetProperty<EndpointAddress> (IssuerAddressProperty, out ret);
  133. return ret;
  134. }
  135. set { Properties [IssuerAddressProperty] = value; }
  136. }
  137. public Binding IssuerBinding {
  138. get {
  139. Binding ret;
  140. TryGetProperty<Binding> (IssuerBindingProperty, out ret);
  141. return ret;
  142. }
  143. set { Properties [IssuerBindingProperty] = value; }
  144. }
  145. public SecurityTokenVersion MessageSecurityVersion {
  146. get {
  147. SecurityTokenVersion ret;
  148. TryGetProperty<SecurityTokenVersion> (MessageSecurityVersionProperty, out ret);
  149. return ret;
  150. }
  151. set { Properties [MessageSecurityVersionProperty] = value; }
  152. }
  153. public SecurityBindingElement SecureConversationSecurityBindingElement {
  154. get {
  155. SecurityBindingElement ret;
  156. TryGetProperty<SecurityBindingElement> (SecureConversationSecurityBindingElementProperty, out ret);
  157. return ret;
  158. }
  159. set { Properties [SecureConversationSecurityBindingElementProperty] = value; }
  160. }
  161. public SecurityAlgorithmSuite SecurityAlgorithmSuite {
  162. get {
  163. SecurityAlgorithmSuite ret;
  164. TryGetProperty<SecurityAlgorithmSuite> (SecurityAlgorithmSuiteProperty, out ret);
  165. return ret;
  166. }
  167. set { Properties [SecurityAlgorithmSuiteProperty] = value; }
  168. }
  169. public SecurityBindingElement SecurityBindingElement {
  170. get {
  171. SecurityBindingElement ret;
  172. TryGetProperty<SecurityBindingElement> (SecurityBindingElementProperty, out ret);
  173. return ret;
  174. }
  175. set { Properties [SecurityBindingElementProperty] = value; }
  176. }
  177. public string TransportScheme {
  178. get {
  179. string ret;
  180. TryGetProperty<string> (TransportSchemeProperty, out ret);
  181. return ret;
  182. }
  183. set { Properties [TransportSchemeProperty] = value; }
  184. }
  185. internal string Dump ()
  186. {
  187. StringBuilder sb = new StringBuilder ();
  188. sb.Append (GetType ()).Append (":");
  189. foreach (KeyValuePair<string, object> p in Properties)
  190. sb.Append ("\n------------\n")
  191. .Append ("URI: ")
  192. .Append (p.Key)
  193. .Append ("\nValue: ")
  194. .Append (p.Value);
  195. return sb.ToString ();
  196. }
  197. }
  198. }