Can someone please point me in the direction of an example creating a SamlAssertion that includes an AudienceRestriction in the Conditions node?
below is an example of my code where I would want to put it:
//Create the SAML Assertion
SamlAssertion samlAssert = new SamlAssertion();
samlAssert.AssertionId = Convert.ToBase64String(encoding.GetBytes(System.Guid.NewGuid().ToString()));
samlAssert.Issuer = "http://www.example.com/";
// Set up the conditions of the assertion - Not Before and Not After
samlAssert.Conditions = new SamlConditions(DateTime.Now, DateTime.Now.AddMinutes(5));
The desired XML looks something like this:
<Assertion xmlns="urn:oasis:names:tc:SAML:1.0:assertion" AssertionID="_e835eca079133299b2f8a2a63ad72fe8" IssueInstant="2007-02-07T20:22:58.165Z" Issuer="http://www.example.com/" MajorVersion="1" MinorVersion="1">
<Conditions NotBefore="2007-02-07T20:22:58.162Z" NotOnOrAfter="2007-02-07T20:24:58.162Z">
<AudienceRestrictionCondition>
<Audience>http://www.example2.com</Audience>
</AudienceRestrictionCondition>
</Conditions>
I see that there's a constructor for SamlConditions class that allows for a 3rd parameter, the conditions, and that there's a SamlAudienceRestriction class, but I can't seem to figure out how to connect the two. I think if I were to see a bit of code, it would become painfully obvious to me, but unfortunately, my google-foo is failing me today.