示例#1
0
        /// <summary>
        ///     Validates application user access rights to execute the function.
        /// </summary>
        /// <param name="type">The access type being validated.</param>
        /// <param name="loginId">The login ID of application user making the request.</param>
        /// <param name="catalog">The name of the database on which policy is being validated on.</param>
        /// <param name="noException">
        ///     If this is switched off, UnauthorizedException is not thrown even when the caller does not
        ///     have access rights to this function.
        /// </param>
        public void Validate(AccessTypeEnum type, long loginId, string catalog, bool noException)
        {
            var policy = new PolicyValidator
            {
                ObjectNamespace = this._ObjectNamespace,
                ObjectName = this._ObjectName,
                LoginId = loginId,
                Catalog = catalog,
                AccessType = type
            };

            policy.Validate();
            this.HasAccess = policy.HasAccess;

            this.Validated = true;

            if (this.HasAccess)
            {
                return;
            }

            if (!noException)
            {
                throw new UnauthorizedException("Access is denied.");
            }
        }
示例#2
0
        /// <summary>
        ///     Validates application user access rights to execute the function.
        /// </summary>
        /// <param name="type">The access type being validated.</param>
        /// <param name="loginId">The login ID of application user making the request.</param>
        /// <param name="database">The name of the database on which policy is being validated on.</param>
        /// <param name="noException">
        ///     If this is switched off, UnauthorizedException is not thrown even when the caller does not
        ///     have access rights to this function.
        /// </param>
        public async Task ValidateAsync(AccessTypeEnum type, long loginId, string database, bool noException)
        {
            var policy = new PolicyValidator
            {
                ObjectNamespace = this._ObjectNamespace,
                ObjectName      = this._ObjectName,
                LoginId         = loginId,
                Database        = database,
                AccessType      = type
            };

            await policy.ValidateAsync().ConfigureAwait(false);

            this.HasAccess = policy.HasAccess;

            this.Validated = true;


            if (this.HasAccess)
            {
                return;
            }

            if (!noException)
            {
                throw new UnauthorizedException("Access is denied.");
            }
        }
示例#3
0
        /// <summary>
        ///     Validates application user access rights to execute the function.
        /// </summary>
        /// <param name="type">The access type being validated.</param>
        /// <param name="loginId">The login ID of application user making the request.</param>
        /// <param name="catalog">The name of the database on which policy is being validated on.</param>
        /// <param name="noException">
        ///     If this is switched off, UnauthorizedException is not thrown even when the caller does not
        ///     have access rights to this function.
        /// </param>
        public void Validate(AccessTypeEnum type, long loginId, string catalog, bool noException)
        {
            var policy = new PolicyValidator
            {
                ObjectNamespace = _ObjectNamespace,
                ObjectName      = _ObjectName,
                LoginId         = loginId,
                Catalog         = catalog,
                AccessType      = type
            };

            policy.Validate();
            HasAccess = policy.HasAccess;

            Validated = true;


            if (HasAccess)
            {
                return;
            }

            if (!noException)
            {
                throw new UnauthorizedException("Access is denied.");
            }
        }
示例#4
0
文件: DbAccess.cs 项目: frapid/frapid
        /// <summary>
        ///     Validates application user access rights to execute the function.
        /// </summary>
        /// <param name="type">The access type being validated.</param>
        /// <param name="loginId">The login ID of application user making the request.</param>
        /// <param name="database">The name of the database on which policy is being validated on.</param>
        /// <param name="noException">
        ///     If this is switched off, UnauthorizedException is not thrown even when the caller does not
        ///     have access rights to this function.
        /// </param>
        public async Task ValidateAsync(AccessTypeEnum type, long loginId, string database, bool noException)
        {
            var policy = new PolicyValidator
                         {
                             ObjectNamespace = this._ObjectNamespace,
                             ObjectName = this._ObjectName,
                             LoginId = loginId,
                             Database = database,
                             AccessType = type
                         };

            await policy.ValidateAsync().ConfigureAwait(false);
            this.HasAccess = policy.HasAccess;

            this.Validated = true;


            if(this.HasAccess)
            {
                return;
            }

            if(!noException)
            {
                throw new UnauthorizedException("Access is denied.");
            }
        }