コード例 #1
0
ファイル: ResultElement.cs プロジェクト: OsvaldoJ/XACML.NET
        /// <summary>
        /// Creates a Result using an XmlReader instance provided.
        /// </summary>
        /// <param name="reader">The XmlReader positioned at the Result node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public ResultElement(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Context, schemaVersion)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName == ContextSchema.ResultElement.Result)
            {
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                    case ContextSchema.ResultElement.Decision:
                        // The parsing should be safe because the document was validated using a Xsd Shcema
                        _decision = (rtm.Decision)Enum.Parse(typeof(rtm.Decision), reader.ReadElementString(), false);
                        break;

                    case ContextSchema.StatusElement.Status:
                        _status = new StatusElement(reader, schemaVersion);
                        break;

                    case ObligationsElement.Obligations:
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case ObligationElement.Obligation:
                                _obligations.Add(new pol.ObligationElement(reader, schemaVersion));
                                break;
                            }
                            // Trick to support multiple nodes of the same name.
                            if (reader.LocalName == ObligationsElement.Obligations &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }

                        break;
                    }
                    if (reader.LocalName == ContextSchema.ResultElement.Result &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
            }
        }
コード例 #2
0
ファイル: ResultElement.cs プロジェクト: OsvaldoJ/XACML.NET
        /// <summary>
        /// Creates a new Result using the provided information.
        /// </summary>
        /// <param name="resourceId">The resource id for this result.</param>
        /// <param name="decision">The decission of the evaluation.</param>
        /// <param name="status">The status with information about the execution.</param>
        /// <param name="obligations">The list of obligations</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public ResultElement(string resourceId, rtm.Decision decision, StatusElement status, pol.ObligationCollection obligations, XacmlVersion schemaVersion)
            : base(XacmlSchema.Context, schemaVersion)
        {
            _resourceId = resourceId;
            _decision   = decision;

            // If the status is null, create an empty status
            if (status == null)
            {
                _status = new StatusElement(null, null, null, schemaVersion);
            }
            else
            {
                _status = status;
            }

            // If the obligations are null, leave the empty ObligationCollection.
            if (obligations != null)
            {
                _obligations = obligations;
            }
        }
コード例 #3
0
ファイル: ResultElement.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// Creates a new Result using the provided information.
		/// </summary>
		/// <param name="resourceId">The resource id for this result.</param>
		/// <param name="decision">The decission of the evaluation.</param>
		/// <param name="status">The status with information about the execution.</param>
		/// <param name="obligations">The list of obligations</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public ResultElement( string resourceId, rtm.Decision decision, StatusElement status, pol.ObligationCollection obligations, XacmlVersion schemaVersion )
			: base( XacmlSchema.Context, schemaVersion )
		{
			_resourceId = resourceId;
			_decision = decision;

			// If the status is null, create an empty status
			if( status == null )
			{
				_status = new StatusElement( null, null, null, schemaVersion );
			}
			else
			{
				_status = status;
			}

			// If the obligations are null, leave the empty ObligationCollection.
			if( obligations != null )
			{
				_obligations = obligations;
			}
		}
コード例 #4
0
ファイル: ResultElement.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// Creates a Result using an XmlReader instance provided.
		/// </summary>
		/// <param name="reader">The XmlReader positioned at the Result node.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public ResultElement( XmlReader reader, XacmlVersion schemaVersion )
			: base( XacmlSchema.Context, schemaVersion )
		{
            if (reader == null) throw new ArgumentNullException("reader");
			if( reader.LocalName == ContextSchema.ResultElement.Result )
			{
				while( reader.Read() )
				{
					switch( reader.LocalName )
					{
						case ContextSchema.ResultElement.Decision:
							// The parsing should be safe because the document was validated using a Xsd Shcema
							_decision = (rtm.Decision)Enum.Parse( typeof(rtm.Decision), reader.ReadElementString(), false );
							break;
						case ContextSchema.StatusElement.Status:
							_status = new StatusElement( reader, schemaVersion );
							break;
						case ObligationsElement.Obligations:
							while( reader.Read() )
							{
								switch( reader.LocalName )
								{
									case ObligationElement.Obligation:
										_obligations.Add( new pol.ObligationElement( reader, schemaVersion ) );
										break;
								}
								// Trick to support multiple nodes of the same name.
								if( reader.LocalName == ObligationsElement.Obligations && 
									reader.NodeType == XmlNodeType.EndElement )
								{
									reader.Read();
									break;
								}		
							}
							
							break;
					}
					if( reader.LocalName == ContextSchema.ResultElement.Result && 
						reader.NodeType == XmlNodeType.EndElement )
					{
						break;
					}
				}
			}
			else
			{
				throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
			}
		}