//-----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace System.IdentityModel.Tokens
{
using System;
using System.Collections.ObjectModel;
///
/// Represents the AuthnContext element specified in [Saml2Core, 2.7.2.2].
///
///
///
/// This base class does not directly support any by-value authentication
/// context declarations (represented in XML by the AuthnContextDecl element).
/// To support by-value declarations, extend this class to support the data
/// model and extend Saml2AssertionSerializer, overriding ReadAuthnContext
/// and WriteAuthnContext to read and write the by-value declaration.
///
///
public class Saml2AuthenticationContext
{
private Collection authenticatingAuthorities = new AbsoluteUriCollection();
private Uri classReference;
private Uri declarationReference;
///
/// Creates an instance of Saml2AuthenticationContext.
///
public Saml2AuthenticationContext()
: this(null, null)
{
}
///
/// Creates an instance of Saml2AuthenticationContext.
///
/// The class reference of the authentication context.
public Saml2AuthenticationContext(Uri classReference)
: this(classReference, null)
{
}
///
/// Creates an instance of Saml2AuthenticationContext.
///
/// The class reference of the authentication context.
/// The declaration reference of the authentication context.
public Saml2AuthenticationContext(Uri classReference, Uri declarationReference)
{
// Must be absolute URIs
if (null != classReference && !classReference.IsAbsoluteUri)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("classReference", SR.GetString(SR.ID0013));
}
if (null != declarationReference && !declarationReference.IsAbsoluteUri)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("declarationReference", SR.GetString(SR.ID0013));
}
this.classReference = classReference;
this.declarationReference = declarationReference;
}
///
/// Gets Zero or more unique identifiers of authentication authorities that
/// were involved in the authentication of the principal (not including
/// the assertion issuer, who is presumed to have been involved without
/// being explicitly named here). [Saml2Core, 2.7.2.2]
///
public Collection AuthenticatingAuthorities
{
get { return this.authenticatingAuthorities; }
}
///
/// Gets or sets a URI reference identifying an authentication context class that
/// describes the authentication context declaration that follows.
/// [Saml2Core, 2.7.2.2]
///
public Uri ClassReference
{
get
{
return this.classReference;
}
set
{
if (null != value && !value.IsAbsoluteUri)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("value", SR.GetString(SR.ID0013));
}
this.classReference = value;
}
}
///
/// Gets or sets a URI reference that identifies an authentication context
/// declaration. [Saml2Core, 2.7.2.2]
///
public Uri DeclarationReference
{
get
{
return this.declarationReference;
}
set
{
if (null != value && !value.IsAbsoluteUri)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("value", SR.GetString(SR.ID0013));
}
this.declarationReference = value;
}
}
}
}