SecurityBindingElement.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. //
  2. // SecurityBindingElement.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2005-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.Collections.ObjectModel;
  30. using System.ServiceModel.Description;
  31. using System.ServiceModel.Channels;
  32. using System.ServiceModel.Security;
  33. #if !NET_2_1
  34. using System.ServiceModel.Channels.Security;
  35. using System.IdentityModel.Selectors;
  36. using System.IdentityModel.Tokens;
  37. using System.ServiceModel.Security.Tokens;
  38. #endif
  39. using System.Text;
  40. namespace System.ServiceModel.Channels
  41. {
  42. public abstract class SecurityBindingElement : BindingElement
  43. {
  44. internal SecurityBindingElement ()
  45. {
  46. #if !NET_2_1
  47. DefaultAlgorithmSuite = SecurityAlgorithmSuite.Default;
  48. MessageSecurityVersion = MessageSecurityVersion.Default;
  49. KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
  50. endpoint = new SupportingTokenParameters ();
  51. operation = new Dictionary<string,SupportingTokenParameters> ();
  52. opt_endpoint = new SupportingTokenParameters ();
  53. opt_operation = new Dictionary<string,SupportingTokenParameters> ();
  54. service_settings = new LocalServiceSecuritySettings ();
  55. #endif
  56. IncludeTimestamp = true;
  57. LocalClientSettings = new LocalClientSecuritySettings ();
  58. }
  59. internal SecurityBindingElement (SecurityBindingElement other)
  60. {
  61. #if !NET_2_1
  62. alg_suite = other.alg_suite;
  63. key_entropy_mode = other.key_entropy_mode;
  64. security_header_layout = other.security_header_layout;
  65. msg_security_version = other.msg_security_version;
  66. endpoint = other.endpoint.Clone ();
  67. opt_endpoint = other.opt_endpoint.Clone ();
  68. operation = new Dictionary<string,SupportingTokenParameters> ();
  69. foreach (KeyValuePair<string,SupportingTokenParameters> p in other.operation)
  70. operation.Add (p.Key, p.Value.Clone ());
  71. opt_operation = new Dictionary<string,SupportingTokenParameters> ();
  72. foreach (KeyValuePair<string,SupportingTokenParameters> p in other.opt_operation)
  73. opt_operation.Add (p.Key, p.Value.Clone ());
  74. service_settings = other.service_settings.Clone ();
  75. #endif
  76. IncludeTimestamp = other.IncludeTimestamp;
  77. LocalClientSettings = other.LocalClientSettings.Clone ();
  78. }
  79. #if !NET_2_1
  80. SecurityAlgorithmSuite alg_suite;
  81. SecurityKeyEntropyMode key_entropy_mode;
  82. SecurityHeaderLayout security_header_layout;
  83. MessageSecurityVersion msg_security_version;
  84. SupportingTokenParameters endpoint, opt_endpoint;
  85. IDictionary<string,SupportingTokenParameters> operation, opt_operation;
  86. LocalServiceSecuritySettings service_settings;
  87. #endif
  88. public bool IncludeTimestamp { get; set; }
  89. public LocalClientSecuritySettings LocalClientSettings { get; private set; }
  90. #if !NET_2_1
  91. public SecurityAlgorithmSuite DefaultAlgorithmSuite {
  92. get { return alg_suite; }
  93. set { alg_suite = value; }
  94. }
  95. public SecurityKeyEntropyMode KeyEntropyMode {
  96. get { return key_entropy_mode; }
  97. set { key_entropy_mode = value; }
  98. }
  99. public LocalServiceSecuritySettings LocalServiceSettings {
  100. get { return service_settings; }
  101. }
  102. public SecurityHeaderLayout SecurityHeaderLayout {
  103. get { return security_header_layout; }
  104. set { security_header_layout = value; }
  105. }
  106. public MessageSecurityVersion MessageSecurityVersion {
  107. get { return msg_security_version; }
  108. set { msg_security_version = value; }
  109. }
  110. public SupportingTokenParameters EndpointSupportingTokenParameters {
  111. get { return endpoint; }
  112. }
  113. public IDictionary<string,SupportingTokenParameters> OperationSupportingTokenParameters {
  114. get { return operation; }
  115. }
  116. public SupportingTokenParameters OptionalEndpointSupportingTokenParameters {
  117. get { return opt_endpoint; }
  118. }
  119. public IDictionary<string,SupportingTokenParameters> OptionalOperationSupportingTokenParameters {
  120. get { return opt_operation; }
  121. }
  122. #endif
  123. [MonoTODO ("Implement for TransportSecurityBindingElement")]
  124. public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
  125. {
  126. #if NET_2_1
  127. // not sure this should be like this, but there isn't Symmetric/Asymmetric elements in 2.1 anyways.
  128. return context.CanBuildInnerChannelFactory<TChannel> ();
  129. #else
  130. if (this is TransportSecurityBindingElement)
  131. throw new NotImplementedException ();
  132. var symm = this as SymmetricSecurityBindingElement;
  133. var asymm = this as AsymmetricSecurityBindingElement;
  134. var pt = symm != null ? symm.ProtectionTokenParameters : asymm != null ? asymm.InitiatorTokenParameters : null;
  135. if (pt == null)
  136. return false;
  137. var t = typeof (TChannel);
  138. var req = new InitiatorServiceModelSecurityTokenRequirement ();
  139. pt.InitializeSecurityTokenRequirement (req);
  140. object dummy;
  141. if (req.Properties.TryGetValue (ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty, out dummy) && dummy != null) {
  142. if (t == typeof (IRequestSessionChannel))
  143. return context.CanBuildInnerChannelFactory<IRequestChannel> () ||
  144. context.CanBuildInnerChannelFactory<IRequestSessionChannel> ();
  145. else if (t == typeof (IDuplexSessionChannel))
  146. return context.CanBuildInnerChannelFactory<IDuplexChannel> () ||
  147. context.CanBuildInnerChannelFactory<IDuplexSessionChannel> ();
  148. } else {
  149. if (t == typeof (IRequestChannel))
  150. return context.CanBuildInnerChannelFactory<IRequestChannel> () ||
  151. context.CanBuildInnerChannelFactory<IRequestSessionChannel> ();
  152. else if (t == typeof (IDuplexChannel))
  153. return context.CanBuildInnerChannelFactory<IDuplexChannel> () ||
  154. context.CanBuildInnerChannelFactory<IDuplexSessionChannel> ();
  155. }
  156. return false;
  157. #endif
  158. }
  159. public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
  160. BindingContext context)
  161. {
  162. return BuildChannelFactoryCore<TChannel> (context);
  163. }
  164. protected abstract IChannelFactory<TChannel>
  165. BuildChannelFactoryCore<TChannel> (BindingContext context);
  166. #if !NET_2_1
  167. [MonoTODO ("Implement for TransportSecurityBindingElement")]
  168. public override bool CanBuildChannelListener<TChannel> (BindingContext context)
  169. {
  170. if (this is TransportSecurityBindingElement)
  171. throw new NotImplementedException ();
  172. var symm = this as SymmetricSecurityBindingElement;
  173. var asymm = this as AsymmetricSecurityBindingElement;
  174. var pt = symm != null ? symm.ProtectionTokenParameters : asymm != null ? asymm.RecipientTokenParameters : null;
  175. if (pt == null)
  176. return false;
  177. var t = typeof (TChannel);
  178. var req = new InitiatorServiceModelSecurityTokenRequirement ();
  179. pt.InitializeSecurityTokenRequirement (req);
  180. object dummy;
  181. if (req.Properties.TryGetValue (ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty, out dummy) && dummy != null) {
  182. if (t == typeof (IReplySessionChannel))
  183. return context.CanBuildInnerChannelListener<IReplyChannel> () ||
  184. context.CanBuildInnerChannelListener<IReplySessionChannel> ();
  185. else if (t == typeof (IDuplexSessionChannel))
  186. return context.CanBuildInnerChannelListener<IDuplexChannel> () ||
  187. context.CanBuildInnerChannelListener<IDuplexSessionChannel> ();
  188. } else {
  189. if (t == typeof (IReplyChannel))
  190. return context.CanBuildInnerChannelListener<IReplyChannel> () ||
  191. context.CanBuildInnerChannelListener<IReplySessionChannel> ();
  192. else if (t == typeof (IDuplexChannel))
  193. return context.CanBuildInnerChannelListener<IDuplexChannel> () ||
  194. context.CanBuildInnerChannelListener<IDuplexSessionChannel> ();
  195. }
  196. return false;
  197. }
  198. public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
  199. BindingContext context)
  200. {
  201. return BuildChannelListenerCore<TChannel> (context);
  202. }
  203. protected abstract IChannelListener<TChannel>
  204. BuildChannelListenerCore<TChannel> (BindingContext context)
  205. where TChannel : class, IChannel;
  206. public override T GetProperty<T> (BindingContext context)
  207. {
  208. // It is documented that ISecurityCapabilities and IdentityVerifier can be returned.
  209. // Though, this class is not inheritable, and they are returned by the derived types.
  210. // So I don't care about them here.
  211. return context.GetInnerProperty<T> ();
  212. }
  213. public virtual void SetKeyDerivation (bool requireDerivedKeys)
  214. {
  215. endpoint.SetKeyDerivation (requireDerivedKeys);
  216. opt_endpoint.SetKeyDerivation (requireDerivedKeys);
  217. foreach (SupportingTokenParameters p in operation.Values)
  218. p.SetKeyDerivation (requireDerivedKeys);
  219. foreach (SupportingTokenParameters p in opt_operation.Values)
  220. p.SetKeyDerivation (requireDerivedKeys);
  221. }
  222. public override string ToString ()
  223. {
  224. var sb = new StringBuilder ();
  225. sb.Append (GetType ().FullName).Append (":\n");
  226. foreach (var pi in GetType ().GetProperties ()) {
  227. var simple = Type.GetTypeCode (pi.PropertyType) != TypeCode.Object;
  228. var val = pi.GetValue (this, null);
  229. sb.Append (pi.Name).Append (':');
  230. if (val != null)
  231. sb.AppendFormat ("{0}{1}{2}", simple ? " " : "\n", simple ? "" : " ", String.Join ("\n ", val.ToString ().Split ('\n')));
  232. sb.Append ('\n');
  233. }
  234. sb.Length--; // chop trailing EOL.
  235. return sb.ToString ();
  236. }
  237. #else
  238. [MonoTODO]
  239. public override T GetProperty<T> (BindingContext context)
  240. {
  241. return null;
  242. }
  243. #endif
  244. #region Factory methods
  245. #if !NET_2_1
  246. public static SymmetricSecurityBindingElement
  247. CreateAnonymousForCertificateBindingElement ()
  248. {
  249. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  250. be.RequireSignatureConfirmation = true;
  251. be.ProtectionTokenParameters = CreateProtectionTokenParameters (true);
  252. return be;
  253. }
  254. public static TransportSecurityBindingElement
  255. CreateCertificateOverTransportBindingElement ()
  256. {
  257. return CreateCertificateOverTransportBindingElement (MessageSecurityVersion.Default);
  258. }
  259. public static TransportSecurityBindingElement
  260. CreateCertificateOverTransportBindingElement (MessageSecurityVersion version)
  261. {
  262. var be = new TransportSecurityBindingElement () { MessageSecurityVersion = version };
  263. be.EndpointSupportingTokenParameters.SignedEncrypted.Add (new X509SecurityTokenParameters ());
  264. return be;
  265. }
  266. [MonoTODO]
  267. public static AsymmetricSecurityBindingElement
  268. CreateCertificateSignatureBindingElement ()
  269. {
  270. throw new NotImplementedException ();
  271. }
  272. [MonoTODO]
  273. public static SymmetricSecurityBindingElement
  274. CreateIssuedTokenBindingElement (
  275. IssuedSecurityTokenParameters issuedTokenParameters)
  276. {
  277. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  278. be.ProtectionTokenParameters = issuedTokenParameters;
  279. return be;
  280. }
  281. public static SymmetricSecurityBindingElement
  282. CreateIssuedTokenForCertificateBindingElement (
  283. IssuedSecurityTokenParameters issuedTokenParameters)
  284. {
  285. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  286. be.RequireSignatureConfirmation = true;
  287. be.ProtectionTokenParameters = CreateProtectionTokenParameters (true);
  288. be.EndpointSupportingTokenParameters.Endorsing.Add (
  289. issuedTokenParameters);
  290. return be;
  291. }
  292. [MonoTODO]
  293. public static SymmetricSecurityBindingElement
  294. CreateIssuedTokenForSslBindingElement (
  295. IssuedSecurityTokenParameters issuedTokenParameters)
  296. {
  297. return CreateIssuedTokenForSslBindingElement (
  298. issuedTokenParameters, false);
  299. }
  300. [MonoTODO]
  301. public static SymmetricSecurityBindingElement
  302. CreateIssuedTokenForSslBindingElement (
  303. IssuedSecurityTokenParameters issuedTokenParameters,
  304. bool requireCancellation)
  305. {
  306. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  307. be.RequireSignatureConfirmation = true;
  308. be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
  309. be.EndpointSupportingTokenParameters.Endorsing.Add (
  310. issuedTokenParameters);
  311. return be;
  312. }
  313. [MonoTODO]
  314. public static TransportSecurityBindingElement
  315. CreateIssuedTokenOverTransportBindingElement (
  316. IssuedSecurityTokenParameters issuedTokenParameters)
  317. {
  318. throw new NotImplementedException ();
  319. }
  320. [MonoTODO]
  321. public static SymmetricSecurityBindingElement CreateKerberosBindingElement ()
  322. {
  323. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  324. be.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128;
  325. be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
  326. be.ProtectionTokenParameters.InclusionMode =
  327. SecurityTokenInclusionMode.Once;
  328. return be;
  329. }
  330. [MonoTODO]
  331. public static TransportSecurityBindingElement
  332. CreateKerberosOverTransportBindingElement ()
  333. {
  334. throw new NotImplementedException ();
  335. }
  336. public static SecurityBindingElement
  337. CreateMutualCertificateBindingElement ()
  338. {
  339. return CreateMutualCertificateBindingElement (MessageSecurityVersion.Default, false);
  340. }
  341. public static SecurityBindingElement
  342. CreateMutualCertificateBindingElement (MessageSecurityVersion version)
  343. {
  344. return CreateMutualCertificateBindingElement (version, false);
  345. }
  346. [MonoTODO("Does not support allowSerializedSigningTokenOnReply.")]
  347. public static SecurityBindingElement
  348. CreateMutualCertificateBindingElement (
  349. MessageSecurityVersion version,
  350. bool allowSerializedSigningTokenOnReply)
  351. {
  352. if (version == null)
  353. throw new ArgumentNullException ("version");
  354. if (allowSerializedSigningTokenOnReply)
  355. throw new NotSupportedException ("allowSerializedSigningTokenOnReply is not supported");
  356. if (version.SecurityVersion == SecurityVersion.WSSecurity10) {
  357. var recipient = new X509SecurityTokenParameters (
  358. X509KeyIdentifierClauseType.Any,
  359. SecurityTokenInclusionMode.Never);
  360. recipient.RequireDerivedKeys = false;
  361. var initiator = new X509SecurityTokenParameters (
  362. X509KeyIdentifierClauseType.Any,
  363. SecurityTokenInclusionMode.AlwaysToRecipient);
  364. initiator.RequireDerivedKeys = false;
  365. return new AsymmetricSecurityBindingElement(recipient, initiator) {
  366. MessageSecurityVersion = version
  367. };
  368. } else {
  369. X509SecurityTokenParameters p =
  370. new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint);
  371. p.RequireDerivedKeys = false;
  372. var sym = new SymmetricSecurityBindingElement () {
  373. MessageSecurityVersion = version,
  374. RequireSignatureConfirmation = true};
  375. sym.EndpointSupportingTokenParameters.Endorsing.Add (p);
  376. return sym;
  377. }
  378. }
  379. [MonoTODO]
  380. public static AsymmetricSecurityBindingElement
  381. CreateMutualCertificateDuplexBindingElement ()
  382. {
  383. throw new NotImplementedException ();
  384. }
  385. [MonoTODO]
  386. public static AsymmetricSecurityBindingElement
  387. CreateMutualCertificateDuplexBindingElement (
  388. MessageSecurityVersion version)
  389. {
  390. throw new NotImplementedException ();
  391. }
  392. public static SecurityBindingElement
  393. CreateSecureConversationBindingElement (SecurityBindingElement binding)
  394. {
  395. return CreateSecureConversationBindingElement (binding, false);
  396. }
  397. public static SecurityBindingElement
  398. CreateSecureConversationBindingElement (
  399. SecurityBindingElement binding, bool requireCancellation)
  400. {
  401. return CreateSecureConversationBindingElement (binding, requireCancellation, null);
  402. }
  403. public static SecurityBindingElement
  404. CreateSecureConversationBindingElement (
  405. SecurityBindingElement binding, bool requireCancellation,
  406. ChannelProtectionRequirements protectionRequirements)
  407. {
  408. SymmetricSecurityBindingElement be =
  409. new SymmetricSecurityBindingElement ();
  410. be.ProtectionTokenParameters =
  411. new SecureConversationSecurityTokenParameters (
  412. binding, requireCancellation, protectionRequirements);
  413. return be;
  414. }
  415. public static SymmetricSecurityBindingElement
  416. CreateSslNegotiationBindingElement (bool requireClientCertificate)
  417. {
  418. return CreateSslNegotiationBindingElement (
  419. requireClientCertificate, false);
  420. }
  421. public static SymmetricSecurityBindingElement
  422. CreateSslNegotiationBindingElement (
  423. bool requireClientCertificate,
  424. bool requireCancellation)
  425. {
  426. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  427. be.ProtectionTokenParameters = new SslSecurityTokenParameters (requireClientCertificate, requireCancellation);
  428. return be;
  429. }
  430. public static SymmetricSecurityBindingElement
  431. CreateSspiNegotiationBindingElement ()
  432. {
  433. return CreateSspiNegotiationBindingElement (true);
  434. }
  435. public static SymmetricSecurityBindingElement
  436. CreateSspiNegotiationBindingElement (bool requireCancellation)
  437. {
  438. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  439. be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
  440. return be;
  441. }
  442. public static TransportSecurityBindingElement
  443. CreateSspiNegotiationOverTransportBindingElement ()
  444. {
  445. return CreateSspiNegotiationOverTransportBindingElement (false);
  446. }
  447. [MonoTODO]
  448. public static TransportSecurityBindingElement
  449. CreateSspiNegotiationOverTransportBindingElement (bool requireCancellation)
  450. {
  451. throw new NotImplementedException ();
  452. }
  453. static X509SecurityTokenParameters CreateProtectionTokenParameters (bool cert)
  454. {
  455. X509SecurityTokenParameters p =
  456. new X509SecurityTokenParameters ();
  457. p.X509ReferenceStyle = X509KeyIdentifierClauseType.Thumbprint;
  458. if (cert)
  459. p.InclusionMode = SecurityTokenInclusionMode.Never;
  460. return p;
  461. }
  462. public static SymmetricSecurityBindingElement
  463. CreateUserNameForCertificateBindingElement ()
  464. {
  465. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  466. be.ProtectionTokenParameters = CreateProtectionTokenParameters (true);
  467. UserNameSecurityTokenParameters utp =
  468. new UserNameSecurityTokenParameters ();
  469. be.EndpointSupportingTokenParameters.SignedEncrypted.Add (utp);
  470. return be;
  471. }
  472. public static SymmetricSecurityBindingElement
  473. CreateUserNameForSslBindingElement ()
  474. {
  475. return CreateUserNameForSslBindingElement (false);
  476. }
  477. public static SymmetricSecurityBindingElement
  478. CreateUserNameForSslBindingElement (bool requireCancellation)
  479. {
  480. SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
  481. be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
  482. UserNameSecurityTokenParameters utp =
  483. new UserNameSecurityTokenParameters ();
  484. be.EndpointSupportingTokenParameters.SignedEncrypted.Add (utp);
  485. return be;
  486. }
  487. #endif
  488. [MonoTODO]
  489. public static TransportSecurityBindingElement
  490. CreateUserNameOverTransportBindingElement ()
  491. {
  492. var be = new TransportSecurityBindingElement ();
  493. #if !NET_2_1 // FIXME: there should be whatever else to do for 2.1 instead.
  494. be.EndpointSupportingTokenParameters.SignedEncrypted.Add (new UserNameSecurityTokenParameters ());
  495. #endif
  496. return be;
  497. }
  498. #endregion
  499. #if !NET_2_1
  500. // It seems almost internal, hardcoded like this (I tried
  501. // custom parameters that sets IssuedTokenSecurityTokenParameters
  502. // like below ones, but that didn't trigger this method).
  503. protected static void SetIssuerBindingContextIfRequired (
  504. SecurityTokenParameters parameters,
  505. BindingContext issuerBindingContext)
  506. {
  507. if (parameters is IssuedSecurityTokenParameters ||
  508. parameters is SecureConversationSecurityTokenParameters ||
  509. parameters is SslSecurityTokenParameters ||
  510. parameters is SspiSecurityTokenParameters) {
  511. parameters.IssuerBindingContext = issuerBindingContext;
  512. }
  513. }
  514. #endif
  515. }
  516. }