wcf icon indicating copy to clipboard operation
wcf copied to clipboard

A way to set WSTrustChannelSecurityTokenProvider.ClientCredentials

Open thuannguy opened this issue 3 years ago • 0 comments

The WsTrustRequest object and its serializer has supports for many request elements that I need, but the WSTrustChannelSecurityTokenProvider provider does not have many of them set. Thus, I need to customize content of the WsTrustRequest object and the only way to do that is to derive from the WSTrustChannelSecurityTokenProvider and override the CreateWsTrustRequest method:

image

The next step is to make a new implement of the ClientCredentialsSecurityTokenManager (similar to WSTrustChannelSecurityTokenManager) which can return my new SecurityTokenProvider:

Related code of the built-in WSTrustChannelSecurityTokenManager class:

image

But there is a big problem here: in my custom code, I cannot set the ClientCredentials property because it is an internal one.

I would argue not allowing user code to set the ClientCredentials property is a big usability design problem. This means that any use cases that need ClientCredentials simply cannot work. This leaves me with 2 equally ugly paths: either use reflection to set ClientCredentials or clone the whole code of the WSTrustChannelSecurityTokenProvider to my custom provider.

Is there a better approach? Otherwise, I would like to request for a way to set the ClientCredentials object.

Thank you for reading, Thuan.

thuannguy avatar Aug 26 '22 05:08 thuannguy