Beispiel #1
0
        public static string GetString(this NameIdFormat nameIdFormat)
        {
            switch (nameIdFormat)
            {
            case NameIdFormat.Unspecified:
                return("urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified");

            case NameIdFormat.EmailAddress:
                return("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress");

            case NameIdFormat.X509SubjectName:
                return("urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName");

            case NameIdFormat.WindowsDomainQualifiedName:
                return("urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName");

            case NameIdFormat.KerberosPrincipalName:
                return("urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos");

            case NameIdFormat.EntityIdentifier:
                return("urn:oasis:names:tc:SAML:2.0:nameid-format:entity");

            case NameIdFormat.Persistent:
                return("urn:oasis:names:tc:SAML:2.0:nameid-format:persistent");

            case NameIdFormat.Transient:
                return("urn:oasis:names:tc:SAML:2.0:nameid-format:transient");

            default:
                throw new ArgumentException("enum member does not exist", nameof(nameIdFormat));
            }
        }
        public Saml2AuthenticationRequest(XmlElement xml, string relayState)
        {
            ReadBaseProperties(xml);
            RelayState = relayState;

            var AssertionConsumerServiceUriString = xml.Attributes["AssertionConsumerServiceURL"].GetValueIfNotNull();

            if (AssertionConsumerServiceUriString != null)
            {
                AssertionConsumerServiceUrl = new Uri(AssertionConsumerServiceUriString);
            }

            var node = xml["NameIDPolicy", Saml2Namespaces.Saml2PName];

            if (node != null)
            {
                var          fullFormat   = node.Attributes["Format"].GetValueIfNotNull();
                var          format       = fullFormat?.Split(':').LastOrDefault();
                NameIdFormat nameIdFormat = NameIdFormat.NotConfigured;
                if (format != null)
                {
                    Enum.TryParse(format, true, out nameIdFormat);
                }

                bool?allowCreate    = null;
                var  allowCreateStr = node.Attributes["AllowCreate"].GetValueIfNotNull();
                if (allowCreateStr != null)
                {
                    allowCreate = bool.Parse(allowCreateStr);
                }

                NameIdPolicy = new Saml2NameIdPolicy(allowCreate, nameIdFormat);
            }
        }
