The AuthnContext element specifies the context of an authentication event. The element can contain an authentication context class reference, an authentication context declaration or declaration reference, or both.

      Syntax

      public class AuthnContext : SamlObject

      Examples

      Shows how to create an AuthnStatement and add it to an Assertion.

      using System;
      using ComponentPro.Saml2;
      
      ...
      
      // Create SAML Assertion.
      Assertion samlAssertion = new Assertion();
      
      // Set Issuer
      samlAssertion.Issuer = new Issuer("http://idp.domain.org", null, null, SamlNameIdentifierFormat.Entity, null);
      samlAssertion.Subject = new Subject(new NameId("johnvu@test.com", null, null, SamlNameIdentifierFormat.EmailAddress, null));
      samlAssertion.Conditions = new Conditions(new TimeSpan(1, 0, 0));
      
      // Create SAML AuthnStatement.
      ComponentPro.Saml2.AuthnStatement authnStatement = new ComponentPro.Saml2.AuthnStatement();
      authnStatement.AuthnContext = new AuthnContext();
      authnStatement.SessionNotOnOrAfter = DateTime.UtcNow.AddDays(1);
      authnStatement.AuthnContext.AuthnContextClassRef = new AuthnContextClassRef(SamlAuthenticationContext.InternetProtocolPassword);
      
      // Add it to the assertion.
      samlAssertion.Statements.Add(authnStatement);
      
      // Add an attribute statement.
      AttributeStatement attributeStatement = new AttributeStatement();
      // Add FirstName attribute
      attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("FirstName", SamlAttributeNameFormat.Basic, null, "John"));
      
      samlAssertion.Statements.Add(attributeStatement);
      
      attributeStatement = new AttributeStatement();
      // Add LastName attribute
      attributeStatement.Attributes.Add(new ComponentPro.Saml2.Attribute("LastName", SamlAttributeNameFormat.Basic, null, "Vu"));
      
      samlAssertion.Statements.Add(attributeStatement);

      Inheritance Hierarchy

            ComponentPro.Saml2.ComponentPro.Saml2.AuthnContext

      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