/// <summary> /// Initializes a new instance of the <see cref="XacmlRule"/> class. /// </summary> /// <param name="ruleId">The rule identifier.</param> /// <param name="effect">The rule effect.</param> public XacmlRule(string ruleId, XacmlEffectType effect) { if (ruleId == null) { throw new ArgumentNullException(nameof(ruleId)); } this.ruleId = ruleId; this.Effect = effect; }
public XacmlAdviceExpression(Uri obligationId, XacmlEffectType effectType) { if (obligationId == null) { throw new ArgumentNullException(nameof(obligationId)); } this.adviceId = obligationId; this.appliesTo = effectType; }
public XacmlObligationExpression(Uri obligationId, XacmlEffectType effectType) { if (obligationId == null) { throw new ArgumentNullException(nameof(obligationId)); } this.obligationId = obligationId; this.fulfillOn = effectType; }
/// <summary> /// Initializes a new instance of the <see cref="XacmlObligation"/> class. /// </summary> /// <param name="obligationId">The obligation identifier.</param> /// <param name="fulfillOn">The fulfill on.</param> /// <param name="attributeAssigments">The attribute assigments.</param> /// <remarks> /// Used only for XACML 1.0/1.1/2.0 /// </remarks> public XacmlObligation(Uri obligationId, XacmlEffectType fulfillOn, IEnumerable<XacmlAttributeAssignment> attributeAssigments) { Contract.Requires<ArgumentNullException>(obligationId != null); Contract.Requires<ArgumentException>(Contract.ForAll<XacmlAttributeAssignment>(attributeAssigments, x => x != null)); this.obligationId = obligationId; this.FulfillOn = fulfillOn; foreach (var item in attributeAssigments) { this.attributeAssignment.Add(item); } }
/// <summary> /// Initializes a new instance of the <see cref="XacmlObligation"/> class. /// </summary> /// <param name="obligationId">Obligation identifier.The value of the obligation identifier SHALL be interpreted by the PEP.</param> /// <param name="fulfillOn">The action to fulfillon.</param> /// <param name="attributeAssigments"> list Obligation arguments assignment.The values of the obligation arguments SHALL be interpreted by the PEP.</param> public XacmlObligation(Uri obligationId, XacmlEffectType fulfillOn, IEnumerable <XacmlAttributeAssignment> attributeAssigments) { Guard.ArgumentNotNull(obligationId, nameof(obligationId)); this.obligationId = obligationId; this.FulfillOn = fulfillOn; foreach (var item in attributeAssigments) { if (item == null) { throw new ArgumentException("Enumeration cannot contains null values.", nameof(attributeAssigments)); } this.attributeAssignment.Add(item); } }
/// <summary> /// Reads the obligation. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> /// <exception cref="System.Xml.XmlException">Obligation NotStartElement</exception> /// <exception cref="XacmlSerializationException">Wrong XacmlEffectType value</exception> protected virtual XacmlObligation ReadObligation(XmlReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (!reader.IsStartElement(XacmlConstants.ElementNames.Obligation, this.Version.NamespacePolicy)) { throw ThrowHelperXml(reader, "Obligation NotStartElement"); } Uri gaObligationId = this.ReadAttribute <Uri>(reader, XacmlConstants.AttributeNames.ObligationId); string gaFulFillOn = this.ReadAttribute <string>(reader, XacmlConstants.AttributeNames.FulfillOn); XacmlEffectType effectType = XacmlEffectType.Deny; if (string.Equals(gaFulFillOn, "Deny", StringComparison.OrdinalIgnoreCase)) { effectType = XacmlEffectType.Deny; } else if (string.Equals(gaFulFillOn, "Permit", StringComparison.OrdinalIgnoreCase)) { effectType = XacmlEffectType.Permit; } else { throw ThrowHelperXml(reader, "Wrong XacmlEffectType value"); } reader.ReadStartElement(XacmlConstants.ElementNames.Obligation, this.Version.NamespacePolicy); List <XacmlAttributeAssignment> assigments = new List <XacmlAttributeAssignment>(); this.ReadList(assigments, XacmlConstants.ElementNames.AttributeAssignment, this.Version.NamespacePolicy, this.ReadAttributeAssigment, reader, isRequired: true); reader.ReadEndElement(); return(new XacmlObligation(gaObligationId, effectType, assigments)); }
public XacmlObligationExpression(Uri obligationId, XacmlEffectType effectType) { Contract.Requires<ArgumentNullException>(obligationId != null); this.obligationId = obligationId; this.fulfillOn = effectType; }
/// <summary> /// Initializes a new instance of the <see cref="XacmlObligationExpression"/> class. /// </summary> /// <param name="obligationId">Obligation identifier.The value of the obligation identifier SHALL be interpreted by the PEP.</param> /// <param name="effectType">The effecttype</param> public XacmlObligationExpression(Uri obligationId, XacmlEffectType effectType) { Guard.ArgumentNotNull(obligationId, nameof(obligationId)); this.obligationId = obligationId; this.fulfillOn = effectType; }
/// <summary> /// Initializes a new instance of the <see cref="XacmlObligation"/> class. /// </summary> /// <param name="fulfillOn">The fulfill on.</param> /// <param name="attributeAssigments">The attribute assigments.</param> /// <remarks> /// Used only for XACML 1.0/1.1/2.0 /// </remarks> public XacmlObligation(XacmlEffectType fulfillOn, IEnumerable<XacmlAttributeAssignment> attributeAssigments) : this(XacmlUtils.GenerateObligationId(), fulfillOn, attributeAssigments) { }
public XacmlAdviceExpression(Uri obligationId, XacmlEffectType effectType) { Contract.Requires<ArgumentNullException>(obligationId != null); this.adviceId = obligationId; this.appliesTo = effectType; }
/// <summary> /// Initializes a new instance of the <see cref="XacmlRule"/> class. /// </summary> /// <param name="ruleId">The rule identifier.</param> /// <param name="effect">The rule effect.</param> public XacmlRule(string ruleId, XacmlEffectType effect) { Contract.Requires<ArgumentNullException>(ruleId != null); this.ruleId = ruleId; this.Effect = effect; }
/// <summary> /// Initializes a new instance of the <see cref="XacmlObligation"/> class. /// </summary> /// <param name="fulfillOn">The fulfill on.</param> /// <param name="attributeAssigments">The attribute assigments.</param> /// <remarks> /// Used only for XACML 1.0/1.1/2.0 /// </remarks> public XacmlObligation(XacmlEffectType fulfillOn, IEnumerable <XacmlAttributeAssignment> attributeAssigments) : this(XacmlUtils.GenerateObligationId(), fulfillOn, attributeAssigments) { }
/// <summary> /// Initializes a new instance of the <see cref="XacmlRule"/> class. /// </summary> /// <param name="effect">The rule effect.</param> public XacmlRule(XacmlEffectType effect) : this(XacmlUtils.GenerateRuleId(), effect) { }
/// <summary> /// Reads the rule. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> /// <exception cref="System.Xml.XmlException"> /// Rule NotStartElement /// or /// RuleId IsNullOrEmpty /// or /// Effect IsNullEmpty /// </exception> /// <exception cref="XacmlSerializationException">Wrong XacmlEffectType value</exception> protected virtual XacmlRule ReadRule(XmlReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (!reader.IsStartElement(XacmlConstants.ElementNames.Rule, this.Version.NamespacePolicy)) { throw ThrowHelperXml(reader, "Rule NotStartElement"); } var gaRuleId = reader.GetAttribute("RuleId"); if (string.IsNullOrEmpty(gaRuleId)) { throw ThrowHelperXml(reader, "RuleId IsNullOrEmpty"); } var gaEffect = reader.GetAttribute("Effect"); if (string.IsNullOrEmpty(gaEffect)) { throw ThrowHelperXml(reader, "Effect IsNullEmpty"); } XacmlEffectType effectType = XacmlEffectType.Deny; if (string.Equals(gaEffect, "Deny", StringComparison.OrdinalIgnoreCase)) { effectType = XacmlEffectType.Deny; } else if (string.Equals(gaEffect, "Permit", StringComparison.OrdinalIgnoreCase)) { effectType = XacmlEffectType.Permit; } else { throw ThrowHelperXml(reader, "Wrong XacmlEffectType value"); } reader.ReadStartElement(XacmlConstants.ElementNames.Rule, this.Version.NamespacePolicy); string description = null; if (reader.IsStartElement(XacmlConstants.ElementNames.Description, this.Version.NamespacePolicy)) { description = reader.ReadElementContentAsString(XacmlConstants.ElementNames.Description, this.Version.NamespacePolicy); } XacmlTarget target = null; if (reader.IsStartElement(XacmlConstants.ElementNames.Target, this.Version.NamespacePolicy)) { target = this.ReadTarget(reader); } XacmlExpression condition = null; if (reader.IsStartElement(XacmlConstants.ElementNames.Condition, this.Version.NamespacePolicy)) { condition = this.ReadCondition(reader); } reader.ReadEndElement(); return(new XacmlRule(gaRuleId, effectType) { Description = description, Target = target, Condition = condition }); }
/// <summary> /// Initializes a new instance of the <see cref="XacmlAdviceExpression"/> class. /// </summary> /// <param name="adviceId">Advice identifier.The value of the advice identifier MAY be interpreted by the PEP.</param> /// <param name="appliesTo">The effect for which this advice must be provided to the PEP.</param> public XacmlAdviceExpression(Uri adviceId, XacmlEffectType appliesTo) { Guard.ArgumentNotNull(adviceId, nameof(adviceId)); this.adviceId = adviceId; this.appliesTo = appliesTo; }
/// <summary> /// Initializes a new instance of the <see cref="XacmlRule"/> class. /// </summary> /// <param name="ruleId">The rule identifier.</param> /// <param name="effect">The rule effect.</param> public XacmlRule(string ruleId, XacmlEffectType effect) { Guard.ArgumentNotNull(ruleId, nameof(ruleId)); this.ruleId = ruleId; this.Effect = effect; }