Created
August 16, 2011 14:46
-
-
Save chgeuer/1149255 to your computer and use it in GitHub Desktop.
How to programatically disable WS-SC session tokens and turn on cookies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Binding DisableRequireSecurityContextCancellation(Binding binding) | |
{ | |
var bindingElements = binding.CreateBindingElements(); | |
var securityBindingElement = bindingElements.OfType<SymmetricSecurityBindingElement>().FirstOrDefault(); | |
if (securityBindingElement == null) | |
{ | |
throw new NotSupportedException("Cannot locate SymmetricSecurityBindingElement"); | |
} | |
var protectionTokenParameters = securityBindingElement.ProtectionTokenParameters; | |
if (protectionTokenParameters == null) | |
{ | |
throw new NotSupportedException("Cannot locate ProtectionTokenParameters"); | |
} | |
var secureConversationSecurityTokenParameters = protectionTokenParameters as SecureConversationSecurityTokenParameters; | |
if (secureConversationSecurityTokenParameters == null) | |
{ | |
throw new NotSupportedException("Cannot locate SecureConversationSecurityTokenParameters"); | |
} | |
// this should be equivalent to setting requireSecurityContextCancellation to false. | |
secureConversationSecurityTokenParameters.RequireCancellation = false; | |
return new CustomBinding(bindingElements); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment