Example #1
0
        public override bool Equals(object obj)
        {
            var other = obj as ClientModel;

            if (other == null)
            {
                return(false);
            }

            var result =
                AbsoluteRefreshTokenLifetime.SafeEquals(other.AbsoluteRefreshTokenLifetime) &&
                AccessTokenLifetime.SafeEquals(other.AccessTokenLifetime) &&
                AccessTokenType.SafeEquals(other.AccessTokenType) &&
                AllowAccessTokensViaBrowser.SafeEquals(other.AllowAccessTokensViaBrowser) &&
                AllowedCorsOrigins.SafeListEquals(other.AllowedCorsOrigins) &&
                AllowedGrantTypes.SafeListEquals(other.AllowedGrantTypes) &&
                AllowedScopes.SafeListEquals(other.AllowedScopes) &&
                AllowOfflineAccess.SafeEquals(other.AllowOfflineAccess) &&
                AllowPlainTextPkce.SafeEquals(other.AllowPlainTextPkce) &&
                AllowRememberConsent.SafeEquals(other.AllowRememberConsent) &&
                AlwaysSendClientClaims.SafeEquals(other.AlwaysSendClientClaims) &&
                AuthorizationCodeLifetime.SafeEquals(other.AuthorizationCodeLifetime) &&
                BackChannelLogoutSessionRequired.SafeEquals(other.BackChannelLogoutSessionRequired) &&
                BackChannelLogoutUri.SafeEquals(other.BackChannelLogoutUri) &&
                Claims.SafeListEquals(other.Claims) &&
                ClientId.SafeEquals(other.ClientId) &&
                ClientName.SafeEquals(other.ClientName) &&
                ClientSecrets.SafeListEquals(other.ClientSecrets) &&
                ClientUri.SafeEquals(other.ClientUri) &&
                ConsentLifetime.SafeEquals(other.ConsentLifetime) &&
                Enabled.SafeEquals(other.Enabled) &&
                EnableLocalLogin.SafeEquals(other.EnableLocalLogin) &&
                FrontChannelLogoutSessionRequired.SafeEquals(other.FrontChannelLogoutSessionRequired) &&
                FrontChannelLogoutUri.SafeEquals(other.FrontChannelLogoutUri) &&
                IdentityProviderRestrictions.SafeListEquals(other.IdentityProviderRestrictions) &&
                IdentityTokenLifetime.SafeEquals(other.IdentityTokenLifetime) &&
                IncludeJwtId.SafeEquals(other.IncludeJwtId) &&
                LogoUri.SafeEquals(other.LogoUri) &&
                LogoutSessionRequired.SafeEquals(other.LogoutSessionRequired) &&
                LogoutUri.SafeEquals(other.LogoutUri) &&
                PostLogoutRedirectUris.SafeListEquals(other.PostLogoutRedirectUris) &&
                Properties.SafeEquals(other.Properties) &&
                ProtocolType.SafeEquals(other.ProtocolType) &&
                RedirectUris.SafeListEquals(other.RedirectUris) &&
                RefreshTokenExpiration.SafeEquals(other.RefreshTokenExpiration) &&
                RefreshTokenUsage.SafeEquals(other.RefreshTokenUsage) &&
                RequireClientSecret.SafeEquals(other.RequireClientSecret) &&
                RequireConsent.SafeEquals(other.RequireConsent) &&
                RequirePkce.SafeEquals(other.RequirePkce) &&
                SlidingRefreshTokenLifetime.SafeEquals(other.SlidingRefreshTokenLifetime) &&
                UpdateAccessTokenClaimsOnRefresh.SafeEquals(other.UpdateAccessTokenClaimsOnRefresh);

            return(result);
        }
Example #2
0
        public override void Valid()
        {
            var l = new List <string>();

            if (string.IsNullOrEmpty(Authority))
            {
                l.Add(nameof(Authority));
            }
            if (string.IsNullOrEmpty(ClientId))
            {
                l.Add(nameof(ClientId));
            }
            if (l.Count > 0)
            {
                throw new InvalidParamException("Missing: " + string.Join(',', l));
            }

            try
            {
                if (!string.IsNullOrWhiteSpace(ClientUri))
                {
                    ClientUri = ClientUri.ValidAbsoluteUri();
                }
                if (!string.IsNullOrWhiteSpace(LogoUri))
                {
                    LogoUri = LogoUri.ValidAbsoluteUri();
                }

                if (!string.IsNullOrEmpty(GrantTypesToAdd))
                {
                    GrantTypesToAdd.ValidGrants(true);
                }
                if (!string.IsNullOrEmpty(GrantTypesToRemove))
                {
                    GrantTypesToRemove.ValidGrants(true);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidParamException(ex);
            }
        }
Example #3
0
 /// <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 (DataCustodianId != null)
         {
             hashCode = hashCode * 59 + DataCustodianId.GetHashCode();
         }
         if (DataCustodianApplicationStatus != null)
         {
             hashCode = hashCode * 59 + DataCustodianApplicationStatus.GetHashCode();
         }
         if (ThirdPartyApplicationDescription != null)
         {
             hashCode = hashCode * 59 + ThirdPartyApplicationDescription.GetHashCode();
         }
         if (ThirdPartyApplicationStatus != null)
         {
             hashCode = hashCode * 59 + ThirdPartyApplicationStatus.GetHashCode();
         }
         if (ThirdPartyApplicationType != null)
         {
             hashCode = hashCode * 59 + ThirdPartyApplicationType.GetHashCode();
         }
         if (ThirdPartyApplicationUse != null)
         {
             hashCode = hashCode * 59 + ThirdPartyApplicationUse.GetHashCode();
         }
         if (ThirdPartyPhone != null)
         {
             hashCode = hashCode * 59 + ThirdPartyPhone.GetHashCode();
         }
         if (AuthorizationServerUri != null)
         {
             hashCode = hashCode * 59 + AuthorizationServerUri.GetHashCode();
         }
         if (ThirdPartyNotifyUri != null)
         {
             hashCode = hashCode * 59 + ThirdPartyNotifyUri.GetHashCode();
         }
         if (AuthorizationServerAuthorizationEndpoint != null)
         {
             hashCode = hashCode * 59 + AuthorizationServerAuthorizationEndpoint.GetHashCode();
         }
         if (AuthorizationServerRegistrationEndpoint != null)
         {
             hashCode = hashCode * 59 + AuthorizationServerRegistrationEndpoint.GetHashCode();
         }
         if (AuthorizationServerTokenEndpoint != null)
         {
             hashCode = hashCode * 59 + AuthorizationServerTokenEndpoint.GetHashCode();
         }
         if (DataCustodianBulkRequestURI != null)
         {
             hashCode = hashCode * 59 + DataCustodianBulkRequestURI.GetHashCode();
         }
         if (DataCustodianResourceEndpoint != null)
         {
             hashCode = hashCode * 59 + DataCustodianResourceEndpoint.GetHashCode();
         }
         if (ThirdPartyScopeSelectionURI != null)
         {
             hashCode = hashCode * 59 + ThirdPartyScopeSelectionURI.GetHashCode();
         }
         if (ThirdPartyUserPortalScreenURI != null)
         {
             hashCode = hashCode * 59 + ThirdPartyUserPortalScreenURI.GetHashCode();
         }
         if (ClientSecret != null)
         {
             hashCode = hashCode * 59 + ClientSecret.GetHashCode();
         }
         if (LogoUri != null)
         {
             hashCode = hashCode * 59 + LogoUri.GetHashCode();
         }
         if (ClientName != null)
         {
             hashCode = hashCode * 59 + ClientName.GetHashCode();
         }
         if (ClientUri != null)
         {
             hashCode = hashCode * 59 + ClientUri.GetHashCode();
         }
         if (RedirectUri != null)
         {
             hashCode = hashCode * 59 + RedirectUri.GetHashCode();
         }
         if (ClientId != null)
         {
             hashCode = hashCode * 59 + ClientId.GetHashCode();
         }
         if (TosUri != null)
         {
             hashCode = hashCode * 59 + TosUri.GetHashCode();
         }
         if (PolicyUri != null)
         {
             hashCode = hashCode * 59 + PolicyUri.GetHashCode();
         }
         if (SoftwareId != null)
         {
             hashCode = hashCode * 59 + SoftwareId.GetHashCode();
         }
         if (SoftwareVersion != null)
         {
             hashCode = hashCode * 59 + SoftwareVersion.GetHashCode();
         }
         if (ClientIdIssuedAt != null)
         {
             hashCode = hashCode * 59 + ClientIdIssuedAt.GetHashCode();
         }
         if (ClientSecretExpiresAt != null)
         {
             hashCode = hashCode * 59 + ClientSecretExpiresAt.GetHashCode();
         }
         if (Contacts != null)
         {
             hashCode = hashCode * 59 + Contacts.GetHashCode();
         }
         if (TokenEndpointAuthMethod != null)
         {
             hashCode = hashCode * 59 + TokenEndpointAuthMethod.GetHashCode();
         }
         if (Scope != null)
         {
             hashCode = hashCode * 59 + Scope.GetHashCode();
         }
         if (GrantTypes != null)
         {
             hashCode = hashCode * 59 + GrantTypes.GetHashCode();
         }
         if (ResponseTypes != null)
         {
             hashCode = hashCode * 59 + ResponseTypes.GetHashCode();
         }
         if (RegistrationClientUri != null)
         {
             hashCode = hashCode * 59 + RegistrationClientUri.GetHashCode();
         }
         if (RegistrationAccessToken != null)
         {
             hashCode = hashCode * 59 + RegistrationAccessToken.GetHashCode();
         }
         if (DataCustodianScopeSelectionScreenURI != null)
         {
             hashCode = hashCode * 59 + DataCustodianScopeSelectionScreenURI.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #4
0
        /// <summary>
        /// Returns true if ApplicationInformation instances are equal
        /// </summary>
        /// <param name="other">Instance of ApplicationInformation to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ApplicationInformation other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     DataCustodianId == other.DataCustodianId ||
                     DataCustodianId != null &&
                     DataCustodianId.Equals(other.DataCustodianId)
                     ) &&
                 (
                     DataCustodianApplicationStatus == other.DataCustodianApplicationStatus ||
                     DataCustodianApplicationStatus != null &&
                     DataCustodianApplicationStatus.Equals(other.DataCustodianApplicationStatus)
                 ) &&
                 (
                     ThirdPartyApplicationDescription == other.ThirdPartyApplicationDescription ||
                     ThirdPartyApplicationDescription != null &&
                     ThirdPartyApplicationDescription.Equals(other.ThirdPartyApplicationDescription)
                 ) &&
                 (
                     ThirdPartyApplicationStatus == other.ThirdPartyApplicationStatus ||
                     ThirdPartyApplicationStatus != null &&
                     ThirdPartyApplicationStatus.Equals(other.ThirdPartyApplicationStatus)
                 ) &&
                 (
                     ThirdPartyApplicationType == other.ThirdPartyApplicationType ||
                     ThirdPartyApplicationType != null &&
                     ThirdPartyApplicationType.Equals(other.ThirdPartyApplicationType)
                 ) &&
                 (
                     ThirdPartyApplicationUse == other.ThirdPartyApplicationUse ||
                     ThirdPartyApplicationUse != null &&
                     ThirdPartyApplicationUse.Equals(other.ThirdPartyApplicationUse)
                 ) &&
                 (
                     ThirdPartyPhone == other.ThirdPartyPhone ||
                     ThirdPartyPhone != null &&
                     ThirdPartyPhone.Equals(other.ThirdPartyPhone)
                 ) &&
                 (
                     AuthorizationServerUri == other.AuthorizationServerUri ||
                     AuthorizationServerUri != null &&
                     AuthorizationServerUri.Equals(other.AuthorizationServerUri)
                 ) &&
                 (
                     ThirdPartyNotifyUri == other.ThirdPartyNotifyUri ||
                     ThirdPartyNotifyUri != null &&
                     ThirdPartyNotifyUri.Equals(other.ThirdPartyNotifyUri)
                 ) &&
                 (
                     AuthorizationServerAuthorizationEndpoint == other.AuthorizationServerAuthorizationEndpoint ||
                     AuthorizationServerAuthorizationEndpoint != null &&
                     AuthorizationServerAuthorizationEndpoint.Equals(other.AuthorizationServerAuthorizationEndpoint)
                 ) &&
                 (
                     AuthorizationServerRegistrationEndpoint == other.AuthorizationServerRegistrationEndpoint ||
                     AuthorizationServerRegistrationEndpoint != null &&
                     AuthorizationServerRegistrationEndpoint.Equals(other.AuthorizationServerRegistrationEndpoint)
                 ) &&
                 (
                     AuthorizationServerTokenEndpoint == other.AuthorizationServerTokenEndpoint ||
                     AuthorizationServerTokenEndpoint != null &&
                     AuthorizationServerTokenEndpoint.Equals(other.AuthorizationServerTokenEndpoint)
                 ) &&
                 (
                     DataCustodianBulkRequestURI == other.DataCustodianBulkRequestURI ||
                     DataCustodianBulkRequestURI != null &&
                     DataCustodianBulkRequestURI.Equals(other.DataCustodianBulkRequestURI)
                 ) &&
                 (
                     DataCustodianResourceEndpoint == other.DataCustodianResourceEndpoint ||
                     DataCustodianResourceEndpoint != null &&
                     DataCustodianResourceEndpoint.Equals(other.DataCustodianResourceEndpoint)
                 ) &&
                 (
                     ThirdPartyScopeSelectionURI == other.ThirdPartyScopeSelectionURI ||
                     ThirdPartyScopeSelectionURI != null &&
                     ThirdPartyScopeSelectionURI.Equals(other.ThirdPartyScopeSelectionURI)
                 ) &&
                 (
                     ThirdPartyUserPortalScreenURI == other.ThirdPartyUserPortalScreenURI ||
                     ThirdPartyUserPortalScreenURI != null &&
                     ThirdPartyUserPortalScreenURI.Equals(other.ThirdPartyUserPortalScreenURI)
                 ) &&
                 (
                     ClientSecret == other.ClientSecret ||
                     ClientSecret != null &&
                     ClientSecret.Equals(other.ClientSecret)
                 ) &&
                 (
                     LogoUri == other.LogoUri ||
                     LogoUri != null &&
                     LogoUri.Equals(other.LogoUri)
                 ) &&
                 (
                     ClientName == other.ClientName ||
                     ClientName != null &&
                     ClientName.Equals(other.ClientName)
                 ) &&
                 (
                     ClientUri == other.ClientUri ||
                     ClientUri != null &&
                     ClientUri.Equals(other.ClientUri)
                 ) &&
                 (
                     RedirectUri == other.RedirectUri ||
                     RedirectUri != null &&
                     RedirectUri.SequenceEqual(other.RedirectUri)
                 ) &&
                 (
                     ClientId == other.ClientId ||
                     ClientId != null &&
                     ClientId.Equals(other.ClientId)
                 ) &&
                 (
                     TosUri == other.TosUri ||
                     TosUri != null &&
                     TosUri.Equals(other.TosUri)
                 ) &&
                 (
                     PolicyUri == other.PolicyUri ||
                     PolicyUri != null &&
                     PolicyUri.Equals(other.PolicyUri)
                 ) &&
                 (
                     SoftwareId == other.SoftwareId ||
                     SoftwareId != null &&
                     SoftwareId.Equals(other.SoftwareId)
                 ) &&
                 (
                     SoftwareVersion == other.SoftwareVersion ||
                     SoftwareVersion != null &&
                     SoftwareVersion.Equals(other.SoftwareVersion)
                 ) &&
                 (
                     ClientIdIssuedAt == other.ClientIdIssuedAt ||
                     ClientIdIssuedAt != null &&
                     ClientIdIssuedAt.Equals(other.ClientIdIssuedAt)
                 ) &&
                 (
                     ClientSecretExpiresAt == other.ClientSecretExpiresAt ||
                     ClientSecretExpiresAt != null &&
                     ClientSecretExpiresAt.Equals(other.ClientSecretExpiresAt)
                 ) &&
                 (
                     Contacts == other.Contacts ||
                     Contacts != null &&
                     Contacts.SequenceEqual(other.Contacts)
                 ) &&
                 (
                     TokenEndpointAuthMethod == other.TokenEndpointAuthMethod ||
                     TokenEndpointAuthMethod != null &&
                     TokenEndpointAuthMethod.Equals(other.TokenEndpointAuthMethod)
                 ) &&
                 (
                     Scope == other.Scope ||
                     Scope != null &&
                     Scope.SequenceEqual(other.Scope)
                 ) &&
                 (
                     GrantTypes == other.GrantTypes ||
                     GrantTypes != null &&
                     GrantTypes.SequenceEqual(other.GrantTypes)
                 ) &&
                 (
                     ResponseTypes == other.ResponseTypes ||
                     ResponseTypes != null &&
                     ResponseTypes.Equals(other.ResponseTypes)
                 ) &&
                 (
                     RegistrationClientUri == other.RegistrationClientUri ||
                     RegistrationClientUri != null &&
                     RegistrationClientUri.Equals(other.RegistrationClientUri)
                 ) &&
                 (
                     RegistrationAccessToken == other.RegistrationAccessToken ||
                     RegistrationAccessToken != null &&
                     RegistrationAccessToken.Equals(other.RegistrationAccessToken)
                 ) &&
                 (
                     DataCustodianScopeSelectionScreenURI == other.DataCustodianScopeSelectionScreenURI ||
                     DataCustodianScopeSelectionScreenURI != null &&
                     DataCustodianScopeSelectionScreenURI.Equals(other.DataCustodianScopeSelectionScreenURI)
                 ));
        }
        /// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
        /// <param name="isNew">是否插入</param>
        public override void Valid(Boolean isNew)
        {
            // 如果没有脏数据,则不需要进行任何处理
            if (!HasDirty)
            {
                return;
            }

            // 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框
            if (ClientId.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(ClientId), "ClientId不能为空!");
            }
            if (ProtocolType.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(ProtocolType), "ProtocolType不能为空!");
            }
            if (ClientName.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(ClientName), "ClientName不能为空!");
            }
            if (Description.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Description), "Description不能为空!");
            }
            if (ClientUri.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(ClientUri), "ClientUri不能为空!");
            }
            if (LogoUri.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(LogoUri), "LogoUri不能为空!");
            }
            if (FrontChannelLogoutUri.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(FrontChannelLogoutUri), "FrontChannelLogoutUri不能为空!");
            }
            if (BackChannelLogoutUri.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(BackChannelLogoutUri), "BackChannelLogoutUri不能为空!");
            }
            if (ClientClaimsPrefix.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(ClientClaimsPrefix), "ClientClaimsPrefix不能为空!");
            }
            if (PairWiseSubjectSalt.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(PairWiseSubjectSalt), "PairWiseSubjectSalt不能为空!");
            }
            if (Created.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Created), "Created不能为空!");
            }
            if (Updated.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Updated), "Updated不能为空!");
            }
            if (LastAccessed.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(LastAccessed), "LastAccessed不能为空!");
            }
            if (UserCodeType.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(UserCodeType), "UserCodeType不能为空!");
            }

            // 在新插入数据或者修改了指定字段时进行修正

            // 检查唯一索引
            // CheckExist(isNew, __.ClientId);
        }