コード例 #1
0
ファイル: EvaluationEngine.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// Resolves the attribute reference defined within the given match.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="match">The target item match.</param>
		/// <param name="contextTargetItem">The context target item.</param>
		/// <returns>The context attribute.</returns>
		public static ctx.AttributeElement Resolve( EvaluationContext context, pol.TargetMatchBaseReadWrite match, ctx.TargetItemBase contextTargetItem )
		{
			ctx.AttributeElementReadWrite attribute = null;
			if( match.AttributeReference is pol.AttributeDesignatorBase )
			{
				pol.AttributeDesignatorBase attrDesig = (pol.AttributeDesignatorBase)match.AttributeReference;
				context.Trace( "Looking for attribute: {0}", attrDesig.AttributeId );
				foreach( ctx.AttributeElementReadWrite tempAttribute in contextTargetItem.Attributes )
				{
					if( tempAttribute.Match( attrDesig ) )
					{
						attribute = tempAttribute;
						break;
					}
				}

				if( attribute == null )
				{
					context.Trace( "Attribute not found, loading searching an external repository" );
					attribute = GetAttribute( context, attrDesig );
				}
			}
			else if( match.AttributeReference is pol.AttributeSelectorElement )
			{
				pol.AttributeSelectorElement attrSelec = (pol.AttributeSelectorElement)match.AttributeReference;
				ctx.ResourceContentElement content = (ctx.ResourceContentElement)((ctx.ResourceElement)contextTargetItem).ResourceContent;
				if( content != null )
				{
					XmlDocument doc = context.ContextDocument.XmlDocument;
					
					if( context.ContextDocument.XmlNamespaceManager == null )
					{
						context.ContextDocument.AddNamespaces( context.PolicyDocument.Namespaces );
					}
					
					string xpath = attrSelec.RequestContextPath;
					try
					{
						XmlNode node = doc.DocumentElement.SelectSingleNode( xpath, context.ContextDocument.XmlNamespaceManager );
						if( node != null )
						{
							attribute = new ctx.AttributeElement( null, attrSelec.DataType, null, null, node.InnerText, attrSelec.SchemaVersion );
						}
					}
					catch( XPathException e )
					{
						context.Trace( Resource.TRACE_ERROR, e.Message ); 
						context.ProcessingError = true;
					}
				}
			}
			
			if( attribute == null && match.AttributeReference.MustBePresent )
			{
				context.IsMissingAttribute = true;
				context.AddMissingAttribute( match.AttributeReference );
			}

			if( attribute != null )
			{
				return new ctx.AttributeElement( attribute.AttributeId, attribute.DataType, attribute.Issuer, attribute.IssueInstant, 
					attribute.Value, attribute.SchemaVersion);
			}
			return null;
		}
コード例 #2
0
ファイル: AttributeElement.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// Clones an Attribute from another attribute.
		/// </summary>
		/// <param name="attributeElement">The attribute id.</param>
		public AttributeElement( AttributeElement attributeElement )
			: base( attributeElement )
		{
		}