Exemplo n.º 1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            if (Claims?.Where(c => c == "*").Count() > 1)
            {
                results.Add(new ValidationResult($"Only one wildcard (*) is allowed in the field {nameof(Claims)}.", new[] { nameof(Claims) }));
            }

            if (AuthnResponseBinding == null)
            {
                results.Add(new ValidationResult($"The {nameof(AuthnResponseBinding)} field is required.", new[] { nameof(AuthnResponseBinding) }));
            }

            if (UpdateState == PartyUpdateStates.Manual)
            {
                if (Issuer.IsNullOrEmpty())
                {
                    results.Add(new ValidationResult($"The {nameof(Issuer)} field is required.", new[] { nameof(Issuer) }));
                }
                if (AuthnUrl.IsNullOrEmpty())
                {
                    results.Add(new ValidationResult($"The {nameof(AuthnUrl)} field is required.", new[] { nameof(AuthnUrl) }));
                }
                if (AuthnRequestBinding == null)
                {
                    results.Add(new ValidationResult($"The {nameof(AuthnRequestBinding)} field is required.", new[] { nameof(AuthnRequestBinding) }));
                }
                if (!LogoutUrl.IsNullOrWhiteSpace())
                {
                    if (LogoutRequestBinding == null)
                    {
                        results.Add(new ValidationResult($"The {nameof(LogoutRequestBinding)} field is required.", new[] { nameof(LogoutRequestBinding) }));
                    }
                    if (LogoutResponseBinding == null)
                    {
                        results.Add(new ValidationResult($"The {nameof(LogoutResponseBinding)} field is required.", new[] { nameof(LogoutResponseBinding) }));
                    }
                }
                if (Keys?.Count < Constants.Models.SamlParty.Up.KeysMin)
                {
                    results.Add(new ValidationResult($"The field {nameof(Keys)} must be at least {Constants.Models.SamlParty.Up.KeysMin}.", new[] { nameof(Keys) }));
                }
            }
            else
            {
                if (!MetadataUpdateRate.HasValue)
                {
                    results.Add(new ValidationResult($"The {nameof(MetadataUpdateRate)} field is required.", new[] { nameof(MetadataUpdateRate) }));
                }
                if (MetadataUrl.IsNullOrEmpty())
                {
                    results.Add(new ValidationResult($"The {nameof(MetadataUrl)} field is required.", new[] { nameof(MetadataUrl) }));
                }
            }
            return(results);
        }
Exemplo n.º 2
0
 private bool Valid()
 {
     return(!LoginUrl.NullOrEmpty() &&
            !LogoutUrl.NullOrEmpty() &&
            !LoginReturnUrlParameter.NullOrEmpty());
 }
 /// <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)
                 ));
        }