//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------- namespace System.IdentityModel.Tokens { using System; using System.Collections.Generic; using System.Collections.ObjectModel; /// /// Represents the AudienceRestriction element specified in [Saml2Core, 2.5.1.4]. /// /// /// If the Audiences collection is empty, an InvalidOperationException will be /// thrown during serialization. /// public class Saml2AudienceRestriction { private Collection audiences = new Collection(); /// /// Creates an instance of Saml2AudienceRestriction. /// public Saml2AudienceRestriction() { } /// /// Creates an instance of Saml2AudienceRestriction. /// /// The audience element contained in this restriction. public Saml2AudienceRestriction(Uri audience) : this(new Uri[] { audience }) { } /// /// Creates an instance of Saml2AudienceRestriction. /// /// The collection of audience elements contained in this restriction. public Saml2AudienceRestriction(IEnumerable audiences) { if (null == audiences) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("audiences"); } foreach (Uri audience in audiences) { if (null == audience) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("audiences"); } this.audiences.Add(audience); } } /// /// Gets the audiences for which the assertion is addressed. /// public Collection Audiences { get { return this.audiences; } } } }