Add Saml Assertion to a custom binding

  • Thread starter Thread starter Francesco Leo
  • Start date Start date
F

Francesco Leo

Guest
I have this CustomBinding:

var sec = new AsymmetricSecurityBindingElement(
new X509SecurityTokenParameters(X509KeyIdentifierClauseType.Any, SecurityTokenInclusionMode.Never),
new X509SecurityTokenParameters(X509KeyIdentifierClauseType.Any, SecurityTokenInclusionMode.AlwaysToRecipient));
sec.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
sec.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
sec.IncludeTimestamp = true;
sec.SetKeyDerivation(false);
sec.KeyEntropyMode = System.ServiceModel.Security.SecurityKeyEntropyMode.ServerEntropy;
sec.EnableUnsecuredResponse = true;

CustomBinding myBinding = new CustomBinding();
myBinding.Elements.Add(sec);

myBinding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));
myBinding.Elements.Add(new HttpsTransportBindingElement());

I would like to add some SAML assertions like this:

<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" saml:ID="authorization-assertion" saml:IssueInstant="2020-11-12T09:10:27Z" saml:Version="2.0" wsu:Id="authorization-assertion" xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:assertion saml-schema-assertion-2.0.xsd">
<saml:Issuer>COMPANY</saml:Issuer>
<saml:Subject>
<saml:nameID>02942630753.localhost.com</saml:nameID>
</saml:Subject>
<saml:AuthzDecisionStatement Decision="Permit" Resource="IDocument">
<saml:Action Namespace="http://FSE/IDocumentService"/>
</saml:AuthzDecisionStatement>
<saml:AttributeStatement/>
</saml:Assertion>
I thought I might use: myBinding.Elements.Add(), But I don't know how to construct the Assertion element.

Any suggestions?

Continue reading...
 
Back
Top