Microsoft.IdentityModel.Xml
Defines a XML transform that applies C14n canonicalization and produces a hash over the transformed XML nodes.
Gets the algorithm
Gets or sets a value indicating if this transform should include comments.
Gets or sets the a PrefixList to use when there is a need to include InclusiveNamespaces writing token.
Processes a set of XML nodes and returns the hash of the octets.
the that has the XML nodes to process.
the to use
the hash of the processed XML nodes.
Wraps a delegates to InnerReader.
Creates a new .
Gets or sets the Inner .
Gets the value of the InnerReaders's attribute with the specified index.
index of the attribute.
Attribute value at the specified index.
Gets the value of the InnerReaders's attribute with the specified Name.
The qualified name of the attribute.
The value of the specified attribute. If the attribute is not found,
null is returned.
Gets the value of the InnerReaders's attribute with the specified LocalName and NamespaceURI.
The local name of the attribute.
The namespace URI of the attribute.
The value of the specified attribute. If the attribute is not found,
null is returned.
Gets the number of InnerReaders's attributes at the current reader position.
Gets the InnerReaders's base Uri of the current node.
Gets a value indicating if the InnerReader can read binary content
Gets a value indicating if the InnerReader can read value chunk.
Gets the InnerReaders's current depth.
Gets a value indicating if the InnerReader is positioned at the end of the stream.
Gets a value indicating if the InnerReader current node has a Value.
Gets a value indicating if the InnerReader's current node is an attribute that
was generated from the default value defined in the DTD or Schema.
Gets a value indicating if the InnerReader's current node is empty.
Gets the InnerReader's LineNumber
If the InnerReader does not support 1 is returned.
Gets the InnerReader's LinePosition.
If the InnerReader does not support 1 is returned.
Gets the InnerReader's LocalName of the current node.
Gets the InnerReader's Name of the current node.
Gets the InnerReader's NamespaceURI of the current node.
Gets the InnerReader's XmlNameTable at the current node.
Gets the type of the InnerReader's current node type.
Gets the prefix of the InnerReader's current node.
Gets the quotation mark character used to enclose the attribute node. (" or ')
Gets the InnerReader's ReadState.
Gets the Value of the InnerReader's current node.
Gets the ValueType of InnerReader's current node.
Gets the InnerReader's XmlLang.
Gets the InnerReader's XmlSpace.
Closes the reader and changes the System.Xml.XmlReader.ReadState
to Closed.
Gets the value of the InnerReader's attribute at the given index.
The index of the attribute. The index is 0 based index.
The value of the attribute at the specified index.
The method does not move the reader position.
Gets the value of the InnerReader's attribute with the given name.
The qualified name of the attribute.
The value of the attribute. If the attribute is not found null
is returned.
The method does not move the reader position.
Gets the value of the InnerReader's attribute with the given name and namespace Uri.
The local name of the attribute.
The namespace of the attribute.
The value of the attribute. If the attribute is not found
null is returned.
The method does not move the reader.
Gets a value indicating if the InnerReader HasLineInfo
Resolves the InnerReader's namespace prefix in the current element scope.
Prefix whose namespace Uri to be resolved.
The namespace Uri to which the prefix matches or null if no matching
prefix is found.
Moves to the InnerReader's attribute with the specified index.
The index of the attribute.
Moves to the InnerReader's attribute with the given local name.
The qualified name of the attribute.
true if the attribute is found; otherwise, false.
Moves to the InnerReader's attribute with the specified LocalName and NamespaceURI.
The local name of the attribute.
The namespace URI of the attribute.
true if the attribute is found; otherwise, false.
Moves the InnerReader to a node of type Element.
true if the reader is positioned on an element else false
Moves the InnerReader to the first attribute.
Returns true if the reader is positioned at a attribute else false.
When returning false the reader position will not be changed.
Moves the InnerReader to the next attribute.
Returns true if the reader is positioned at an attribute else false.
When returning false the reader position will not be changed.
Reads the InnerReader's next node from the stream.
true if the next node was read successfully.
Parses the InnerReader's attribute value into one or more Text, EntityReference, or EndEntity nodes.
true if there are nodes to return.false if the reader is not positioned on
an attribute node when the initial call is made or if all the attribute values
have been read.
Reads the InnerReader's content and returns the Base64 decoded binary bytes.
The buffer into which to copy the resulting text. This value cannot be null.
The offset into the buffer where to start copying the result.
The maximum number of bytes to copy into the buffer.
The number of bytes written to the buffer.
Reads the InnerReader's content and returns the BinHex decoded binary bytes.
The buffer into which to copy the resulting text. This value cannot be null.
The offset into the buffer where to start copying the result.
The maximum number of bytes to copy into the buffer.
The number of bytes written to the buffer.
Resolves the InnerReader's EntityReference nodes.
Reads large streams of text embedded in an XML document from the InnerReader.
The array of characters that serves as the buffer to which the text contents
are written. This value cannot be null.
The offset within the buffer where the System.Xml.XmlReader can start to
copy the results.
The maximum number of characters to copy into the buffer. The actual number
of characters copied is returned from this method.
The number of characters read into the buffer. The value zero is returned
when there is no more text content.
Gets the
if is null.
Wraps a and delegates to InnerWriter.
Initializes a new instance of
Gets or sets a for tracing.
if 'value' is null.
Gets or sets the InnerWriter.
if 'value' is null.
Closes the underlying stream.
Flushes the underlying stream.
Encodes the specified binary bytes as Base64 and writes out the resulting text.
Byte array to encode.
The position in the buffer indicating the start of the bytes to write.
The number of bytes to write.
Writes out a CDATA block containing the specified text.
The text to place inside the CDATA block.
Forces the generation of a character entity for the specified Unicode character value.
The Unicode character for which to generate a character entity.
When overridden in a derived class, writes text one buffer at a time.
Character array containing the text to write.
The position in the buffer indicating the start of the text to write.
The number of characters to write.
Writes out a comment containing the specified text.
Text to place inside the comment.
Writes the DOCTYPE declaration with the specified name and optional attributes.
The name of the DOCTYPE. This must be non-empty.
If non-null it also writes PUBLIC "pubid" "sysid" where pubid and sysid are
replaced with the value of the given arguments.
If pubid is null and sysid is non-null it writes SYSTEM "sysid" where sysid
is replaced with the value of this argument.
If non-null it writes [subset] where subset is replaced with the value of
this argument.
Closes the previous System.Xml.XmlWriter.WriteStartAttribute(System.String,System.String) call.
Closes any open elements or attributes and puts the writer back in the Start state.
Closes one element and pops the corresponding namespace scope.
Writes out an entity reference as name.
The name of the entity reference.
Closes one element and pops the corresponding namespace scope.
Writes out a processing instruction with a space between the name and text as follows: <?name text?>.
The name of the processing instruction.
The text to include in the processing instruction.
When overridden in a derived class, writes raw markup manually from a character buffer.
Character array containing the text to write.
The position within the buffer indicating the start of the text to write.
The number of characters to write.
Writes raw markup manually from a string.
String containing the text to write.
Writes the start of an attribute with the specified local name and namespace URI.
The namespace prefix of the attribute.
The local name of the attribute.
The namespace URI for the attribute.
When overridden in a derived class, writes the XML declaration with the version "1.0".
When overridden in a derived class, writes the XML declaration with the version
"1.0" and the standalone attribute.
If true, it writes "standalone=yes"; if false, it writes "standalone=no".
When overridden in a derived class, writes the specified start tag and associates
it with the given namespace and prefix.
The namespace prefix of the element.
The local name of the element.
The namespace URI to associate with the element.
When overridden in a derived class, gets the state of the writer.
Writes the given text content.
The text to write.
Generates and writes the surrogate character entity for the surrogate character pair.
The low surrogate. This must be a value between 0xDC00 and 0xDFFF.
The high surrogate. This must be a value between 0xD800 and 0xDBFF.
Writes out the given white space.
The string of white space characters.
Writes an attribute as a xml attribute with the prefix 'xml:'.
Localname of the attribute.
Attribute value.
Writes an xmlns namespace declaration.
The prefix of the namespace declaration.
The namespace Uri itself.
Returns the closest prefix defined in the current namespace scope for the namespace URI.
The namespace URI whose prefix to find.
The matching prefix or null if no matching namespace URI is found in the
current scope.
Gets the
if is null.
Base class for a XmlDsig element as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/
Initializes a instance.
Gets or sets the Id.
Gets or sets the prefix associated with the element.
Reads and writes XML associated with XML DSig https://www.w3.org/TR/2001/PR-xmldsig-core-20010820
Returns the default instance.
Static constructor that initializes the default .
Initializes an instance of
Gets or sets the prefix to use when writing the Signature element.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-KeyInfo
pointing positioned on a <KeyInfo> element.
if is null.
if there is a problem reading the XML.
Only handles IssuerSerial, Ski, SubjectName, Certificate. Unsupported types are skipped. Only a X509 data element is supported.
Reads the "X509DataElement" element conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-X509Data.
A positioned on a element.
Reads the "X509IssuerSerial" element conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-X509Data.
A positioned on a element.
Reads the "RSAKeyValue" element conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-RSAKeyValue.
A positioned on a element.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Signature
a positioned on a <Signature> element.
if is null.
if there is a problem reading the XML.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-SignedInfo
a positioned on a <SignedInfo> element.
if is null.
if there is a problem reading the XML.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Reference
a positioned on a <Reference> element.
if is null.
if there is a problem reading the XML.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Transforms
a positioned on a <Transforms> element.
a to attach transforms.
if is null.
if is null.
if there is a problem reading the XML.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-SignatureMethod
a positioned on a <SignatureMethod> element.
if is null.
if there is a problem reading the XML.
A string with the signature method.
Reads XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-CanonicalizationMethod
a positioned on a <CanonicalizationMethod> element.
if is null.
if there is a problem reading the XML.
A string with the canonicalization method.
Writes the contents of a as XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-KeyInfo.
the to use.
the to write.
if is null.
if is null.
if there is a problem writing the XML.
Writes the contents of a as XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Reference.
the to use.
the to write.
Assumes the <DigestValue> has been calculated, no canonicalization or digest calculation is performed.
if is null.
if is null.
if is null or empty.
if is null or empty.
if one of the values in is null or empty.
Writes the contents of a as XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Signature.
the to use.
the to write.
Assumes the <SignatureValue> has been calculated, no canonicalization or signature calculation is performed.
if is null.
if is null.
if is null or empty.
if is null.
if one of the values in is null or empty.
Writes the contents of a as XML conforming to https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-SignedInfo.
the to use.
the to write.
Assumes the <Reference> digest has been calculated, no canonicalization or digest calculation is performed.
if is null.
if is null.
if is null or empty.
if is null.
if .Count > 1.
if is null or empty.
Gets or sets the to use when processing transforms in References
Wraps a pointing to a root element of XML that may contain a signature.
If a Signature element is found, a will be populated and will
have set for future validation.
Initializes an instance of
a pointing to XML that may contain an enveloped signature.
If a <Signature> element is found, the will be set.
if is null.
Gets or sets the to use when reading XmlDSig elements.
if 'value' is null.
Called after the root element has been completely read.
Attaches a to the first Reference for future processing if
a signature was found.
Keeps track of the XML Element count. If a signature is detected it is read.
'true' if the next node was read successfully; 'false' if there are no more nodes.
if more than one signature is found.
if a <Reference> element was not found in the <SignedInfo>.
Gets the that was found inside the XML.
may be null.
Defines a XML transform that removes the XML nodes associated with the Signature.
Creates an EnvelopedSignatureTransform
Gets the Algorithm associated with this transform
Sets the reader to exclude the <Signature> element
to process.
with exclusion set.
Wraps a and generates a signature automatically when the envelope
is written completely. By default the generated signature is inserted as
the last element in the envelope. This can be modified by explicitly
calling WriteSignature to indicate the location inside the envelope where
the signature should be inserted.
Initializes an instance of . The returned writer can be directly used
to write the envelope. The signature will be automatically generated when
the envelope is completed.
Writer to wrap/
SigningCredentials to be used to generate the signature.
The reference Id of the envelope.
if is null.
if is null.
if is null or Empty.
Initializes an instance of . The returned writer can be directly used
to write the envelope. The signature will be automatically generated when
the envelope is completed.
Writer to wrap/
SigningCredentials to be used to generate the signature.
The reference Id of the envelope.
inclusive prefix list to use for exclusive canonicalization.
if is null.
if is null.
if is null or Empty.
Gets or sets the to use.
if value is null.
Calculates and inserts the Signature.
Sets the position of the signature within the envelope. Call this
method while writing the envelope to indicate at which point the
signature should be inserted.
Overrides the base class implementation. When the last element of the envelope is written
the signature is automatically computed over the envelope and the signature is inserted at
the appropriate position, if WriteSignature was explicitly called or is inserted at the
end of the envelope.
Overrides the base class implementation. When the last element of the envelope is written
the signature is automatically computed over the envelope and the signature is inserted at
the appropriate position, if WriteSignature was explicitly called or is inserted at the
end of the envelope.
Overrides the base class. Writes the specified start tag and associates
it with the given namespace.
The namespace prefix of the element.
The local name of the element.
The namespace URI to associate with the element.
Releases the unmanaged resources used by the System.IdentityModel.Protocols.XmlSignature.EnvelopedSignatureWriter and optionally
releases the managed resources.
True to release both managed and unmanaged resources; false to release only unmanaged resources.
Represents an exception thrown when processing xml.
Initializes a new instance of the class.
Initializes a new instance of the class with a specified error message.
The error message that explains the reason for the exception.
Initializes a new instance of the class with a specified error message
and a reference to the inner exception that is the cause of this exception.
The error message that explains the reason for the exception.
The that is the cause of the current exception, or a null reference if no inner exception is specified.
This exception is thrown when a problem occurs reading XML.
Initializes a new instance of the class.
Initializes a new instance of the class.
Addtional information to be included in the exception and displayed to user.
Initializes a new instance of the class.
Addtional information to be included in the exception and displayed to user.
A that represents the root cause of the exception.
This exception is thrown when a problem occurs when validating the XML <Signature>.
Initializes a new instance of the class.
Initializes a new instance of the class with a specified error message.
The error message that explains the reason for the exception.
Initializes a new instance of the class with a specified error message
and a reference to the inner exception that is the cause of this exception.
The error message that explains the reason for the exception.
The that is the cause of the current exception, or a null reference if no inner exception is specified.
This exception is thrown when a problem occurs writing XML.
Initializes a new instance of the class.
Initializes a new instance of the class.
Addtional information to be included in the exception and displayed to user.
Initializes a new instance of the class.
Addtional information to be included in the exception and displayed to user.
A that represents the root cause of the exception.
Represents Canonicalization algorithms found in <SignedInfo> and in <Reference>.
Initializes an instance of .
Initializes an instance of .
controls if the transform will include comments.
Gets the Algorithm associated with this transform
Applies a canonicalization transform over a set of XML nodes and computes the hash value.
the set of XML nodes to transform.
the hash algorithm to apply.
the hash of the transformed octets.
Represents the IssuerSerial property of X509Data as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-X509Data
Gets the IssuerName of the IssuerSerial.
Gets the SerialNumber of the IssuerSerial.
Creates an IssuerSerial using the specified IssuerName and SerialNumber.
Compares two IssuerSerial objects.
Serves as a hash function for IssuerSerial.
Represents a XmlDsig KeyInfo element as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-KeyInfo
Only a single 'X509Certificate' is supported. Multiples that include intermediate and root certs are not supported.
Initializes an instance of .
Initializes an instance of .
the to populate the X509Data.
Initializes an instance of .
the to populate the .
Gets or sets the 'KeyName' that can be used as a key identifier.
Gets or sets the Uri associated with the RetrievalMethod
Gets or sets the RSAKeyValue.
Gets the 'X509Data' value.
Compares two KeyInfo objects.
Serves as a hash function for KeyInfo.
Returns true if the KeyInfo object can be matched with the specified SecurityKey, returns false otherwise.
Log messages and codes for XmlProcessing
Represents a XmlDsig Reference element as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Reference
Initializes an instance of
Initializes an instance of
the to apply.
the to use.
if is null.
if is null.
Gets or sets the CanonicalizingTransform
if 'value' is null.
Gets or sets the DigestMethod to use when creating the hash.
if 'value' is null or empty.
Gets or sets the Base64 encoding of the hashed octets.
if 'value' is null or empty.
Gets or sets the that is associated with the .
if 'value' is null.
Gets the of transforms to apply.
Gets or sets the Type of this Reference.
Gets or sets the Uri of this Reference.
Verifies that the equals the hashed value of the after
have been applied.
supplies the .
if is null.
Writes into a stream and then hashes the bytes.
the set of XML nodes to read.
the hash algorithm to apply.
hash of the octets.
Computes the digest of this reference by applying the transforms over the tokenStream.
the that will supply the .
The digest over the after all transforms have been applied.
if is null.
if is null.
if is not supported.
if .CreateHashAlgorithm returns null.
The RSAKeyValue found inside of the KeyValue element.
The modulus of the RSAKeyValue.
The exponent of the RSAKeyValue.
Creates an RSAKeyValue using the specified modulus and exponent.
Compares two RSAKeyValue objects.
Serves as a hash function for RSAKeyValue.
Represents a XmlDsig Signature element as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-Signature
Initializes a instance.
Initializes a instance.
associated with this Signature.
if if null.
Gets or sets the KeyInfo
Gets or sets the SignatureValue
if 'value' is null or empty.
Gets or sets the .
if 'value' is null.
Verifies the signature over the SignedInfo.
the to use for cryptographic operations.
the to obtain cryptographic operators.
if is null.
if is null.
if null.
if is not supported.
if signature does not validate.
Represents a XmlDsig SignedInfo element as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-SignedInfo
Initializes a instance.
Initializes a instance.
a to include.
if is null.
Gets or sets the CanonicalizationMethod
if 'value' is null.
if 'value' is not one of:
"http://www.w3.org/2001/10/xml-exc-c14n#"
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments"
Gets or sets the Reference.
if 'value' is null.
Gets or sets the SignatureMethod.
if 'value' is null.
Verifies the digest of all .
supplies any required cryptographic operators.
if is null.
Writes the Canonicalized bytes into a stream.
the to receive the bytes.
Defines a XMLTransform
Called to transform a
the to process.
Gets the algorithm
Static constructor that initializes the default .
Gets the default instance of
Determine if the transform is supported.
the name of the transform.
if the transform is supported
Determine if the canonicalizing transform is supported.
the name of the canonicalizing transform.
if the canonicalizing transform is supported
Gets a XML transform that modifies a XmlTokenStream.
the name of the transform.
Gets a XML transform that is capable of Canonicalizing XML and returning bytes.
the name of the transform.
Represents a XmlDsig X509Data element as per: https://www.w3.org/TR/2001/PR-xmldsig-core-20010820/#sec-X509Data
Supports multiple certificates.
Initializes an instance of .
Initializes an instance of .
If 'certificate' is null
Initializes an instance of .
If 'certificates' is null
Gets or sets the 'X509IssuerSerial' that is part of a 'X509Data'.
Gets or sets the 'X509SKI' value that is a part of 'X509Data'.
Get or sets the 'X509SubjectName' value that is a part of 'X509Data'.
Get the collection of X509Certificates that is associated with 'X509Data'.
Get or sets the 'CRL' value that is a part of 'X509Data'.
Compares two X509Data objects.
Serves as a hash function for X509Data.
Constants for XML Signature
Definitions for namespace, attributes and elements as defined in http://www.w3.org/TR/xmldsig-core/
Maintains a collection of XML nodes obtained when reading signed XML.
Initializes a
Adds a XML node to the collection.
if is null.
Adds a XML attribute node to the collection
the XML prefix.
the local name of the attribute.
the namespace of the attribute.
the value of the attribute.
if is null or empty.
Adds a XML element node to the collection
the XML prefix.
the local name of the element.
the namespace of the attribute.
value indicating if the element is empty.
if is null or empty.
Sets the name and namespace of which element to exclude. Normally this is the <Signature> element.
the name of the Element to exclude.
the namespace of the Element to exclude.
if is null or empty.
Writes the XML nodes into the .
the to use.
if is null.
An XmlReader that captures xml as a XmlTokenStream
Initializes a new instance of for creating a .
an to capture the .
if if null.
if .IsStartElement() is false.
Gets the
Delegates to InnerReader, then calls Record()
Utilities for working with XML
Checks if the is pointing to an expected element.
the to check.
the expected element.
if is null.
if is null or empty.
if if not at a StartElement.
if if not at at expected element.
Checks if the is pointing to an expected element.
the to check.
the expected element.
the expected namespace.
if is null.
if is null or empty.
if if not at a StartElement.
if if not at expected element.
Determine if reader is at expected element in one of the listed namespace in namespaceList.
the to check.
the expected element.
the expected namespace list.
if is at expected element.
if is null.
if is null or empty.
Determines if a Qualified names equals a name / namespace pair.
the to compare.
the name to compare.
the namepace to compare.
Hex representation of bytes
Gets the xsi:type as a for the current element.
an pointing at an Element.
if is null.
a if the current element has an XSI type.
If is not on an element OR xsi type is not found, null.
Determines if the has an attribute that is 'nil'
a positioned on an element.
if is null.
true is the attribute value is 'nil'
Normalizes an empty string to 'null'.
null if string is null or empty.
Returns a new with message including the element and attribute.
the missing element.
the missing attribute.
a .
Determines if the prefix on a name maps to a namespace that is in scope the reader.
the in scope.
the qualifiedName to check.
if is null.
if is null.
a with the namespace that was in scope. If the prefix was not in scope, the namespace will be null.
Validates that element the is positioned on has an xsi:type attribute
with a specific name and type.
an positioned on an element.
the expected name of the xsi:type.
the expected namespace of the xsi:type.
if is null.
if is null.
if is null.
if the does require an xsi:type attribute to be present. If the xsi:type is present, it will be validated.
Validates that element the is positioned on has an xsi:type attribute
with a specific name and type.
an positioned on an element.
the expected name of the xsi:type.
the expected namespace of the xsi:type.
controls if the xsi:type must be present.
if is null.
if is null.
if is null.
if xsi:type is not found and required.
if xsi:type is found and did not match expected.
Sends formatted to the Logger.
the format string.
the arguments to use for formating.
a .
Sends formatted to the Logger.
the format string.
the arguments to use for formating.
the inner exception.
a .
Sends formatted to the Logger.
the format string.
the arguments to use for formating.
a .
Sends formatted to the Logger.
the format string.
the arguments to use for formating.
the inner exception.
a .
Sends formatted to the Logger.
the format string.
the arguments to use for formating.
a .
Sends formatted to the Logger.
the format string.
the arguments to use for formating.
the inner exception.
a .