Skip to content
Snippets Groups Projects
Select Git revision
  • v2
  • Coscine/FederationAdaption default
  • gitkeep
  • dev protected
  • Sprint/2022-01
  • fixmerge
  • master
  • develop protected
  • dependabot/nuget/Samples/SampleMvcApplication/bootstrap-3.4.1
  • dependabot/nuget/Samples/SampleOwinApplication/bootstrap-3.4.1
  • v1
  • netcore-cookiemanager
  • limitingcookiemanager
  • owin-cookiemanager
  • owin-cookiemanger-changeinterface
  • excess-cookies
  • missing_nodes_exceptions
  • empty_ref_exception
  • fix_shared_options
  • csphashsupport
  • v2.7.0
  • v1.0.2
  • v2.6.0
  • v2.5.0
  • v1.0.1
  • v2.4.0
  • v2.3.0
  • v2.2.0
  • v2.1.0
  • v2.0.0
  • v1.0.0
  • v0.24.0
  • v0.23.0
  • v2.0.0-preview01
  • v0.22.0
  • v0.21.2
  • v0.21.1
  • v0.21.0
  • v0.20.0
  • v0.19.0
40 results

NameIdFormatExtension.cs

Blame
  • user avatar
    Anders Abel authored
    9b75409f
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    NameIdFormatExtension.cs 1.66 KiB
    using System;
    using Sustainsys.Saml2.Saml2P;
    using System.Diagnostics.CodeAnalysis;
    using System.Collections.Generic;
    
    namespace Sustainsys.Saml2
    {
        /// <summary>
        /// Extensions for NameIdFormat enum.
        /// </summary>
        public static class NameIdFormatExtension
        {
            static Dictionary<NameIdFormat, Uri> enumToUri
                = new Dictionary<NameIdFormat, Uri>()
                {
                    { NameIdFormat.Unspecified, new Uri("urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified") },
                    { NameIdFormat.EmailAddress, new Uri("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress") },
                    { NameIdFormat.X509SubjectName, new Uri("urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName") },
                    { NameIdFormat.WindowsDomainQualifiedName, new Uri("urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName") },
                    { NameIdFormat.KerberosPrincipalName, new Uri("urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos") },
                    { NameIdFormat.EntityIdentifier, new Uri("urn:oasis:names:tc:SAML:2.0:nameid-format:entity") },
                    { NameIdFormat.Persistent, new Uri("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent") },
                    { NameIdFormat.Transient, new Uri("urn:oasis:names:tc:SAML:2.0:nameid-format:transient") }
                };
            
            /// <summary>
            /// Get the full Uri for a NameIdFormat.
            /// </summary>
            /// <param name="nameIdFormat">NameIdFormat to get Uri for</param>
            /// <returns>Uri</returns>
            public static Uri GetUri(this NameIdFormat nameIdFormat)
            {
                return enumToUri[nameIdFormat];
            }
        }
    }