Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Sustainsys.​Saml2.​XmlHelpers

Assembly: Sustainsys.Saml2

Inheritance: object → XmlHelpers

Extension methods and helpers for XmlDocument/XmlElement etc.

Methods

public static void
Sign​(System.​Xml.​XmlDocument xmlDocument, System.​Security.​Cryptography.​X509Certificates.​X509Certificate2 cert)
Sign an xml document with the supplied cert.
xmlDocument XmlDocument to be signed. The signature is added as a node in the document, right after the Issuer node.
cert Certificate to use when signing.
XmlDocumentFromString​(string source)
Creates an Xml document with secure settings and initialized it from a string.
Returns Xml document
source Source string to load
CreateSafeXmlDocument​()
Create an Xml Document with secure settings, specifically disabling xml external entities. Also set PreserveWhiteSpace = true
Returns Xml Document
public static void
Remove​(System.​Xml.​XmlAttributeCollection attributes, string attributeName)
Remove the attribute with the given name from the collection.
attributes Attribute collection.
attributeName Name of attribute to remove.
public static void
RemoveChild​(System.​Xml.​XmlElement xmlElement, string name, string ns)
Remove the child xml element with the specified name.
xmlElement Parent
name Name of child
ns Namespace of child
public static void
Sign​(System.​Xml.​XmlDocument xmlDocument, System.​Security.​Cryptography.​X509Certificates.​X509Certificate2 cert, bool includeKeyInfo)
Sign an xml document with the supplied cert.
xmlDocument XmlDocument to be signed. The signature is added as a node in the document, right after the Issuer node.
cert Certificate to use when signing.
includeKeyInfo Include public key in signed output.
public static void
Sign​(System.​Xml.​XmlDocument xmlDocument, System.​Security.​Cryptography.​X509Certificates.​X509Certificate2 cert, bool includeKeyInfo, string signingAlgorithm)
Sign an xml document with the supplied cert.
xmlDocument XmlDocument to be signed. The signature is added as a node in the document, right after the Issuer node.
cert Certificate to use when signing.
includeKeyInfo Include public key in signed output.
signingAlgorithm Uri of signing algorithm to use.
public static void
Sign​(System.​Xml.​XmlElement xmlElement, System.​Security.​Cryptography.​X509Certificates.​X509Certificate2 cert, bool includeKeyInfo)
Sign an xml element with the supplied cert.
xmlElement xmlElement to be signed. The signature is added as a node in the document, right after the Issuer node.
cert Certificate to use when signing.
includeKeyInfo Include public key in signed output.
public static void
Sign​(System.​Xml.​XmlElement xmlElement, System.​Security.​Cryptography.​X509Certificates.​X509Certificate2 cert, bool includeKeyInfo, string signingAlgorithm)
Sign an xml element with the supplied cert.
xmlElement xmlElement to be signed. The signature is added as a node in the document, right after the Issuer node.
cert Certificate to use when signing.
includeKeyInfo Include public key in signed output.
signingAlgorithm The signing algorithm to use.
public static bool
IsSignedByAny​(System.​Xml.​XmlElement xmlElement, System.​Collections.​Generic.​IEnumerable<​SecurityKeyIdentifierClause> signingKeys, bool validateCertificate, string minimumSigningAlgorithm)
Checks if an xml element is signed by the given certificate, through a contained enveloped signature.
Returns True on correct signature, false on missing signature
xmlElement Xml Element that should be signed
signingKeys Signing keys to test, one should validate.
validateCertificate Should the certificate be validated too?
minimumSigningAlgorithm The mininum signing algorithm strength allowed.
public static void
ValidateSignatureMethodStrength​(string minIncomingSignatureAlgorithm, string signatureMethod)
Check if the signature method is at least as strong as the mininum one.
public static string
PrettyPrint​(System.​Xml.​XmlElement xml)
Pretty an xml element.
Returns Nicely indented and readable data.
xml Xml to pretty print.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object