Authentication context classes.
public static class SamlAuthenticationContext
Public NotInheritable Class SamlAuthenticationContext
public ref class SamlAuthenticationContext abstract sealed
Shows how to create an AuthnRequest request and send it over HTTP POST or HTTP Redirect.
using System.Security.Cryptography.X509Certificates;
using System.Web;
using ComponentPro.Saml2;
...
// Create a new instance of the AuthnRequest class.
AuthnRequest request = new AuthnRequest();
request.IsPassive = false;
// Set Protocol Binding.
request.ProtocolBinding = SamlBindingUri.HttpPost;
// Set the target provider's Assertion Consumer Service Url.
request.AssertionConsumerServiceUrl = "your url";
// Set Issuer
request.Issuer = new Issuer();
request.Issuer.NameIdentifier = "your name identifier";
request.NameIdPolicy = new NameIdPolicy();
request.NameIdPolicy.SpNameQualifier = "moodle.sp.myname";
request.NameIdPolicy.AllowCreate = true;
request.NameIdPolicy.Format = SamlNameIdentifierFormat.Persistent;
request.RequestedAuthnContext = new RequestedAuthnContext();
request.RequestedAuthnContext.Comparison = SamlAuthenticationContextComparison.Exact;
request.RequestedAuthnContext.AuthenticationContexts.Add(new AuthnContextClassRef(SamlAuthenticationContext.PasswordProtectedTransport));
// Send the request over HTTP POST
request.SendHttpPost(Response, "http://mybaseurl", "my_relay_state");
// Or you can send it over HTTP Redirect
// X509Certificate2 certificate = new X509Certificate2("PKey.pfx", "password");
// request.Redirect(Response, "http://mybaseurl", "my_relay_state", certificate.PrivateKey);
Imports System.Security.Cryptography.X509Certificates
Imports ComponentPro.Saml2
...
' Create a new instance of the AuthnRequest class.
Dim request As New AuthnRequest()
request.IsPassive = False
' Set Protocol Binding.
request.ProtocolBinding = SamlBindingUri.HttpPost
' Set the target provider's Assertion Consumer Service Url.
request.AssertionConsumerServiceUrl = "your url"
' Set Issuer
request.Issuer = New Issuer()
request.Issuer.NameIdentifier = "your name identifier"
request.NameIdPolicy = New NameIdPolicy()
request.NameIdPolicy.SpNameQualifier = "moodle.sp.myname"
request.NameIdPolicy.AllowCreate = True
request.NameIdPolicy.Format = SamlNameIdentifierFormat.Persistent
request.RequestedAuthnContext = New RequestedAuthnContext()
request.RequestedAuthnContext.Comparison = SamlAuthenticationContextComparison.Exact
request.RequestedAuthnContext.AuthenticationContexts.Add(New AuthnContextClassRef(SamlAuthenticationContext.PasswordProtectedTransport))
' Send the request over HTTP POST
request.SendHttpPost(Response, "http://mybaseurl", "my_relay_state")
' Or you can send it over HTTP Redirect
' X509Certificate2 certificate = new X509Certificate2("PKey.pfx", "password");
' request.Redirect(Response, "http://mybaseurl", "my_relay_state", certificate.PrivateKey);
ComponentPro.Saml2.ComponentPro.Saml2.SamlAuthenticationContext