本文整理汇总了C#中XacmlVersion类的典型用法代码示例。如果您正苦于以下问题:C# XacmlVersion类的具体用法?C# XacmlVersion怎么用?C# XacmlVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XacmlVersion类属于命名空间,在下文中一共展示了XacmlVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TargetMatchBaseReadWrite
/// <summary>
/// Creates an instance of a TargetMatchBase with the values specified.
/// </summary>
/// <param name="matchId">The match id</param>
/// <param name="attributeValue">The attribute value instance.</param>
/// <param name="attributeReference">An attribute reference instance.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
protected TargetMatchBaseReadWrite(string matchId, AttributeValueElementReadWrite attributeValue, AttributeReferenceBase attributeReference, XacmlVersion schemaVersion)
: base(XacmlSchema.Policy, schemaVersion)
{
_id = matchId;
_attributeValue = attributeValue;
_attributeReference = attributeReference;
}
示例2: SubjectAttributeDesignatorElement
/// <summary>
/// Creates an instance of the SubjectAttributeDesignator using the provided XmlReader. It also calls the
/// base class constructor specifying the XmlReader.
/// </summary>
/// <param name="reader">The XmlReader positioned at the SubjectAttributeDesignator node.</param>
/// <param name="version">The version of the schema that was used to validate.</param>
public SubjectAttributeDesignatorElement(XmlReader reader, XacmlVersion version)
:
base(reader, version)
{
if (reader == null) throw new ArgumentNullException("reader");
_subjectCategory = reader.GetAttribute(PolicySchema1.SubjectAttributeDesignatorElement.SubjectCategory);
}
示例3: ValidateSchema
/// <summary>
/// 根据给定的版本号验证给定的模式。
/// </summary>
/// <param name="reader">用于读取命名空间</param>
/// <param name="version">用于验证版本号</param>
/// <returns><c>true</c>, 如果命名空间正确</returns>
protected bool ValidateSchema(XmlReader reader, XacmlVersion version)
{
if (reader == null) throw new ArgumentNullException("reader");
switch (_schema)
{
case XacmlSchema.Policy:
switch (version)
{
case XacmlVersion.Version10:
case XacmlVersion.Version11:
return (reader.NamespaceURI == Consts.Schema1.Namespaces.Policy);
case XacmlVersion.Version20:
return (reader.NamespaceURI == Consts.Schema2.Namespaces.Policy);
default:
throw new EvaluationException("意外的版本号" + version);
}
break;
case XacmlSchema.Context:
switch (version)
{
case XacmlVersion.Version10:
case XacmlVersion.Version11:
return (reader.NamespaceURI == Consts.Schema1.Namespaces.Context);
case XacmlVersion.Version20:
return (reader.NamespaceURI == Consts.Schema2.Namespaces.Context);
default:
throw new EvaluationException("意外的版本号" + version);
}
break;
default:
throw new EvaluationException("意外的模式" + _schema);
}
}
示例4: AttributeAssignmentElementReadWrite
/// <summary>
/// Creates an instance of the ReadWriteAttributeAssignment using the provided XmlReader.
/// </summary>
/// <param name="reader">The XmlReader positioned at the AttributeAssignament node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public AttributeAssignmentElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
: base( XacmlSchema.Policy, schemaVersion )
{
if (reader == null) throw new ArgumentNullException("reader");
if( reader.LocalName == PolicySchema1.ObligationElement.AttributeAssignment &&
ValidateSchema( reader, schemaVersion ) )
{
if( reader.HasAttributes )
{
// Load all the attributes
while( reader.MoveToNextAttribute() )
{
if( reader.LocalName == PolicySchema1.AttributeValueElement.DataType )
{
_dataType = reader.GetAttribute( PolicySchema1.AttributeValueElement.DataType );
}
else if( reader.LocalName == PolicySchema1.AttributeAssignmentElement.AttributeId )
{
_attributeId = reader.GetAttribute( PolicySchema1.AttributeAssignmentElement.AttributeId );
}
}
reader.MoveToElement();
}
// Load the node contents
_contents = reader.ReadInnerXml();
}
else
{
throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
}
}
示例5: AttributeValueElementReadWrite
/// <summary>
/// Creates an instance of the AttributeValue class using the XmlReader and the name of the node that
/// defines the AttributeValue.
/// </summary>
/// <param name="reader">The XmlReader positioned at the node AttributeValue.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public AttributeValueElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
: base(XacmlSchema.Policy, schemaVersion)
{
if (reader == null) throw new ArgumentNullException("reader");
if (reader.LocalName == Consts.Schema1.AttributeValueElement.AttributeValue &&
ValidateSchema(reader, schemaVersion))
{
if (reader.HasAttributes)
{
// Load all the attributes
while (reader.MoveToNextAttribute())
{
if (reader.LocalName == Consts.Schema1.AttributeValueElement.DataType)
{
_dataType = reader.GetAttribute(Consts.Schema1.AttributeValueElement.DataType);
}
}
reader.MoveToElement();
}
// Load the node contents
_contents = reader.ReadInnerXml();
}
else
{
throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
}
}
示例6: ResponseElement
/// <summary>
/// Creates a response using the XmlReader instance provided.
/// </summary>
/// <remarks>This method is only provided for testing purposes, because it's easy to run the ConformanceTests
/// comparing the expected response with the response created.</remarks>
/// <param name="reader">The XmlReader positioned at the Response node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public ResponseElement(XmlReader reader, XacmlVersion schemaVersion)
: base(XacmlSchema.Context, schemaVersion)
{
if (reader == null) throw new ArgumentNullException("reader");
_results = new ResultCollection();
if (reader.LocalName == Consts.ContextSchema.ResponseElement.Response)
{
while (reader.Read())
{
switch (reader.LocalName)
{
case Consts.ContextSchema.ResultElement.Result:
_results.Add(new ResultElement(reader, schemaVersion));
break;
}
if (reader.LocalName == Consts.ContextSchema.ResponseElement.Response &&
reader.NodeType == XmlNodeType.EndElement)
{
break;
}
}
}
else
{
throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
}
}
示例7: StatusCodeElement
/// <summary>
/// Creates a StatusCode using an XmlReader instance provided.
/// </summary>
/// <param name="reader">The XmlReader instance positioned at the StatusCode node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public StatusCodeElement( XmlReader reader, XacmlVersion schemaVersion )
: base( XacmlSchema.Context, schemaVersion )
{
if (reader == null) throw new ArgumentNullException("reader");
if( reader.LocalName == ContextSchema.StatusElement.StatusCode )
{
_value = reader.GetAttribute( ContextSchema.StatusElement.Value );
if( !reader.IsEmptyElement )
{
while( reader.Read() )
{
switch( reader.LocalName )
{
case ContextSchema.StatusElement.StatusCode:
_statusCode = new StatusCodeElement( reader, schemaVersion );
break;
}
if( reader.LocalName == ContextSchema.StatusElement.StatusCode &&
reader.NodeType == XmlNodeType.EndElement )
{
break;
}
}
}
}
else
{
throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
}
}
示例8: RequestElementReadWrite
/// <summary>
/// Creates a new Request using the XmlReader instance provided.
/// </summary>
/// <param name="reader">The XmlReader positioned at the Request node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public RequestElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
: base(XacmlSchema.Context, schemaVersion)
{
if (reader == null) throw new ArgumentNullException("reader");
if (reader.LocalName == Consts.ContextSchema.RequestElement.Request)
{
while (reader.Read())
{
switch (reader.LocalName)
{
case Consts.ContextSchema.RequestElement.Subject:
_subjects.Add(new SubjectElementReadWrite(reader, schemaVersion));
break;
case Consts.ContextSchema.RequestElement.Resource:
_resources.Add(new ResourceElementReadWrite(reader, schemaVersion));
break;
case Consts.ContextSchema.RequestElement.Action:
_action = new ActionElementReadWrite(reader, schemaVersion);
break;
case Consts.ContextSchema.RequestElement.Environment:
_environment = new EnvironmentElementReadWrite(reader, schemaVersion);
break;
}
}
}
else
{
throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
}
}
示例9: PolicyElement
/// <summary>
/// Creates a new Policy with the specified arguments.
/// </summary>
/// <param name="id">The policy id.</param>
/// <param name="description">THe policy description.</param>
/// <param name="target">THe policy target.</param>
/// <param name="rules">THe rules for this policy.</param>
/// <param name="ruleCombiningAlgorithm">THe rule combining algorithm.</param>
/// <param name="obligations">The Obligations for this policy.</param>
/// <param name="xpathVersion">The XPath version supported.</param>
/// <param name="combinerParameters">The combiner parameters in this policy.</param>
/// <param name="ruleCombinerParameters">The rule parameters in this policy.</param>
/// <param name="variableDefinitions">The variable definitions of this policy.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public PolicyElement( string id, string description, TargetElementReadWrite target, RuleReadWriteCollection rules,
string ruleCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion, ArrayList combinerParameters,
ArrayList ruleCombinerParameters, IDictionary variableDefinitions, XacmlVersion schemaVersion )
: base( id, description, target, rules, ruleCombiningAlgorithm, obligations, xpathVersion,
combinerParameters, ruleCombinerParameters, variableDefinitions, schemaVersion )
{
}
示例10: PolicyIdReferenceElementReadWrite
/// <summary>
/// Creates a new PolicyIdReference using the XmlReader instance provided.
/// </summary>
/// <param name="reader">The XmlReader positioned at the PolicyIdReference element.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public PolicyIdReferenceElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
: base( XacmlSchema.Policy, schemaVersion )
{
if (reader == null) throw new ArgumentNullException("reader");
if( reader.LocalName == PolicySchema1.PolicyIdReferenceElement.PolicyIdReference &&
ValidateSchema( reader, schemaVersion ) )
{
if( reader.HasAttributes )
{
// Load all the attributes
while( reader.MoveToNextAttribute() )
{
if( reader.LocalName == PolicyReferenceElement.Version )
{
_version = reader.GetAttribute( PolicyReferenceElement.Version );
}
else if( reader.LocalName == PolicyReferenceElement.EarliestVersion )
{
_earliestVersion = reader.GetAttribute( PolicyReferenceElement.EarliestVersion );
}
else if( reader.LocalName == PolicyReferenceElement.LatestVersion )
{
_latestVersion = reader.GetAttribute( PolicyReferenceElement.LatestVersion );
}
}
reader.MoveToElement();
}
_policyIdReference = reader.ReadElementString();
}
else
{
throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
}
}
示例11: AttributeAssignmentElementReadWrite
/// <summary>
/// Creates an instance of the ReadWriteAttributeAssignment using the provided values
/// </summary>
/// <param name="attributeId"></param>
/// <param name="dataType"></param>
/// <param name="contents"></param>
/// <param name="version"></param>
public AttributeAssignmentElementReadWrite(string attributeId, string dataType, string contents, XacmlVersion version) :
base(XacmlSchema.Policy, version)
{
_attributeId = attributeId;
_dataType = dataType;
_contents = contents;
}
示例12: TargetItemsBaseReadWrite
/// <summary>
/// Creates a new TargetItem instance using the specified XmlReader instance provided, and the node names of
/// the "target item list" nodes which are provided by the derived class during construction.
/// </summary>
/// <param name="reader">The XmlReader instance positioned at the "target item list" node.</param>
/// <param name="itemsNodeName">The name of the "target item list" node.</param>
/// <param name="anyItemNodeName">The name of the AnyXxxx node for this "target item list" node.</param>
/// <param name="itemNodeName">The name of the "target item" node that can be defined within this "target
/// item list" node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
protected TargetItemsBaseReadWrite(XmlReader reader, string itemsNodeName, string anyItemNodeName, string itemNodeName, XacmlVersion schemaVersion)
: this(schemaVersion)
{
if (reader == null) throw new ArgumentNullException("reader");
if (reader.LocalName == itemsNodeName && ValidateSchema(reader, schemaVersion))
{
while (reader.Read())
{
if (reader.LocalName == anyItemNodeName && ValidateSchema(reader, schemaVersion))
{
_anyItem = true;
}
else if (reader.LocalName == itemNodeName && ValidateSchema(reader, schemaVersion))
{
_items.Add((TargetItemBaseReadWrite)CreateTargetItem(reader));
}
else if (reader.LocalName == itemsNodeName &&
reader.NodeType == XmlNodeType.EndElement)
{
break;
}
}
}
else
{
throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
}
}
示例13: StatusElement
/// <summary>
/// Creates a Status using the supplied values.
/// </summary>
/// <param name="statusCode">The status code.</param>
/// <param name="statusMessage">The status message.</param>
/// <param name="statusDetail">The status detail.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public StatusElement(StatusCodeElement statusCode, string statusMessage, string statusDetail, XacmlVersion schemaVersion)
: base(XacmlSchema.Context, schemaVersion)
{
StatusCode = statusCode;
_statusMessage = statusMessage;
_statusDetail = statusDetail;
}
示例14: ObligationElementReadWrite
/// <summary>
/// Creates a new instance of the Obligation class using the XmlReader instance provided.
/// </summary>
/// <param name="reader">The XmlReader positioned at the Obligation node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public ObligationElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
: base( XacmlSchema.Policy, schemaVersion )
{
if(reader != null)
{
if( reader.LocalName == PolicySchema1.ObligationElement.Obligation &&
ValidateSchema( reader, schemaVersion ) )
{
_obligationId = reader.GetAttribute( PolicySchema1.ObligationElement.ObligationId );
// Parses the Effect attribute value
_fulfillOn = (Effect)Enum.Parse(
typeof(Effect), reader.GetAttribute( PolicySchema1.ObligationElement.FulfillOn ), false );
// Read all the attribute assignments
while( reader.Read() )
{
switch( reader.LocalName )
{
case PolicySchema1.ObligationElement.AttributeAssignment:
_attributeAssignment.Add( new AttributeAssignmentElementReadWrite( reader, schemaVersion ) );
break;
}
if( reader.LocalName == PolicySchema1.ObligationElement.Obligation &&
reader.NodeType == XmlNodeType.EndElement )
{
break;
}
}
}
}
else
_obligationId = "[TODO]: Add Obligation ID";
}
示例15: TargetItemsBase
/// <summary>
/// Creates a new TargetItem instance using the specified XmlReader instance provided, and the node names of
/// the "target item list" nodes which are provided by the derived class during construction.
/// </summary>
/// <param name="reader">The XmlReader instance positioned at the "target item list" node.</param>
/// <param name="itemsNodeName">The name of the "target item list" node.</param>
/// <param name="anyItemNodeName">The name of the AnyXxxx node for this "target item list" node.</param>
/// <param name="itemNodeName">The name of the "target item" node that can be defined within this "target
/// item list" node.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
protected TargetItemsBase( XmlReader reader, string itemsNodeName, string anyItemNodeName, string itemNodeName, XacmlVersion schemaVersion )
: base( schemaVersion )
{
if (reader == null) throw new ArgumentNullException("reader");
if( reader.LocalName == itemsNodeName && ValidateSchema( reader, schemaVersion ) )
{
while( reader.Read() )
{
if( reader.LocalName == anyItemNodeName && ValidateSchema( reader, schemaVersion ) )
{
base.IsAny = true;
}
else if( reader.LocalName == itemNodeName && ValidateSchema( reader, schemaVersion ) )
{
base.ItemsList.Add( (TargetItemBase)CreateTargetItem( reader ) );
}
else if( reader.LocalName == itemsNodeName &&
reader.NodeType == XmlNodeType.EndElement )
{
break;
}
}
}
else
{
throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
}
}