Beispiel #3
0
        public override void Seed(IDbContext context)
        {
            var transientNameIdFormat = new NameIdFormat {
                Key = "Transient", Uri = NameIdentifierFormats.Transient
            };

            context.Add <NameIdFormat>(transientNameIdFormat);

            var persistentNameIdFormat = new NameIdFormat {
                Key = "Persistent", Uri = NameIdentifierFormats.Persistent
            };

            context.Add <NameIdFormat>(persistentNameIdFormat);

            Seeder._cache.Add(Seeder.NameIdKey, new[] { transientNameIdFormat, persistentNameIdFormat });
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="allowCreate"></param>
 /// <param name="format"></param>
 public Saml2NameIdPolicy(bool?allowCreate, NameIdFormat format)
 {
     AllowCreate = allowCreate;
     Format      = format;
 }
Beispiel #5
0
 /// <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]);
 }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="allowCreate"></param>
 /// <param name="format"></param>
 public Saml2NameIdPolicy(bool? allowCreate, NameIdFormat format)
 {
     AllowCreate = allowCreate;
     Format = format;
 }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Path != null)
         {
             hashCode = hashCode * 59 + Path.GetHashCode();
         }
         if (ServiceRanking != null)
         {
             hashCode = hashCode * 59 + ServiceRanking.GetHashCode();
         }
         if (IdpUrl != null)
         {
             hashCode = hashCode * 59 + IdpUrl.GetHashCode();
         }
         if (IdpCertAlias != null)
         {
             hashCode = hashCode * 59 + IdpCertAlias.GetHashCode();
         }
         if (IdpHttpRedirect != null)
         {
             hashCode = hashCode * 59 + IdpHttpRedirect.GetHashCode();
         }
         if (ServiceProviderEntityId != null)
         {
             hashCode = hashCode * 59 + ServiceProviderEntityId.GetHashCode();
         }
         if (AssertionConsumerServiceURL != null)
         {
             hashCode = hashCode * 59 + AssertionConsumerServiceURL.GetHashCode();
         }
         if (SpPrivateKeyAlias != null)
         {
             hashCode = hashCode * 59 + SpPrivateKeyAlias.GetHashCode();
         }
         if (KeyStorePassword != null)
         {
             hashCode = hashCode * 59 + KeyStorePassword.GetHashCode();
         }
         if (DefaultRedirectUrl != null)
         {
             hashCode = hashCode * 59 + DefaultRedirectUrl.GetHashCode();
         }
         if (UserIDAttribute != null)
         {
             hashCode = hashCode * 59 + UserIDAttribute.GetHashCode();
         }
         if (UseEncryption != null)
         {
             hashCode = hashCode * 59 + UseEncryption.GetHashCode();
         }
         if (CreateUser != null)
         {
             hashCode = hashCode * 59 + CreateUser.GetHashCode();
         }
         if (AddGroupMemberships != null)
         {
             hashCode = hashCode * 59 + AddGroupMemberships.GetHashCode();
         }
         if (GroupMembershipAttribute != null)
         {
             hashCode = hashCode * 59 + GroupMembershipAttribute.GetHashCode();
         }
         if (DefaultGroups != null)
         {
             hashCode = hashCode * 59 + DefaultGroups.GetHashCode();
         }
         if (NameIdFormat != null)
         {
             hashCode = hashCode * 59 + NameIdFormat.GetHashCode();
         }
         if (SynchronizeAttributes != null)
         {
             hashCode = hashCode * 59 + SynchronizeAttributes.GetHashCode();
         }
         if (HandleLogout != null)
         {
             hashCode = hashCode * 59 + HandleLogout.GetHashCode();
         }
         if (LogoutUrl != null)
         {
             hashCode = hashCode * 59 + LogoutUrl.GetHashCode();
         }
         if (ClockTolerance != null)
         {
             hashCode = hashCode * 59 + ClockTolerance.GetHashCode();
         }
         if (DigestMethod != null)
         {
             hashCode = hashCode * 59 + DigestMethod.GetHashCode();
         }
         if (SignatureMethod != null)
         {
             hashCode = hashCode * 59 + SignatureMethod.GetHashCode();
         }
         if (UserIntermediatePath != null)
         {
             hashCode = hashCode * 59 + UserIntermediatePath.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if SamlConfigurationProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of SamlConfigurationProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SamlConfigurationProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                     ) &&
                 (
                     ServiceRanking == other.ServiceRanking ||
                     ServiceRanking != null &&
                     ServiceRanking.Equals(other.ServiceRanking)
                 ) &&
                 (
                     IdpUrl == other.IdpUrl ||
                     IdpUrl != null &&
                     IdpUrl.Equals(other.IdpUrl)
                 ) &&
                 (
                     IdpCertAlias == other.IdpCertAlias ||
                     IdpCertAlias != null &&
                     IdpCertAlias.Equals(other.IdpCertAlias)
                 ) &&
                 (
                     IdpHttpRedirect == other.IdpHttpRedirect ||
                     IdpHttpRedirect != null &&
                     IdpHttpRedirect.Equals(other.IdpHttpRedirect)
                 ) &&
                 (
                     ServiceProviderEntityId == other.ServiceProviderEntityId ||
                     ServiceProviderEntityId != null &&
                     ServiceProviderEntityId.Equals(other.ServiceProviderEntityId)
                 ) &&
                 (
                     AssertionConsumerServiceURL == other.AssertionConsumerServiceURL ||
                     AssertionConsumerServiceURL != null &&
                     AssertionConsumerServiceURL.Equals(other.AssertionConsumerServiceURL)
                 ) &&
                 (
                     SpPrivateKeyAlias == other.SpPrivateKeyAlias ||
                     SpPrivateKeyAlias != null &&
                     SpPrivateKeyAlias.Equals(other.SpPrivateKeyAlias)
                 ) &&
                 (
                     KeyStorePassword == other.KeyStorePassword ||
                     KeyStorePassword != null &&
                     KeyStorePassword.Equals(other.KeyStorePassword)
                 ) &&
                 (
                     DefaultRedirectUrl == other.DefaultRedirectUrl ||
                     DefaultRedirectUrl != null &&
                     DefaultRedirectUrl.Equals(other.DefaultRedirectUrl)
                 ) &&
                 (
                     UserIDAttribute == other.UserIDAttribute ||
                     UserIDAttribute != null &&
                     UserIDAttribute.Equals(other.UserIDAttribute)
                 ) &&
                 (
                     UseEncryption == other.UseEncryption ||
                     UseEncryption != null &&
                     UseEncryption.Equals(other.UseEncryption)
                 ) &&
                 (
                     CreateUser == other.CreateUser ||
                     CreateUser != null &&
                     CreateUser.Equals(other.CreateUser)
                 ) &&
                 (
                     AddGroupMemberships == other.AddGroupMemberships ||
                     AddGroupMemberships != null &&
                     AddGroupMemberships.Equals(other.AddGroupMemberships)
                 ) &&
                 (
                     GroupMembershipAttribute == other.GroupMembershipAttribute ||
                     GroupMembershipAttribute != null &&
                     GroupMembershipAttribute.Equals(other.GroupMembershipAttribute)
                 ) &&
                 (
                     DefaultGroups == other.DefaultGroups ||
                     DefaultGroups != null &&
                     DefaultGroups.Equals(other.DefaultGroups)
                 ) &&
                 (
                     NameIdFormat == other.NameIdFormat ||
                     NameIdFormat != null &&
                     NameIdFormat.Equals(other.NameIdFormat)
                 ) &&
                 (
                     SynchronizeAttributes == other.SynchronizeAttributes ||
                     SynchronizeAttributes != null &&
                     SynchronizeAttributes.Equals(other.SynchronizeAttributes)
                 ) &&
                 (
                     HandleLogout == other.HandleLogout ||
                     HandleLogout != null &&
                     HandleLogout.Equals(other.HandleLogout)
                 ) &&
                 (
                     LogoutUrl == other.LogoutUrl ||
                     LogoutUrl != null &&
                     LogoutUrl.Equals(other.LogoutUrl)
                 ) &&
                 (
                     ClockTolerance == other.ClockTolerance ||
                     ClockTolerance != null &&
                     ClockTolerance.Equals(other.ClockTolerance)
                 ) &&
                 (
                     DigestMethod == other.DigestMethod ||
                     DigestMethod != null &&
                     DigestMethod.Equals(other.DigestMethod)
                 ) &&
                 (
                     SignatureMethod == other.SignatureMethod ||
                     SignatureMethod != null &&
                     SignatureMethod.Equals(other.SignatureMethod)
                 ) &&
                 (
                     UserIntermediatePath == other.UserIntermediatePath ||
                     UserIntermediatePath != null &&
                     UserIntermediatePath.Equals(other.UserIntermediatePath)
                 ));
        }