ComponentPro UltimateSaml

      AudienceRestriction Class

      See AlsoMembersMembers Options: Show AllLanguage Filter: AllSend comments on this topic to ComponentPro
      The AudienceRestriction element specifies that the assertion is addressed to one or more specific audiences identified by Audience elements. Although a SAML relying party that is outside the audiences specified is capable of drawing conclusions from an assertion, the SAML asserting party explicitly makes no representation as to accuracy or trustworthiness to such a party.

      Syntax

      public class AudienceRestriction : Condition

      Examples

      Shows how to create a Response object and sign it.

      using System;
      using ComponentPro.Saml2;
      using System.Xml;
      using System.Security.Cryptography.X509Certificates;
      
      ...
      
      X509Certificate2 x509Certificate = new X509Certificate2(@"..\..\Pkey.pfx", "password");
      
      // Create SAML Response object.
      Response response = new Response();
      
      Assertion samlAssertion = new Assertion();
      Audience aud = new Audience();
      aud.Uri = "http://testuri.org";
      AudienceRestriction ar = new AudienceRestriction();
      ar.Audiences.Add(aud);
      
      samlAssertion.Conditions = new Conditions();
      samlAssertion.Conditions.ConditionsList.Add(ar);
      
      samlAssertion.Sign(x509Certificate);
      
      // Add SAML Assertion
      response.Assertions.Add(samlAssertion);
      
      // You can also sign the SAML response with the following code
      response.Sign(x509Certificate);
      
      XmlElement xmlElement = response.GetXml();
      
      System.Diagnostics.Trace.WriteLine(xmlElement.OuterXml);
      Console.WriteLine(xmlElement.OuterXml);

      Inheritance Hierarchy

               ComponentPro.Saml2.ComponentPro.Saml2.AudienceRestriction

      Framework

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Saml (in ComponentPro.Saml.dll)

      See Also