/// <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."); } }
public List <Claim> GetClaimType(AccessTypeEnum Permission) { List <Claim> claims = new List <Claim>(); switch (Permission) { case AccessTypeEnum.Administration: claims.Add(new Claim("Administration", "true")); claims.Add(new Claim("DatabaseAdministration", "true")); claims.Add(new Claim("ReportsAdministration", "true")); claims.Add(new Claim("Read", "true")); break; case AccessTypeEnum.DatabaseAdministration: claims.Add(new Claim("DatabaseAdministration", "true")); claims.Add(new Claim("Read", "true")); break; case AccessTypeEnum.ReportsAdministration: claims.Add(new Claim("ReportsAdministration", "true")); claims.Add(new Claim("Read", "true")); break; case AccessTypeEnum.Read: claims.Add(new Claim("Read", "true")); break; } return(claims); }
/// <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) { PolicyValidator 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."); } }
/// <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."); } }
/// <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."); } }
public static bool HasAccess(string pocoNamespace, AccessTypeEnum accessTypeEnum, int userId) { int accessType = (int)accessTypeEnum; const string sql = "SELECT * FROM policy.has_access(@0, @1, @2);"; //Todo return(true); }
protected override void MapEntityToCustomProperties(IENTBaseEntity entity) { ENTCapability capability = (ENTCapability)entity; ID = capability.ENTCapabilityId; CapabilityName = capability.CapabilityName; MenuItemId = capability.ENTMenuItemId; AccessType = (AccessTypeEnum)capability.AccessType; }
/// <summary> /// Initializes a new instance of the <see cref="OnDemandPromotion" /> class. /// </summary> /// <param name="accessType">The type of access that the promotion grants. Option descriptions: * `default` - The promotion grants discounts on existing product offerings. * `vip` - The promotion grants free access to On Demand content before it is released or to access types that aren't part of the existing product offerings. (required).</param> /// <param name="discountType">The type of discount that the promotion provides. Option descriptions: * `dollars` - The promotion discounts a fixed amount from the full purchase price. * `free` - The promotion discounts the full purchase price. When **access_type** is `vip`, **discount_type** is always `free`. * `percent` - The promotion discounts a percentage of the full purchase price. (required).</param> /// <param name="download">Whether the promotion grants download access to On Demand content. (required).</param> /// <param name="label">The prefix string for batch codes, or the null value for single codes. (required).</param> /// <param name="metadata">metadata (required).</param> /// <param name="percentOff">When **discount_type** is `percent`, the percentage amount that is deducted from the product price. (required).</param> /// <param name="productType">The type of product to which the promotion can be applied. Only the `buy` and `rent` options are available when **access_type** is `vip`. Option descriptions: * `any` - The promotion can be applied to any product. * `buy` - The promotion can be applied to a buyable single video. * `buy_episode` - The promotion can be applied to a buyable single episode. * `rent` - The promotion can be applied to a rentable single video. * `rent_episode` - The promotion can be applied to a rentable single episode. * `subscribe` - The promotion can be applied to a subscription. (required).</param> /// <param name="streamPeriod">The amount of time that the user has access to the On Demand content after redeeming a promo code. Option descriptions: * `1_week` - Access lasts for one week. * `1_year` - Access lasts for one year. * `24_hour` - Access lasts for 24 hours. * `30_days` - Access lasts for 30 days. * `3_month` - Access lasts for three months. * `48_hour` - Access lasts for 48 hours. * `6_month` - Access lasts for six months. * `72_hour` - Access lasts for 72 hours. (required).</param> /// <param name="total">When **type** is `single`, the total number of times that the promotion can be used. When **type** is `batch` or `batch_prefix`, the total number of promo codes that have been generated. (required).</param> /// <param name="type">The way in which the promotion generates promo codes. Option descriptions: * `batch` - The promotion provides a unique promo code for each user. * `batch_prefix` - Like `batch`, except that all codes have a similar prefix string. This option is deprecated, yet it may still appear for some users. * `single` - The promotion provides a single promo code for all users. (required).</param> /// <param name="uri">The promotion's canonical relative URI. (required).</param> public OnDemandPromotion(AccessTypeEnum accessType = default(AccessTypeEnum), DiscountTypeEnum discountType = default(DiscountTypeEnum), bool download = default(bool), string label = default(string), OnDemandPromotionMetadata metadata = default(OnDemandPromotionMetadata), decimal percentOff = default(decimal), ProductTypeEnum productType = default(ProductTypeEnum), StreamPeriodEnum streamPeriod = default(StreamPeriodEnum), decimal total = default(decimal), TypeEnum type = default(TypeEnum), string uri = default(string)) { this.AccessType = accessType; this.DiscountType = discountType; this.Download = download; // to ensure "label" is required (not null) this.Label = label ?? throw new ArgumentNullException("label is a required property for OnDemandPromotion and cannot be null"); // to ensure "metadata" is required (not null) this.Metadata = metadata ?? throw new ArgumentNullException("metadata is a required property for OnDemandPromotion and cannot be null"); this.PercentOff = percentOff; this.ProductType = productType; this.StreamPeriod = streamPeriod; this.Total = total; this.Type = type; // to ensure "uri" is required (not null) this.Uri = uri ?? throw new ArgumentNullException("uri is a required property for OnDemandPromotion and cannot be null"); }
public AccessPolicyAttribute(string objectNamespace, string objectName, AccessTypeEnum type) { this.ObjectNamespace = objectNamespace; this.ObjectName = objectName; this.Type = type; }