Add project

Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
This commit is contained in:
2025-08-12 11:21:10 +09:00
parent bbcbe841a7
commit 33ab055b43
546 changed files with 176950 additions and 0 deletions

View File

@ -0,0 +1,62 @@
// AllDataObjectsTimeStampCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class AllDataObjectsTimeStampCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new TimeStamp this[int index]
{
get
{
return (TimeStamp)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public TimeStamp Add(TimeStamp objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public TimeStamp Add()
{
return this.Add(new TimeStamp("AllDataObjectsTimeStamp"));
}
}
}

View File

@ -0,0 +1,222 @@
// CRLIdentifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class includes the issuer (Issuer element), the time when the CRL
/// was issued (IssueTime element) and optionally the number of the CRL
/// (Number element).
/// The Identifier element can be dropped if the CRL could be inferred from
/// other information. Its URI attribute could serve to indicate where the
/// identified CRL is archived.
/// </summary>
public class CRLIdentifier
{
#region Private variables
private string uriAttribute;
private string issuer;
private DateTime issueTime;
private long number;
#endregion
#region Public properties
/// <summary>
/// The optional URI attribute could serve to indicate where the OCSP
/// response identified is archived
/// </summary>
public string UriAttribute
{
get
{
return this.uriAttribute;
}
set
{
this.uriAttribute = value;
}
}
/// <summary>
/// Issuer of the CRL
/// </summary>
public string Issuer
{
get
{
return this.issuer;
}
set
{
this.issuer = value;
}
}
/// <summary>
/// Date of issue of the CRL
/// </summary>
public DateTime IssueTime
{
get
{
return this.issueTime;
}
set
{
this.issueTime = value;
}
}
/// <summary>
/// Optional number of the CRL
/// </summary>
public long Number
{
get
{
return this.number;
}
set
{
this.number = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CRLIdentifier()
{
this.issueTime = DateTime.MinValue;
this.number = long.MinValue; //Impossible value
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.uriAttribute))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.issuer))
{
retVal = true;
}
if (this.issueTime != DateTime.MinValue)
{
retVal = true;
}
if (this.number != long.MinValue)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("URI"))
{
this.uriAttribute = xmlElement.GetAttribute("URI");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:Issuer", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.issuer = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:IssueTime", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.issueTime = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Local);
}
xmlNodeList = xmlElement.SelectNodes("xsd:Number", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.number = long.Parse(xmlNodeList.Item(0).InnerText);
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CRLIdentifier", XadesSignedXml.XadesNamespaceUri);
retVal.SetAttribute("URI", this.uriAttribute);
if (!String.IsNullOrEmpty(this.issuer))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "Issuer", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.issuer;
retVal.AppendChild(bufferXmlElement);
}
if (this.issueTime != DateTime.MinValue)
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "IssueTime", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = Convert.ToString(this.issueTime.ToString("s"));
retVal.AppendChild(bufferXmlElement);
}
if (this.number != long.MinValue)
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "Number", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.number.ToString();
retVal.AppendChild(bufferXmlElement);
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,165 @@
// CRLRef.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains information about a Certificate Revocation List (CRL)
/// </summary>
public class CRLRef
{
#region Private variables
private DigestAlgAndValueType digestAlgAndValue;
private CRLIdentifier crlIdentifier;
#endregion
#region Public properties
/// <summary>
/// The digest of the entire DER encoded
/// </summary>
public DigestAlgAndValueType CertDigest
{
get
{
return this.digestAlgAndValue;
}
set
{
this.digestAlgAndValue = value;
}
}
/// <summary>
/// CRLIdentifier is a set of data including the issuer, the time when
/// the CRL was issued and optionally the number of the CRL.
/// The Identifier element can be dropped if the CRL could be inferred
/// from other information.
/// </summary>
public CRLIdentifier CRLIdentifier
{
get
{
return this.crlIdentifier;
}
set
{
this.crlIdentifier = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CRLRef()
{
this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue");
this.crlIdentifier = new CRLIdentifier();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.digestAlgAndValue != null && this.digestAlgAndValue.HasChanged())
{
retVal = true;
}
if (this.crlIdentifier != null && this.crlIdentifier.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:DigestAlgAndValue", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("DigestAlgAndValue missing");
}
this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue");
this.digestAlgAndValue.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:CRLIdentifier", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
this.crlIdentifier = null;
}
else
{
this.crlIdentifier = new CRLIdentifier();
this.crlIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CRLRef", XadesSignedXml.XadesNamespaceUri);
if (this.digestAlgAndValue != null && this.digestAlgAndValue.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.digestAlgAndValue.GetXml(), true));
}
else
{
throw new CryptographicException("DigestAlgAndValue element missing in CRLRef");
}
if (this.crlIdentifier != null && this.crlIdentifier.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.crlIdentifier.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// CRLRefCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CRLRefCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new CRLRef this[int index]
{
get
{
return (CRLRef)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public CRLRef Add(CRLRef objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public CRLRef Add()
{
return this.Add(new CRLRef());
}
}
}

View File

@ -0,0 +1,146 @@
// CRLRefs.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// Class that contains a collection of CRL references
/// </summary>
public class CRLRefs
{
#region Private variables
private CRLRefCollection crlRefCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of
/// </summary>
public CRLRefCollection CRLRefCollection
{
get
{
return this.crlRefCollection;
}
set
{
this.crlRefCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CRLRefs()
{
this.crlRefCollection = new CRLRefCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.crlRefCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
CRLRef newCRLRef;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.crlRefCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:CRLRef", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCRLRef = new CRLRef();
newCRLRef.LoadXml(iterationXmlElement);
this.crlRefCollection.Add(newCRLRef);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CRLRefs", XadesSignedXml.XadesNamespaceUri);
if (this.crlRefCollection.Count > 0)
{
foreach (CRLRef crlRef in this.crlRefCollection)
{
if (crlRef.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(crlRef.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,33 @@
// CRLValue.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
namespace Microsoft.Xades
{
/// <summary>
/// This class consist of a sequence of at least one Certificate Revocation
/// List. Each EncapsulatedCRLValue will contain the base64 encoding of a
/// DER-encoded X509 CRL.
/// </summary>
public class CRLValue : EncapsulatedPKIData
{
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CRLValue()
{
this.TagName = "EncapsulatedCRLValue";
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// CRLValueCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CRLValueCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new CRLValue this[int index]
{
get
{
return (CRLValue)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public CRLValue Add(CRLValue objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public CRLValue Add()
{
return this.Add(new CRLValue());
}
}
}

View File

@ -0,0 +1,146 @@
// CRLValues.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of CRL values
/// </summary>
public class CRLValues
{
#region Private variables
private CRLValueCollection crlValueCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of CRLValues
/// </summary>
public CRLValueCollection CRLValueCollection
{
get
{
return this.crlValueCollection;
}
set
{
this.crlValueCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CRLValues()
{
this.crlValueCollection = new CRLValueCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.crlValueCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
CRLValue newCRLValue;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.crlValueCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:EncapsulatedCRLValue", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCRLValue = new CRLValue();
newCRLValue.LoadXml(iterationXmlElement);
this.crlValueCollection.Add(newCRLValue);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CRLValues", XadesSignedXml.XadesNamespaceUri);
if (this.crlValueCollection.Count > 0)
{
foreach (CRLValue crlValue in this.crlValueCollection)
{
if (crlValue.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(crlValue.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,162 @@
// Cert.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains certificate identification information
/// </summary>
public class Cert
{
#region Private variables
private DigestAlgAndValueType certDigest;
private IssuerSerial issuerSerial;
#endregion
#region Public properties
/// <summary>
/// The element CertDigest contains the digest of one of the
/// certificates referenced in the sequence
/// </summary>
public DigestAlgAndValueType CertDigest
{
get
{
return this.certDigest;
}
set
{
this.certDigest = value;
}
}
/// <summary>
/// The element IssuerSerial contains the identifier of one of the
/// certificates referenced in the sequence. Should the
/// X509IssuerSerial element appear in the signature to denote the same
/// certificate, its value MUST be consistent with the corresponding
/// IssuerSerial element.
/// </summary>
public IssuerSerial IssuerSerial
{
get
{
return this.issuerSerial;
}
set
{
this.issuerSerial = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public Cert()
{
this.certDigest = new DigestAlgAndValueType("CertDigest");
this.issuerSerial = new IssuerSerial();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.certDigest != null && this.certDigest.HasChanged())
{
retVal = true;
}
if (this.issuerSerial != null && this.issuerSerial.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:CertDigest", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("CertDigest missing");
}
this.certDigest = new DigestAlgAndValueType("CertDigest");
this.certDigest.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:IssuerSerial", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("IssuerSerial missing");
}
this.issuerSerial = new IssuerSerial();
this.issuerSerial.LoadXml((XmlElement)xmlNodeList.Item(0));
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "Cert", XadesSignedXml.XadesNamespaceUri);
if (this.certDigest != null && this.certDigest.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.certDigest.GetXml(), true));
}
if (this.issuerSerial != null && this.issuerSerial.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.issuerSerial.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// CertCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CertCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new Cert this[int index]
{
get
{
return (Cert)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public Cert Add(Cert objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public Cert Add()
{
return this.Add(new Cert());
}
}
}

View File

@ -0,0 +1,146 @@
// CertRefs.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The CertRefs element contains a collection of Cert elements
/// </summary>
public class CertRefs
{
#region Private variables
private CertCollection certCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of Certs
/// </summary>
public CertCollection CertCollection
{
get
{
return this.certCollection;
}
set
{
this.certCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CertRefs()
{
this.certCollection = new CertCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.certCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
Cert newCert;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.certCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:Cert", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCert = new Cert();
newCert.LoadXml(iterationXmlElement);
this.certCollection.Add(newCert);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("CertRefs", XadesSignedXml.XadesNamespaceUri);
if (this.certCollection.Count > 0)
{
foreach (Cert cert in this.certCollection)
{
if (cert.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(cert.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,246 @@
// CertificateValues.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The CertificateValues element contains the full set of certificates
/// that have been used to validate the electronic signature, including the
/// signer's certificate. However, it is not necessary to include one of
/// those certificates into this property, if the certificate is already
/// present in the ds:KeyInfo element of the signature.
/// In fact, both the signer certificate (referenced in the mandatory
/// SigningCertificate property element) and all certificates referenced in
/// the CompleteCertificateRefs property element must be present either in
/// the ds:KeyInfo element of the signature or in the CertificateValues
/// property element.
/// </summary>
public class CertificateValues
{
#region Private variables
private string id;
private EncapsulatedX509CertificateCollection encapsulatedX509CertificateCollection;
private OtherCertificateCollection otherCertificateCollection;
#endregion
#region Public properties
/// <summary>
/// Optional Id of the certificate values element
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// A collection of encapsulated X509 certificates
/// </summary>
public EncapsulatedX509CertificateCollection EncapsulatedX509CertificateCollection
{
get
{
return this.encapsulatedX509CertificateCollection;
}
set
{
this.encapsulatedX509CertificateCollection = value;
}
}
/// <summary>
/// Collection of other certificates
/// </summary>
public OtherCertificateCollection OtherCertificateCollection
{
get
{
return this.otherCertificateCollection;
}
set
{
this.otherCertificateCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CertificateValues()
{
this.encapsulatedX509CertificateCollection = new EncapsulatedX509CertificateCollection();
this.otherCertificateCollection = new OtherCertificateCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.id != null && this.id != "")
{
retVal = true;
}
if (this.encapsulatedX509CertificateCollection.Count > 0)
{
retVal = true;
}
if (this.otherCertificateCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
EncapsulatedX509Certificate newEncapsulatedX509Certificate;
OtherCertificate newOtherCertificate;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xades", XadesSignedXml.XadesNamespaceUri);
this.encapsulatedX509CertificateCollection.Clear();
this.otherCertificateCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xades:EncapsulatedX509Certificate", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newEncapsulatedX509Certificate = new EncapsulatedX509Certificate();
newEncapsulatedX509Certificate.LoadXml(iterationXmlElement);
this.encapsulatedX509CertificateCollection.Add(newEncapsulatedX509Certificate);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
xmlNodeList = xmlElement.SelectNodes("xades:OtherCertificate", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newOtherCertificate = new OtherCertificate();
newOtherCertificate.LoadXml(iterationXmlElement);
this.otherCertificateCollection.Add(newOtherCertificate);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CertificateValues", XadesSignedXml.XadesNamespaceUri);
if (this.id != null && this.id != "")
{
retVal.SetAttribute("Id", this.id);
}
if (this.encapsulatedX509CertificateCollection.Count > 0)
{
foreach (EncapsulatedX509Certificate encapsulatedX509Certificate in this.encapsulatedX509CertificateCollection)
{
if (encapsulatedX509Certificate.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(encapsulatedX509Certificate.GetXml(), true));
}
}
}
if (this.otherCertificateCollection.Count > 0)
{
foreach (OtherCertificate otherCertificate in this.otherCertificateCollection)
{
if (otherCertificate.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(otherCertificate.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,32 @@
// CertifiedRole.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
namespace Microsoft.Xades
{
/// <summary>
/// The CertifiedRoles element contains one or more wrapped attribute
/// certificates for the signer
/// </summary>
public class CertifiedRole : EncapsulatedPKIData
{
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CertifiedRole()
{
this.TagName = "CertifiedRole";
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// CertifiedRoleCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CertifiedRoleCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new CertifiedRole this[int index]
{
get
{
return (CertifiedRole)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public CertifiedRole Add(CertifiedRole objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public CertifiedRole Add()
{
return this.Add(new CertifiedRole());
}
}
}

View File

@ -0,0 +1,147 @@
// CertifiedRoles.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The CertifiedRoles element contains one or more wrapped attribute
/// certificates for the signer
/// </summary>
public class CertifiedRoles
{
#region Private variables
private CertifiedRoleCollection certifiedRoleCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of certified roles
/// </summary>
public CertifiedRoleCollection CertifiedRoleCollection
{
get
{
return this.certifiedRoleCollection;
}
set
{
this.certifiedRoleCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CertifiedRoles()
{
this.certifiedRoleCollection = new CertifiedRoleCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.certifiedRoleCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
EncapsulatedPKIData newCertifiedRole;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.certifiedRoleCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:CertifiedRole", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCertifiedRole = new EncapsulatedPKIData("CertifiedRole");
newCertifiedRole.LoadXml(iterationXmlElement);
this.certifiedRoleCollection.Add(newCertifiedRole);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CertifiedRoles", XadesSignedXml.XadesNamespaceUri);
if (this.certifiedRoleCollection.Count > 0)
{
foreach (EncapsulatedPKIData certifiedRole in this.certifiedRoleCollection)
{
if (certifiedRole.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(certifiedRole.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,101 @@
// ClaimedRole.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a roles claimed by the signer but not it is not a
/// certified role
/// </summary>
public class ClaimedRole
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents a claimed role
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public ClaimedRole()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "ClaimedRole", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// ClaimedRoleCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class ClaimedRoleCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new ClaimedRole this[int index]
{
get
{
return (ClaimedRole)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public ClaimedRole Add(ClaimedRole objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public ClaimedRole Add()
{
return this.Add(new ClaimedRole());
}
}
}

View File

@ -0,0 +1,150 @@
// ClaimedRoles.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The ClaimedRoles element contains a sequence of roles claimed by
/// the signer but not certified. Additional contents types may be
/// defined on a domain application basis and be part of this element.
/// The namespaces given to the corresponding XML schemas will allow
/// their unambiguous identification in the case these roles use XML.
/// </summary>
public class ClaimedRoles
{
#region Private variables
private ClaimedRoleCollection claimedRoleCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of claimed roles
/// </summary>
public ClaimedRoleCollection ClaimedRoleCollection
{
get
{
return this.claimedRoleCollection;
}
set
{
this.claimedRoleCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public ClaimedRoles()
{
this.claimedRoleCollection = new ClaimedRoleCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.claimedRoleCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
ClaimedRole newClaimedRole;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.claimedRoleCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:ClaimedRole", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newClaimedRole = new ClaimedRole();
newClaimedRole.LoadXml(iterationXmlElement);
this.claimedRoleCollection.Add(newClaimedRole);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "ClaimedRoles", XadesSignedXml.XadesNamespaceUri);
if (this.claimedRoleCollection.Count > 0)
{
foreach (ClaimedRole claimedRole in this.claimedRoleCollection)
{
if (claimedRole.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(claimedRole.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,283 @@
// CommitmentTypeIndication.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The commitment type can be indicated in the electronic signature
/// by either explicitly using a commitment type indication in the
/// electronic signature or implicitly or explicitly from the semantics
/// of the signed data object.
/// If the indicated commitment type is explicit by means of a commitment
/// type indication in the electronic signature, acceptance of a verified
/// signature implies acceptance of the semantics of that commitment type.
/// The semantics of explicit commitment types indications shall be
/// specified either as part of the signature policy or may be registered
/// for generic use across multiple policies.
/// </summary>
public class CommitmentTypeIndication
{
#region Private variables
private ObjectIdentifier commitmentTypeId;
private ObjectReferenceCollection objectReferenceCollection;
private bool allSignedDataObjects;
private CommitmentTypeQualifiers commitmentTypeQualifiers;
#endregion
#region Public properties
/// <summary>
/// The CommitmentTypeId element univocally identifies the type of commitment made by the signer.
/// A number of commitments have been already identified and assigned corresponding OIDs.
/// </summary>
public ObjectIdentifier CommitmentTypeId
{
get
{
return this.commitmentTypeId;
}
set
{
this.commitmentTypeId = value;
}
}
/// <summary>
/// Collection of object references
/// </summary>
public ObjectReferenceCollection ObjectReferenceCollection
{
get
{
return this.objectReferenceCollection;
}
set
{
this.objectReferenceCollection = value;
if (this.objectReferenceCollection != null)
{
if (this.objectReferenceCollection.Count > 0)
{
this.allSignedDataObjects = false;
}
}
}
}
/// <summary>
/// If all the signed data objects share the same commitment, the
/// AllSignedDataObjects empty element MUST be present
/// </summary>
public bool AllSignedDataObjects
{
get
{
return this.allSignedDataObjects;
}
set
{
this.allSignedDataObjects = value;
if (this.allSignedDataObjects)
{
this.objectReferenceCollection.Clear();
}
}
}
/// <summary>
/// The CommitmentTypeQualifiers element provides means to include additional
/// qualifying information on the commitment made by the signer
/// </summary>
public CommitmentTypeQualifiers CommitmentTypeQualifiers
{
get
{
return this.commitmentTypeQualifiers;
}
set
{
this.commitmentTypeQualifiers = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CommitmentTypeIndication()
{
this.commitmentTypeId = new ObjectIdentifier("CommitmentTypeId");
this.objectReferenceCollection = new ObjectReferenceCollection();
this.allSignedDataObjects = true;
this.commitmentTypeQualifiers = new CommitmentTypeQualifiers();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.commitmentTypeId != null && this.commitmentTypeId.HasChanged())
{
retVal = true;
}
if (this.objectReferenceCollection.Count > 0)
{
retVal = true;
}
if (this.commitmentTypeQualifiers != null && this.commitmentTypeQualifiers.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
ObjectReference newObjectReference;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeId", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
this.commitmentTypeId = null;
throw new CryptographicException("CommitmentTypeId missing");
}
else
{
this.commitmentTypeId = new ObjectIdentifier("CommitmentTypeId");
this.commitmentTypeId.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:ObjectReference", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.objectReferenceCollection.Clear();
this.allSignedDataObjects = false;
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newObjectReference = new ObjectReference();
newObjectReference.LoadXml(iterationXmlElement);
this.objectReferenceCollection.Add(newObjectReference);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
else
{
this.objectReferenceCollection.Clear();
this.allSignedDataObjects = true;
}
xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeQualifiers", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.commitmentTypeQualifiers = new CommitmentTypeQualifiers();
this.commitmentTypeQualifiers.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CommitmentTypeIndication", XadesSignedXml.XadesNamespaceUri);
if (this.commitmentTypeId != null && this.commitmentTypeId.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.commitmentTypeId.GetXml(), true));
}
else
{
throw new CryptographicException("CommitmentTypeId element missing");
}
if (this.allSignedDataObjects)
{ //Add emty element as required
bufferXmlElement = creationXmlDocument.CreateElement("xades", "AllSignedDataObjects", XadesSignedXml.XadesNamespaceUri);
retVal.AppendChild(bufferXmlElement);
}
else
{
if (this.objectReferenceCollection.Count > 0)
{
foreach (ObjectReference objectReference in this.objectReferenceCollection)
{
if (objectReference.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(objectReference.GetXml(), true));
}
}
}
}
if (this.commitmentTypeQualifiers != null && this.commitmentTypeQualifiers.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.commitmentTypeQualifiers.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// ACommitmentTypeIndicationCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CommitmentTypeIndicationCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new CommitmentTypeIndication this[int index]
{
get
{
return (CommitmentTypeIndication)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public CommitmentTypeIndication Add(CommitmentTypeIndication objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public CommitmentTypeIndication Add()
{
return this.Add(new CommitmentTypeIndication());
}
}
}

View File

@ -0,0 +1,101 @@
// CommitmentTypeQualifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The CommitmentTypeQualifiers element provides means to include
/// additional qualifying information on the commitment made by the signer
/// </summary>
public class CommitmentTypeQualifier
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents a commitment type qualifier
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CommitmentTypeQualifier()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CommitmentTypeQualifier", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// CommitmentTypeQualifierCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CommitmentTypeQualifierCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new CommitmentTypeQualifier this[int index]
{
get
{
return (CommitmentTypeQualifier)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public CommitmentTypeQualifier Add(CommitmentTypeQualifier objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public CommitmentTypeQualifier Add()
{
return this.Add(new CommitmentTypeQualifier());
}
}
}

View File

@ -0,0 +1,147 @@
// CommitmentTypeQualifers.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The CommitmentTypeQualifier element provides means to include
/// additional qualifying information on the commitment made by the signer
/// </summary>
public class CommitmentTypeQualifiers
{
#region Private variables
private CommitmentTypeQualifierCollection commitmentTypeQualifierCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of commitment type qualifiers
/// </summary>
public CommitmentTypeQualifierCollection CommitmentTypeQualifierCollection
{
get
{
return this.commitmentTypeQualifierCollection;
}
set
{
this.commitmentTypeQualifierCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CommitmentTypeQualifiers()
{
this.commitmentTypeQualifierCollection = new CommitmentTypeQualifierCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.commitmentTypeQualifierCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
CommitmentTypeQualifier newCommitmentTypeQualifier;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.commitmentTypeQualifierCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeQualifier", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCommitmentTypeQualifier = new CommitmentTypeQualifier();
newCommitmentTypeQualifier.LoadXml(iterationXmlElement);
this.commitmentTypeQualifierCollection.Add(newCommitmentTypeQualifier);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CommitmentTypeQualifiers", XadesSignedXml.XadesNamespaceUri);
if (this.commitmentTypeQualifierCollection.Count > 0)
{
foreach (CommitmentTypeQualifier commitmentTypeQualifier in this.commitmentTypeQualifierCollection)
{
if (commitmentTypeQualifier.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(commitmentTypeQualifier.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,157 @@
// CompleteCertificateRefs.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This clause defines the XML element containing the sequence of
/// references to the full set of CA certificates that have been used
/// to validate the electronic signature up to (but not including) the
/// signer's certificate. This is an unsigned property that qualifies
/// the signature.
/// An XML electronic signature aligned with the XAdES standard may
/// contain at most one CompleteCertificateRefs element.
/// </summary>
public class CompleteCertificateRefs
{
#region Private variables
private string id;
private CertRefs certRefs;
#endregion
#region Public properties
/// <summary>
/// The optional Id attribute can be used to make a reference to the CompleteCertificateRefs element
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// The CertRefs element contains a sequence of Cert elements, incorporating the
/// digest of each certificate and optionally the issuer and serial number identifier
/// </summary>
public CertRefs CertRefs
{
get
{
return this.certRefs;
}
set
{
this.certRefs = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CompleteCertificateRefs()
{
this.certRefs = new CertRefs();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (this.certRefs != null && this.certRefs.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:CertRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.certRefs = new CertRefs();
this.certRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CompleteCertificateRefs", XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.id))
{
retVal.SetAttribute("Id", this.id);
}
if (this.certRefs != null && this.certRefs.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.certRefs.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,216 @@
// CompleteRevocationRefs.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This clause defines the XML element containing a full set of
/// references to the revocation data that have been used in the
/// validation of the signer and CA certificates.
/// This is an unsigned property that qualifies the signature.
/// The XML electronic signature aligned with the present document
/// MAY contain at most one CompleteRevocationRefs element.
/// </summary>
public class CompleteRevocationRefs
{
#region Private variables
private string id;
private CRLRefs crlRefs;
private OCSPRefs ocspRefs;
private OtherRefs otherRefs;
#endregion
#region Public properties
/// <summary>
/// The optional Id attribute can be used to make a reference to the CompleteRevocationRefs element
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// Sequences of references to CRLs
/// </summary>
public CRLRefs CRLRefs
{
get
{
return this.crlRefs;
}
set
{
this.crlRefs = value;
}
}
/// <summary>
/// Sequences of references to OCSP responses
/// </summary>
public OCSPRefs OCSPRefs
{
get
{
return this.ocspRefs;
}
set
{
this.ocspRefs = value;
}
}
/// <summary>
/// Other references to alternative forms of revocation data
/// </summary>
public OtherRefs OtherRefs
{
get
{
return this.otherRefs;
}
set
{
this.otherRefs = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public CompleteRevocationRefs()
{
this.crlRefs = new CRLRefs();
this.ocspRefs = new OCSPRefs();
this.otherRefs = new OtherRefs();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (this.crlRefs != null && this.crlRefs.HasChanged())
{
retVal = true;
}
if (this.ocspRefs != null && this.ocspRefs.HasChanged())
{
retVal = true;
}
if (this.otherRefs != null && this.otherRefs.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:CRLRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.crlRefs = new CRLRefs();
this.crlRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:OCSPRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.ocspRefs = new OCSPRefs();
this.ocspRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:OtherRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.otherRefs = new OtherRefs();
this.otherRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "CompleteRevocationRefs", XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.id))
{
retVal.SetAttribute("Id", this.id);
}
if (this.crlRefs != null && this.crlRefs.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.crlRefs.GetXml(), true));
}
if (this.ocspRefs != null && this.ocspRefs.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.ocspRefs.GetXml(), true));
}
if (this.otherRefs != null && this.otherRefs.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.otherRefs.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// CounterSignatureCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class CounterSignatureCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new XadesSignedXml this[int index]
{
get
{
return (XadesSignedXml)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public XadesSignedXml Add(XadesSignedXml objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public XadesSignedXml Add()
{
return this.Add(new XadesSignedXml());
}
}
}

View File

@ -0,0 +1,270 @@
// DataIbjectFormat.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The DataObjectFormat element provides information that describes the
/// format of the signed data object. This element must be present when it
/// is mandatory to present the signed data object to human users on
/// verification.
/// This is a signed property that qualifies one specific signed data
/// object. In consequence, a XAdES signature may contain more than one
/// DataObjectFormat elements, each one qualifying one signed data object.
/// </summary>
public class DataObjectFormat
{
#region Private variables
private string objectReferenceAttribute;
private string description;
private ObjectIdentifier objectIdentifier;
private string mimeType;
private string encoding;
#endregion
#region Public properties
/// <summary>
/// The mandatory ObjectReference attribute refers to the Reference element
/// of the signature corresponding with the data object qualified by this
/// property
/// </summary>
public string ObjectReferenceAttribute
{
get
{
return this.objectReferenceAttribute;
}
set
{
this.objectReferenceAttribute = value;
}
}
/// <summary>
/// Textual information related to the signed data object
/// </summary>
public string Description
{
get
{
return this.description;
}
set
{
this.description = value;
}
}
/// <summary>
/// An identifier indicating the type of the signed data object
/// </summary>
public ObjectIdentifier ObjectIdentifier
{
get
{
return this.objectIdentifier;
}
set
{
this.objectIdentifier = value;
}
}
/// <summary>
/// An indication of the MIME type of the signed data object
/// </summary>
public string MimeType
{
get
{
return this.mimeType;
}
set
{
this.mimeType = value;
}
}
/// <summary>
/// An indication of the encoding format of the signed data object
/// </summary>
public string Encoding
{
get
{
return this.encoding;
}
set
{
this.encoding = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public DataObjectFormat()
{
this.objectIdentifier = new ObjectIdentifier("ObjectIdentifier");
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.objectReferenceAttribute))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.description))
{
retVal = true;
}
if (this.objectIdentifier != null && this.objectIdentifier.HasChanged())
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.mimeType))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.encoding))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("ObjectReference"))
{
this.objectReferenceAttribute = xmlElement.GetAttribute("ObjectReference");
}
else
{
this.objectReferenceAttribute = "";
throw new CryptographicException("ObjectReference attribute missing");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:Description", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.description = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:ObjectIdentifier", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.objectIdentifier = new ObjectIdentifier("ObjectIdentifier");
this.objectIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:MimeType", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.mimeType = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:Encoding", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.encoding = xmlNodeList.Item(0).InnerText;
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "DataObjectFormat", XadesSignedXml.XadesNamespaceUri);
if ((this.objectReferenceAttribute != null) && ((this.objectReferenceAttribute != "")))
{
retVal.SetAttribute("ObjectReference", this.objectReferenceAttribute);
}
else
{
throw new CryptographicException("Attribute ObjectReference missing");
}
if (!String.IsNullOrEmpty(this.description))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "Description", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.description;
retVal.AppendChild(bufferXmlElement);
}
if (this.objectIdentifier != null && this.objectIdentifier.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.objectIdentifier.GetXml(), true));
}
if (!String.IsNullOrEmpty(this.mimeType))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "MimeType", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.mimeType;
retVal.AppendChild(bufferXmlElement);
}
if (!String.IsNullOrEmpty(this.encoding))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "Encoding", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.encoding;
retVal.AppendChild(bufferXmlElement);
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// DataObjectFormatCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class DataObjectFormatCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new DataObjectFormat this[int index]
{
get
{
return (DataObjectFormat)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public DataObjectFormat Add(DataObjectFormat objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public DataObjectFormat Add()
{
return this.Add(new DataObjectFormat());
}
}
}

View File

@ -0,0 +1,192 @@
// DigestAlgAndValueType.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class indicates the algortithm used to calculate the digest and
/// the digest value itself
/// </summary>
public class DigestAlgAndValueType
{
#region Private variables
private string tagName;
private DigestMethod digestMethod;
private byte[] digestValue;
#endregion
#region Public properties
/// <summary>
/// The name of the element when serializing
/// </summary>
public string TagName
{
get
{
return this.tagName;
}
set
{
this.tagName = value;
}
}
/// <summary>
/// Indicates the digest algorithm
/// </summary>
public DigestMethod DigestMethod
{
get
{
return this.digestMethod;
}
set
{
this.digestMethod = value;
}
}
/// <summary>
/// Contains the value of the digest
/// </summary>
public byte[] DigestValue
{
get
{
return this.digestValue;
}
set
{
this.digestValue = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public DigestAlgAndValueType()
{
this.digestMethod = new DigestMethod();
this.digestValue = null;
}
/// <summary>
/// Constructor with TagName
/// </summary>
/// <param name="tagName">Name of the tag when serializing with GetXml</param>
public DigestAlgAndValueType(string tagName) : this()
{
this.tagName = tagName;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.digestMethod != null && this.digestMethod.HasChanged())
{
retVal = true;
}
if (this.digestValue != null && this.digestValue.Length > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
xmlNodeList = xmlElement.SelectNodes("ds:DigestMethod", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("DigestMethod missing");
}
this.digestMethod = new DigestMethod();
this.digestMethod.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("ds:DigestValue", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("DigestValue missing");
}
this.digestValue = Convert.FromBase64String(xmlNodeList.Item(0).InnerText);
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", this.tagName, XadesSignedXml.XadesNamespaceUri);
if (this.digestMethod != null && this.digestMethod.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.digestMethod.GetXml(), true));
}
else
{
throw new CryptographicException("DigestMethod element missing in DigestAlgAndValueType");
}
if (this.digestValue != null && this.digestValue.Length > 0)
{
bufferXmlElement = creationXmlDocument.CreateElement("ds", "DigestValue", SignedXml.XmlDsigNamespaceUrl);
bufferXmlElement.InnerText = Convert.ToBase64String(this.digestValue);
retVal.AppendChild(bufferXmlElement);
}
else
{
throw new CryptographicException("DigestValue element missing in DigestAlgAndValueType");
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,104 @@
// DigestMethod.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// DigestMethod indicates the digest algorithm
/// </summary>
public class DigestMethod
{
#region Private variables
private string algorithm;
#endregion
#region Public properties
/// <summary>
/// Contains the digest algorithm
/// </summary>
public string Algorithm
{
get
{
return this.algorithm;
}
set
{
this.algorithm = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public DigestMethod()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.algorithm))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
this.algorithm = xmlElement.GetAttribute("Algorithm");
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("ds", "DigestMethod", SignedXml.XmlDsigNamespaceUrl);
retVal.SetAttribute("Algorithm", this.algorithm);
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,103 @@
// DocumentationReference.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// DocumentationReference points to further explanatory documentation
/// of the object identifier
/// </summary>
public class DocumentationReference
{
#region Private variables
private string documentationReferenceUri;
#endregion
#region Public properties
/// <summary>
/// Pointer to further explanatory documentation of the object identifier
/// </summary>
public string DocumentationReferenceUri
{
get
{
return this.documentationReferenceUri;
}
set
{
this.documentationReferenceUri = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public DocumentationReference()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.documentationReferenceUri))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
this.documentationReferenceUri = xmlElement.InnerText;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "DocumentationReference", XadesSignedXml.XadesNamespaceUri);
retVal.InnerText = this.documentationReferenceUri;
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// DocumentationReferenceCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class DocumentationReferenceCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new DocumentationReference this[int index]
{
get
{
return (DocumentationReference)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public DocumentationReference Add(DocumentationReference objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public DocumentationReference Add()
{
return this.Add(new DocumentationReference());
}
}
}

View File

@ -0,0 +1,146 @@
// DocumentationReferences.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of DocumentationReferences
/// </summary>
public class DocumentationReferences
{
#region Private variables
private DocumentationReferenceCollection documentationReferenceCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of documentation references
/// </summary>
public DocumentationReferenceCollection DocumentationReferenceCollection
{
get
{
return this.documentationReferenceCollection;
}
set
{
this.documentationReferenceCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public DocumentationReferences()
{
this.documentationReferenceCollection = new DocumentationReferenceCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.documentationReferenceCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
DocumentationReference newDocumentationReference;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.documentationReferenceCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:DocumentationReference", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newDocumentationReference = new DocumentationReference();
newDocumentationReference.LoadXml(iterationXmlElement);
this.documentationReferenceCollection.Add(newDocumentationReference);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "DocumentationReferences", XadesSignedXml.XadesNamespaceUri);
if (this.documentationReferenceCollection.Count > 0)
{
foreach (DocumentationReference documentationReference in this.documentationReferenceCollection)
{
if (documentationReference.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(documentationReference.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,171 @@
// EncapsulatedPKIData.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// EncapsulatedPKIData is used to incorporate a piece of PKI data
/// into an XML structure whereas the PKI data is encoded using an ASN.1
/// encoding mechanism. Examples of such PKI data that are widely used at
/// the time include X509 certificates and revocation lists, OCSP responses,
/// attribute certificates and time-stamps.
/// </summary>
public class EncapsulatedPKIData
{
#region Private variables
private string tagName;
private string id;
private byte[] pkiData;
#endregion
#region Public properties
/// <summary>
/// The name of the element when serializing
/// </summary>
public string TagName
{
get
{
return this.tagName;
}
set
{
this.tagName = value;
}
}
/// <summary>
/// The optional ID attribute can be used to make a reference to an element
/// of this data type.
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// Base64 encoded content of this data type
/// </summary>
public byte[] PkiData
{
get
{
return this.pkiData;
}
set
{
this.pkiData = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public EncapsulatedPKIData()
{
}
/// <summary>
/// Constructor with TagName
/// </summary>
/// <param name="tagName">Name of the tag when serializing with GetXml</param>
public EncapsulatedPKIData(string tagName)
{
this.tagName = tagName;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (this.pkiData != null && this.pkiData.Length > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
this.pkiData = Convert.FromBase64String(xmlElement.InnerText);
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", this.tagName, XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.id))
{
retVal.SetAttribute("Id", this.id);
}
if (this.pkiData != null && this.pkiData.Length > 0)
{
retVal.InnerText = Convert.ToBase64String(this.pkiData);
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,32 @@
// EncapsulatedX509Certificate.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
namespace Microsoft.Xades
{
/// <summary>
/// The EncapsulatedX509Certificate element is able to contain the
/// base64 encoding of a DER-encoded X.509 certificate
/// </summary>
public class EncapsulatedX509Certificate : EncapsulatedPKIData
{
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public EncapsulatedX509Certificate()
{
this.TagName = "EncapsulatedX509Certificate";
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// EncapsulatedX509CertificateCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class EncapsulatedX509CertificateCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new EncapsulatedX509Certificate this[int index]
{
get
{
return (EncapsulatedX509Certificate)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public EncapsulatedX509Certificate Add(EncapsulatedX509Certificate objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public EncapsulatedX509Certificate Add()
{
return this.Add(new EncapsulatedX509Certificate());
}
}
}

View File

@ -0,0 +1,156 @@
// HashDataInfo.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The HashDataInfo class contains a uri attribute referencing a data object
/// and a ds:Transforms element indicating the transformations to make to this
/// data object.
/// The sequence of HashDataInfo elements will be used to produce the input of
/// the hash computation process whose result will be included in the
/// timestamp request to be sent to the TSA.
/// </summary>
public class HashDataInfo
{
#region Private variables
private string uriAttribute;
private Transforms transforms;
#endregion
#region Public properties
/// <summary>
/// Uri referencing a data object
/// </summary>
public string UriAttribute
{
get
{
return this.uriAttribute;
}
set
{
this.uriAttribute = value;
}
}
/// <summary>
/// Transformations to make to this data object
/// </summary>
public Transforms Transforms
{
get
{
return this.transforms;
}
set
{
this.transforms = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public HashDataInfo()
{
this.transforms = new Transforms();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.uriAttribute))
{
retVal = true;
}
if (this.transforms != null && this.transforms.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("uri"))
{
this.uriAttribute = xmlElement.GetAttribute("uri");
}
else
{
this.uriAttribute = "";
throw new CryptographicException("uri attribute missing");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:Transforms", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.transforms = new Transforms();
this.transforms.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "HashDataInfo", XadesSignedXml.XadesNamespaceUri);
retVal.SetAttribute("uri", this.uriAttribute);
if (this.transforms != null && this.transforms.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.transforms.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// HashDataInfoCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class HashDataInfoCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new HashDataInfo this[int index]
{
get
{
return (HashDataInfo)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public HashDataInfo Add(HashDataInfo objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public HashDataInfo Add()
{
return this.Add(new HashDataInfo());
}
}
}

View File

@ -0,0 +1,162 @@
// Identifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// Possible values for Qualifier
/// </summary>
public enum KnownQualifier
{
/// <summary>
/// Value has not been set
/// </summary>
Uninitalized,
/// <summary>
/// OID encoded as Uniform Resource Identifier (URI)
/// </summary>
OIDAsURI,
/// <summary>
/// OID encoded as Uniform Resource Name (URN)
/// </summary>
OIDAsURN
}
/// <summary>
/// The Identifier element contains a permanent identifier. Once assigned the
/// identifier can never be re-assigned again. It supports both the mechanism
/// that is used to identify objects in ASN.1 and the mechanism that is
/// usually used to identify objects in an XML environment.
/// </summary>
public class Identifier
{
#region Private variables
private KnownQualifier qualifier;
private string identifierUri;
#endregion
#region Public properties
/// <summary>
/// The optional Qualifier attribute can be used to provide a hint about the
/// applied encoding (values OIDAsURN or OIDAsURI)
/// </summary>
public KnownQualifier Qualifier
{
get
{
return this.qualifier;
}
set
{
this.qualifier = value;
}
}
/// <summary>
/// Identification of the XML environment object
/// </summary>
public string IdentifierUri
{
get
{
return this.identifierUri;
}
set
{
this.identifierUri = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public Identifier()
{
this.qualifier = KnownQualifier.Uninitalized;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.qualifier != KnownQualifier.Uninitalized)
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.identifierUri))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Qualifier"))
{
this.qualifier = (KnownQualifier)KnownQualifier.Parse(typeof(KnownQualifier), xmlElement.GetAttribute("Qualifier"), true);
}
else
{
this.qualifier = KnownQualifier.Uninitalized;
}
this.identifierUri = xmlElement.InnerText;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "Identifier", XadesSignedXml.XadesNamespaceUri);
if (this.qualifier != KnownQualifier.Uninitalized)
{
retVal.SetAttribute("Qualifier", this.qualifier.ToString());
}
retVal.InnerText = this.identifierUri;
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,63 @@
// individualDataObjectsTimeStampCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class IndividualDataObjectsTimeStampCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new TimeStamp this[int index]
{
get
{
return (TimeStamp)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public TimeStamp Add(TimeStamp objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <param name="tagName">Name of the tag when serializing into XML using GetXml()</param>
/// <returns>The newly created object that has been added to collection</returns>
public TimeStamp Add(string tagName)
{
return this.Add(new TimeStamp(tagName));
}
}
}

View File

@ -0,0 +1,152 @@
// IssuerSerial.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The element IssuerSerial contains the identifier of one of the
/// certificates referenced in the sequence
/// </summary>
public class IssuerSerial
{
#region Private variables
private string x509IssuerName;
private string x509SerialNumber;
#endregion
#region Public properties
/// <summary>
/// Name of the X509 certificate issuer
/// </summary>
public string X509IssuerName
{
get
{
return this.x509IssuerName;
}
set
{
this.x509IssuerName = value;
}
}
/// <summary>
/// Serial number of the X509 certificate
/// </summary>
public string X509SerialNumber
{
get
{
return this.x509SerialNumber;
}
set
{
this.x509SerialNumber = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public IssuerSerial()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.x509IssuerName))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.x509SerialNumber))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
xmlNodeList = xmlElement.SelectNodes("ds:X509IssuerName", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("X509IssuerName missing");
}
this.x509IssuerName = xmlNodeList.Item(0).InnerText;
xmlNodeList = xmlElement.SelectNodes("ds:X509SerialNumber", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("X509SerialNumber missing");
}
this.x509SerialNumber = xmlNodeList.Item(0).InnerText;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "IssuerSerial", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement = creationXmlDocument.CreateElement("ds", "X509IssuerName", SignedXml.XmlDsigNamespaceUrl);
bufferXmlElement.InnerText = this.x509IssuerName;
retVal.AppendChild(bufferXmlElement);
bufferXmlElement = creationXmlDocument.CreateElement("ds", "X509SerialNumber", SignedXml.XmlDsigNamespaceUrl);
bufferXmlElement.InnerText = this.x509SerialNumber;
retVal.AppendChild(bufferXmlElement);
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// NoticeNumberCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class NoticeNumberCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new int this[int index]
{
get
{
return (int)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public int Add(int objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public int Add()
{
return this.Add(new int());
}
}
}

View File

@ -0,0 +1,147 @@
// NoticeNumbers.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains identifying numbers for a group of textual statements
/// so that the XAdES based application can get the explicit notices from a
/// notices file
/// </summary>
public class NoticeNumbers
{
#region Private variables
private NoticeNumberCollection noticeNumberCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of notice numbers
/// </summary>
public NoticeNumberCollection NoticeNumberCollection
{
get
{
return this.noticeNumberCollection;
}
set
{
this.noticeNumberCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public NoticeNumbers()
{
this.noticeNumberCollection = new NoticeNumberCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.noticeNumberCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
int newNoticeNumber;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.noticeNumberCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:int", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newNoticeNumber = int.Parse(iterationXmlElement.InnerText);
this.noticeNumberCollection.Add(newNoticeNumber);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement bufferXmlElement;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "NoticeNumbers", XadesSignedXml.XadesNamespaceUri);
if (this.noticeNumberCollection.Count > 0)
{
foreach (int noticeNumber in this.noticeNumberCollection)
{
bufferXmlElement = creationXmlDocument.CreateElement("int", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = noticeNumber.ToString();
retVal.AppendChild(bufferXmlElement);
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,161 @@
// NoticeRef.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The NoticeRef element names an organization and identifies by
/// numbers a group of textual statements prepared by that organization,
/// so that the application could get the explicit notices from a notices file
/// </summary>
public class NoticeRef
{
#region Private variables
private string organization;
private NoticeNumbers noticeNumbers;
#endregion
#region Public properties
/// <summary>
/// Organization issuing the signature policy
/// </summary>
public string Organization
{
get
{
return this.organization;
}
set
{
this.organization = value;
}
}
/// <summary>
/// Numerical identification of textual statements prepared by the organization,
/// so that the application can get the explicit notices from a notices file
/// </summary>
public NoticeNumbers NoticeNumbers
{
get
{
return this.noticeNumbers;
}
set
{
this.noticeNumbers = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public NoticeRef()
{
this.noticeNumbers = new NoticeNumbers();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.organization))
{
retVal = true;
}
if (this.noticeNumbers != null && this.noticeNumbers.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:Organization", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("Organization missing");
}
this.organization = xmlNodeList.Item(0).InnerText;
xmlNodeList = xmlElement.SelectNodes("xsd:NoticeNumbers", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("NoticeNumbers missing");
}
this.noticeNumbers = new NoticeNumbers();
this.noticeNumbers.LoadXml((XmlElement)xmlNodeList.Item(0));
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement bufferXmlElement;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "NoticeRef", XadesSignedXml.XadesNamespaceUri);
if (this.organization == null)
{
throw new CryptographicException("Organization can't be null");
}
bufferXmlElement = creationXmlDocument.CreateElement("xades", "Organization", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.organization;
retVal.AppendChild(bufferXmlElement);
if (this.noticeNumbers == null)
{
throw new CryptographicException("NoticeNumbers can't be null");
}
retVal.AppendChild(creationXmlDocument.ImportNode(this.noticeNumbers.GetXml(), true));
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,186 @@
// OCSPIdentifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class includes the name of the server that has produced the
/// referenced response (ResponderID element) and the time indication in
/// the "ProducedAt" field of the referenced response (ProducedAt element).
/// The optional URI attribute could serve to indicate where the OCSP
/// response identified is archived.
/// </summary>
public class OCSPIdentifier
{
#region Private variables
private string uriAttribute;
private string responderID;
private DateTime producedAt;
#endregion
#region Public properties
/// <summary>
/// The optional URI attribute could serve to indicate where the OCSP
/// response is archived
/// </summary>
public string UriAttribute
{
get
{
return this.uriAttribute;
}
set
{
this.uriAttribute = value;
}
}
/// <summary>
/// The ID of the server that has produced the referenced response
/// </summary>
public string ResponderID
{
get
{
return this.responderID;
}
set
{
this.responderID = value;
}
}
/// <summary>
/// Time indication in the referenced response
/// </summary>
public DateTime ProducedAt
{
get
{
return this.producedAt;
}
set
{
this.producedAt = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OCSPIdentifier()
{
this.producedAt = DateTime.MinValue;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.uriAttribute))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.responderID))
{
retVal = true;
}
if (this.producedAt != DateTime.MinValue)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("URI"))
{
this.uriAttribute = xmlElement.GetAttribute("URI");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:ResponderID", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.responderID = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:ProducedAt", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.producedAt = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Local);
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OCSPIdentifier", XadesSignedXml.XadesNamespaceUri);
retVal.SetAttribute("URI", this.uriAttribute);
if (!String.IsNullOrEmpty(this.responderID))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "ResponderID", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.responderID;
retVal.AppendChild(bufferXmlElement);
}
if (this.producedAt != DateTime.MinValue)
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "ProducedAt", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = Convert.ToString(this.producedAt.ToString("s"));
retVal.AppendChild(bufferXmlElement);
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,164 @@
// OCSPRef.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class identifies one OCSP response
/// </summary>
public class OCSPRef
{
#region Private variables
private OCSPIdentifier ocspIdentifier;
private DigestAlgAndValueType digestAlgAndValue;
#endregion
#region Public properties
/// <summary>
/// Identification of one OCSP response
/// </summary>
public OCSPIdentifier OCSPIdentifier
{
get
{
return this.ocspIdentifier;
}
set
{
this.ocspIdentifier = value;
}
}
/// <summary>
/// The digest computed on the DER encoded OCSP response, since it may be
/// needed to differentiate between two OCSP responses by the same server
/// with their "ProducedAt" fields within the same second
/// </summary>
public DigestAlgAndValueType CertDigest
{
get
{
return this.digestAlgAndValue;
}
set
{
this.digestAlgAndValue = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OCSPRef()
{
this.ocspIdentifier = new OCSPIdentifier();
this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue");
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.ocspIdentifier != null && this.ocspIdentifier.HasChanged())
{
retVal = true;
}
if (this.digestAlgAndValue != null && this.digestAlgAndValue.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:OCSPIdentifier", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("OCSPIdentifier missing");
}
this.ocspIdentifier = new OCSPIdentifier();
this.ocspIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:DigestAlgAndValue", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
this.digestAlgAndValue = null;
}
else
{
this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue");
this.digestAlgAndValue.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OCSPRef", XadesSignedXml.XadesNamespaceUri);
if (this.ocspIdentifier != null && this.ocspIdentifier.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.ocspIdentifier.GetXml(), true));
}
else
{
throw new CryptographicException("OCSPIdentifier element missing in OCSPRef");
}
if (this.digestAlgAndValue != null && this.digestAlgAndValue.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.digestAlgAndValue.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// OCSPRefCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class OCSPRefCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new OCSPRef this[int index]
{
get
{
return (OCSPRef)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public OCSPRef Add(OCSPRef objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public OCSPRef Add()
{
return this.Add(new OCSPRef());
}
}
}

View File

@ -0,0 +1,146 @@
// OCSPRefs.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of OCSPRefs
/// </summary>
public class OCSPRefs
{
#region Private variables
private OCSPRefCollection ocspRefCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of OCSP refs
/// </summary>
public OCSPRefCollection OCSPRefCollection
{
get
{
return this.ocspRefCollection;
}
set
{
this.ocspRefCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OCSPRefs()
{
this.ocspRefCollection = new OCSPRefCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.ocspRefCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
OCSPRef newOCSPRef;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.ocspRefCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:OCSPRef", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newOCSPRef = new OCSPRef();
newOCSPRef.LoadXml(iterationXmlElement);
this.ocspRefCollection.Add(newOCSPRef);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OCSPRefs", XadesSignedXml.XadesNamespaceUri);
if (this.ocspRefCollection.Count > 0)
{
foreach (OCSPRef ocspRef in this.ocspRefCollection)
{
if (ocspRef.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(ocspRef.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,33 @@
// OCSPValue.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
namespace Microsoft.Xades
{
/// <summary>
/// This class consist of a sequence of at least one OCSP Response. The
/// EncapsulatedOCSPValue element contains the base64 encoding of a
/// DER-encoded OCSP Response
/// </summary>
public class OCSPValue : EncapsulatedPKIData
{
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OCSPValue()
{
this.TagName = "EncapsulatedOCSPValue";
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// OCSPValueCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class OCSPValueCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new OCSPValue this[int index]
{
get
{
return (OCSPValue)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public OCSPValue Add(OCSPValue objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public OCSPValue Add()
{
return this.Add(new OCSPValue());
}
}
}

View File

@ -0,0 +1,146 @@
// OCSPValues.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of OCSPValues
/// </summary>
public class OCSPValues
{
#region Private variables
private OCSPValueCollection ocspValueCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of OCSP values
/// </summary>
public OCSPValueCollection OCSPValueCollection
{
get
{
return this.ocspValueCollection;
}
set
{
this.ocspValueCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OCSPValues()
{
this.ocspValueCollection = new OCSPValueCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.ocspValueCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
OCSPValue newOCSPValue;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.ocspValueCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:OCSPValue", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newOCSPValue = new OCSPValue();
newOCSPValue.LoadXml(iterationXmlElement);
this.ocspValueCollection.Add(newOCSPValue);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OCSPValues", XadesSignedXml.XadesNamespaceUri);
if (this.ocspValueCollection.Count > 0)
{
foreach (OCSPValue ocspValue in this.ocspValueCollection)
{
if (ocspValue.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(ocspValue.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,221 @@
// ObjectIdentifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// ObjectIdentifier allows the specification of an unique and permanent
/// object of an object and some additional information about the nature of
/// the data object
/// </summary>
public class ObjectIdentifier
{
#region Private variables
private string tagName;
private Identifier identifier;
private string description;
private DocumentationReferences documentationReferences;
#endregion
#region Public properties
/// <summary>
/// The name of the element when serializing
/// </summary>
public string TagName
{
get
{
return this.tagName;
}
set
{
this.tagName = value;
}
}
/// <summary>
/// Specification of an unique and permanent identifier
/// </summary>
public Identifier Identifier
{
get
{
return this.identifier;
}
set
{
this.identifier = value;
}
}
/// <summary>
/// Textual description of the nature of the data object
/// </summary>
public string Description
{
get
{
return this.description;
}
set
{
this.description = value;
}
}
/// <summary>
/// References to documents where additional information about the
/// nature of the data object can be found
/// </summary>
public DocumentationReferences DocumentationReferences
{
get
{
return this.documentationReferences;
}
set
{
this.documentationReferences = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public ObjectIdentifier()
{
this.identifier = new Identifier();
this.documentationReferences = new DocumentationReferences();
}
/// <summary>
/// Constructor with TagName
/// </summary>
/// <param name="tagName">Name of the tag when serializing with GetXml</param>
public ObjectIdentifier(string tagName) : this()
{
this.tagName = tagName;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.identifier != null && this.identifier.HasChanged())
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.description))
{
retVal = true;
}
if (this.documentationReferences != null && this.documentationReferences.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:Identifier", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("Identifier missing");
}
this.identifier = new Identifier();
this.identifier.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:Description", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.description = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:DocumentationReferences", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.documentationReferences = new DocumentationReferences();
this.documentationReferences.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", this.tagName, XadesSignedXml.XadesNamespaceUri);
if (this.identifier != null && this.identifier.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.identifier.GetXml(), true));
}
else
{
throw new CryptographicException("Identifier element missing in OjectIdentifier");
}
if (!String.IsNullOrEmpty(this.description))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "Description", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.description;
retVal.AppendChild(bufferXmlElement);
}
if (this.documentationReferences != null && this.documentationReferences.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.documentationReferences.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,107 @@
// ObjectReference.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class refers to one ds:Reference element of the ds:SignedInfo
/// corresponding with one data object qualified by this property.
/// If some but not all the signed data objects share the same commitment,
/// one ObjectReference element must appear for each one of them.
/// However, if all the signed data objects share the same commitment,
/// the AllSignedDataObjects empty element must be present.
/// </summary>
public class ObjectReference
{
#region Private variables
private string objectReferenceUri;
#endregion
#region Public properties
/// <summary>
/// Uri of the object reference
/// </summary>
public string ObjectReferenceUri
{
get
{
return this.objectReferenceUri;
}
set
{
this.objectReferenceUri = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public ObjectReference()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.objectReferenceUri != null && this.objectReferenceUri != "")
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
this.objectReferenceUri = xmlElement.InnerText;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "ObjectReference", XadesSignedXml.XadesNamespaceUri);
retVal.InnerText = this.objectReferenceUri;
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// ObjectReferenceCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class ObjectReferenceCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new ObjectReference this[int index]
{
get
{
return (ObjectReference)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public ObjectReference Add(ObjectReference objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public ObjectReference Add()
{
return this.Add(new ObjectReference());
}
}
}

View File

@ -0,0 +1,102 @@
// OtherCertificate.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The OtherCertificate element is a placeholder for potential future
/// new formats of certificates
/// </summary>
public class OtherCertificate : ArrayList
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents any certificate
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OtherCertificate()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OtherCertificate", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// OtherCertificateCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class OtherCertificateCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new OtherCertificate this[int index]
{
get
{
return (OtherCertificate)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public OtherCertificate Add(OtherCertificate objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public OtherCertificate Add()
{
return this.Add(new OtherCertificate());
}
}
}

View File

@ -0,0 +1,100 @@
// OtherRef.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// Alternative forms of validation data can be included in this class
/// </summary>
public class OtherRef
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents any other type of ref
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OtherRef()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OtherRef", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// OtherRefCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class OtherRefCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new OtherRef this[int index]
{
get
{
return (OtherRef)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public OtherRef Add(OtherRef objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public OtherRef Add()
{
return this.Add(new OtherRef());
}
}
}

View File

@ -0,0 +1,146 @@
// OtherRefs.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of OtherRefs
/// </summary>
public class OtherRefs
{
#region Private variables
private OtherRefCollection otherRefCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of other refs
/// </summary>
public OtherRefCollection OtherRefCollection
{
get
{
return this.otherRefCollection;
}
set
{
this.otherRefCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OtherRefs()
{
this.otherRefCollection = new OtherRefCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.otherRefCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
OtherRef newOtherRef;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.otherRefCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:OtherRef", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newOtherRef = new OtherRef();
newOtherRef.LoadXml(iterationXmlElement);
this.otherRefCollection.Add(newOtherRef);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OtherRefs", XadesSignedXml.XadesNamespaceUri);
if (this.otherRefCollection.Count > 0)
{
foreach (OtherRef otherRef in this.otherRefCollection)
{
if (otherRef.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(otherRef.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,100 @@
// OtherValue.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class provides a placeholder for other revocation information
/// </summary>
public class OtherValue
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents any other value
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OtherValue()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OtherValue", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// OtherValueCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class OtherValueCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new OtherValue this[int index]
{
get
{
return (OtherValue)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public OtherValue Add(OtherValue objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public OtherValue Add()
{
return this.Add(new OtherValue());
}
}
}

View File

@ -0,0 +1,146 @@
// OtherValues.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of OtherValues
/// </summary>
public class OtherValues
{
#region Private variables
private OtherValueCollection otherValueCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of other values
/// </summary>
public OtherValueCollection OtherValueCollection
{
get
{
return this.otherValueCollection;
}
set
{
this.otherValueCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public OtherValues()
{
this.otherValueCollection = new OtherValueCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.otherValueCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
OtherValue newOtherValue;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.otherValueCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:OtherValue", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newOtherValue = new OtherValue();
newOtherValue.LoadXml(iterationXmlElement);
this.otherValueCollection.Add(newOtherValue);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "OtherValues", XadesSignedXml.XadesNamespaceUri);
if (this.otherValueCollection.Count > 0)
{
foreach (OtherValue otherValue in this.otherValueCollection)
{
if (otherValue.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(otherValue.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,237 @@
// QualifiyngProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The QualifyingProperties element acts as a container element for
/// all the qualifying information that should be added to an XML
/// signature
/// </summary>
public class QualifyingProperties
{
#region Private variables
private string id;
private string target;
private SignedProperties signedProperties;
private UnsignedProperties unsignedProperties;
#endregion
#region Public properties
/// <summary>
/// The optional Id attribute can be used to make a reference to the
/// QualifyingProperties container
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// The mandatory Target attribute refers to the XML signature with which the
/// qualifying properties are associated
/// </summary>
public string Target
{
get
{
return this.target;
}
set
{
this.target = value;
}
}
/// <summary>
/// The SignedProperties element contains a number of properties that are
/// collectively signed by the XMLDSIG signature
/// </summary>
public SignedProperties SignedProperties
{
get
{
return this.signedProperties;
}
set
{
this.signedProperties = value;
}
}
/// <summary>
/// The UnsignedProperties element contains a number of properties that are
/// not signed by the XMLDSIG signature
/// </summary>
public UnsignedProperties UnsignedProperties
{
get
{
return this.unsignedProperties;
}
set
{
this.unsignedProperties = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public QualifyingProperties()
{
this.signedProperties = new SignedProperties();
this.unsignedProperties = new UnsignedProperties();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.target))
{
retVal = true;
}
if (this.signedProperties != null && this.signedProperties.HasChanged())
{
retVal = true;
}
if (this.unsignedProperties != null && this.unsignedProperties.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
/// <param name="counterSignedXmlElement">Element containing parent signature (needed if there are counter signatures)</param>
public void LoadXml(XmlElement xmlElement, XmlElement counterSignedXmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
if (xmlElement.HasAttribute("Target"))
{
this.target = xmlElement.GetAttribute("Target");
}
else
{
this.target = "";
throw new CryptographicException("Target attribute missing");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SignedProperties", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("SignedProperties missing");
}
this.signedProperties = new SignedProperties();
this.signedProperties.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:UnsignedProperties", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.unsignedProperties = new UnsignedProperties();
this.unsignedProperties.LoadXml((XmlElement)xmlNodeList.Item(0), counterSignedXmlElement);
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "QualifyingProperties", XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.id))
{
retVal.SetAttribute("Id", this.id);
}
if (!String.IsNullOrEmpty(this.target))
{
retVal.SetAttribute("Target", this.target);
}
else
{
throw new CryptographicException("QualifyingProperties Target attribute has no value");
}
var xmlAttribute = retVal.OwnerDocument.CreateAttribute("xmlns", "xades141", "http://www.w3.org/2000/xmlns/");
xmlAttribute.Value = "http://uri.etsi.org/01903/v1.4.1#";
retVal.Attributes.Append(xmlAttribute);
if (this.signedProperties != null && this.signedProperties.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signedProperties.GetXml(), true));
}
if (this.unsignedProperties != null && this.unsignedProperties.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.unsignedProperties.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,217 @@
// RevocationValues.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The RevocationValues element is used to hold the values of the
/// revocation information which are to be shipped with the XML signature
/// in case of an XML Advanced Electronic Signature with Extended
/// Validation Data (XAdES-X-Long). This is a unsigned property that
/// qualifies the signature. An XML electronic signature aligned with the
/// present document MAY contain at most one RevocationValues element.
/// </summary>
public class RevocationValues
{
#region Private variables
private string id;
private CRLValues crlValues;
private OCSPValues ocspValues;
private OtherValues otherValues;
#endregion
#region Public properties
/// <summary>
/// Optional Id for the XML element
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// Certificate Revocation Lists
/// </summary>
public CRLValues CRLValues
{
get
{
return this.crlValues;
}
set
{
this.crlValues = value;
}
}
/// <summary>
/// Responses from an online certificate status server
/// </summary>
public OCSPValues OCSPValues
{
get
{
return this.ocspValues;
}
set
{
this.ocspValues = value;
}
}
/// <summary>
/// Placeholder for other revocation information is provided for future
/// use
/// </summary>
public OtherValues OtherValues
{
get
{
return this.otherValues;
}
set
{
this.otherValues = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public RevocationValues()
{
this.crlValues = new CRLValues();
this.ocspValues = new OCSPValues();
this.otherValues = new OtherValues();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (this.crlValues != null && this.crlValues.HasChanged())
{
retVal = true;
}
if (this.ocspValues != null && this.ocspValues.HasChanged())
{
retVal = true;
}
if (this.otherValues != null && this.otherValues.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:CRLValues", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.crlValues = new CRLValues();
this.crlValues.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:OCSPValues", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.ocspValues = new OCSPValues();
this.ocspValues.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:OtherValues", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.otherValues = new OtherValues();
this.otherValues.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "RevocationValues", XadesSignedXml.XadesNamespaceUri);
if (this.id != null && this.id != "")
{
retVal.SetAttribute("Id", this.id);
}
if (this.crlValues != null && this.crlValues.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.crlValues.GetXml(), true));
}
if (this.ocspValues != null && this.ocspValues.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.ocspValues.GetXml(), true));
}
if (this.otherValues != null && this.otherValues.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.otherValues.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,131 @@
// SPUri.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// SPUri represents the URL where the copy of the Signature Policy may be
/// obtained. The class derives from SigPolicyQualifier.
/// </summary>
public class SPUri : SigPolicyQualifier
{
#region Private variables
private string uri;
#endregion
#region Public properties
/// <summary>
/// Uri for the sig policy qualifier
/// </summary>
public string Uri
{
get
{
return this.uri;
}
set
{
this.uri = value;
}
}
/// <summary>
/// Inherited generic element, not used in the SPUri class
/// </summary>
public override XmlElement AnyXmlElement
{
get
{
return null;
}
set
{
throw new CryptographicException("Setting AnyXmlElement on a SPUri is not supported");
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SPUri()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public override bool HasChanged()
{
bool retVal = false;
if (this.uri != null && this.uri != "")
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public override void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SPURI", xmlNamespaceManager);
this.uri = ((XmlElement)xmlNodeList.Item(0)).InnerText;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public override XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement bufferXmlElement;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SigPolicyQualifier", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement = creationXmlDocument.CreateElement("xades", "SPURI", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.uri;
retVal.AppendChild(creationXmlDocument.ImportNode(bufferXmlElement, true));
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,175 @@
// SPUserNotice.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// SPUserNotice element is intended for being displayed whenever the
/// signature is validated. The class derives from SigPolicyQualifier.
/// </summary>
public class SPUserNotice : SigPolicyQualifier
{
#region Private variables
private NoticeRef noticeRef;
private string explicitText;
#endregion
#region Public properties
/// <summary>
/// The NoticeRef element names an organization and identifies by
/// numbers a group of textual statements prepared by that organization,
/// so that the application could get the explicit notices from a notices file
/// </summary>
public NoticeRef NoticeRef
{
get
{
return this.noticeRef;
}
set
{
this.noticeRef = value;
}
}
/// <summary>
/// The ExplicitText element contains the text of the notice to be displayed
/// </summary>
public string ExplicitText
{
get
{
return this.explicitText;
}
set
{
this.explicitText = value;
}
}
/// <summary>
/// Inherited generic element, not used in the SPUserNotice class
/// </summary>
public override XmlElement AnyXmlElement
{
get
{
return null;
}
set
{
throw new CryptographicException("Setting AnyXmlElement on a SPUserNotice is not supported");
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SPUserNotice()
{
noticeRef = new NoticeRef();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public override bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.explicitText))
{
retVal = true;
}
if (this.noticeRef != null && this.noticeRef.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public override void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SPUserNotice/xsd:NoticeRef", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.noticeRef = new NoticeRef();
this.noticeRef.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:SPUserNotice/xsd:ExplicitText", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.explicitText = xmlNodeList.Item(0).InnerText;
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public override XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement bufferXmlElement;
XmlElement bufferXmlElement2;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SigPolicyQualifier", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement = creationXmlDocument.CreateElement("xades", "SPUserNotice", XadesSignedXml.XadesNamespaceUri);
if (this.noticeRef != null && this.noticeRef.HasChanged())
{
bufferXmlElement.AppendChild(creationXmlDocument.ImportNode(this.noticeRef.GetXml(), true));
}
if (!String.IsNullOrEmpty(this.explicitText))
{
bufferXmlElement2 = creationXmlDocument.CreateElement("xades", "ExplicitText", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement2.InnerText = this.explicitText;
bufferXmlElement.AppendChild(bufferXmlElement2);
}
retVal.AppendChild(creationXmlDocument.ImportNode(bufferXmlElement, true));
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,101 @@
// SigpolicyQualifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class can contain additional information qualifying the signature
/// policy identifier
/// </summary>
public class SigPolicyQualifier
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents a sig policy qualifier
/// </summary>
public virtual XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SigPolicyQualifier()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public virtual bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public virtual void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public virtual XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SigPolicyQualifier", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// SigPolicyQualifierCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class SigPolicyQualifierCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new SigPolicyQualifier this[int index]
{
get
{
return (SigPolicyQualifier)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public SigPolicyQualifier Add(SigPolicyQualifier objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public SigPolicyQualifier Add()
{
return this.Add(new SigPolicyQualifier());
}
}
}

View File

@ -0,0 +1,169 @@
// SigpolicyQualifiers.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a collection of SigPolicyQualifiers
/// </summary>
public class SigPolicyQualifiers
{
#region Private variables
private SigPolicyQualifierCollection sigPolicyQualifierCollection;
#endregion
#region Public properties
/// <summary>
/// A collection of sig policy qualifiers
/// </summary>
public SigPolicyQualifierCollection SigPolicyQualifierCollection
{
get
{
return this.sigPolicyQualifierCollection;
}
set
{
this.sigPolicyQualifierCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SigPolicyQualifiers()
{
this.sigPolicyQualifierCollection = new SigPolicyQualifierCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.sigPolicyQualifierCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
SPUri newSPUri;
SPUserNotice newSPUserNotice;
SigPolicyQualifier newSigPolicyQualifier;
IEnumerator enumerator;
XmlElement iterationXmlElement;
XmlElement subElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.sigPolicyQualifierCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyQualifier", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
subElement = (XmlElement)iterationXmlElement.SelectSingleNode("xsd:SPURI", xmlNamespaceManager);
if (subElement != null)
{
newSPUri = new SPUri();
newSPUri.LoadXml(iterationXmlElement);
this.sigPolicyQualifierCollection.Add(newSPUri);
}
else
{
subElement = (XmlElement)iterationXmlElement.SelectSingleNode("xsd:SPUserNotice", xmlNamespaceManager);
if (subElement != null)
{
newSPUserNotice = new SPUserNotice();
newSPUserNotice.LoadXml(iterationXmlElement);
this.sigPolicyQualifierCollection.Add(newSPUserNotice);
}
else
{
newSigPolicyQualifier = new SigPolicyQualifier();
newSigPolicyQualifier.LoadXml(iterationXmlElement);
this.sigPolicyQualifierCollection.Add(newSigPolicyQualifier);
}
}
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SigPolicyQualifiers", XadesSignedXml.XadesNamespaceUri);
if (this.sigPolicyQualifierCollection.Count > 0)
{
foreach (SigPolicyQualifier sigPolicyQualifier in this.sigPolicyQualifierCollection)
{
if (sigPolicyQualifier.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(sigPolicyQualifier.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,244 @@
// SignaturePolicyId.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The SignaturePolicyId element is an explicit and unambiguous identifier
/// of a Signature Policy together with a hash value of the signature
/// policy, so it can be verified that the policy selected by the signer is
/// the one being used by the verifier. An explicit signature policy has a
/// globally unique reference, which, in this way, is bound to an
/// electronic signature by the signer as part of the signature
/// calculation.
/// </summary>
public class SignaturePolicyId
{
#region Private variables
private ObjectIdentifier sigPolicyId;
private Transforms transforms;
private DigestAlgAndValueType sigPolicyHash;
private SigPolicyQualifiers sigPolicyQualifiers;
#endregion
#region Public properties
/// <summary>
/// The SigPolicyId element contains an identifier that uniquely
/// identifies a specific version of the signature policy
/// </summary>
public ObjectIdentifier SigPolicyId
{
get
{
return this.sigPolicyId;
}
set
{
this.sigPolicyId = value;
}
}
/// <summary>
/// The optional Transforms element can contain the transformations
/// performed on the signature policy document before computing its
/// hash
/// </summary>
public Transforms Transforms
{
get
{
return this.transforms;
}
set
{
this.transforms = value;
}
}
/// <summary>
/// The SigPolicyHash element contains the identifier of the hash
/// algorithm and the hash value of the signature policy
/// </summary>
public DigestAlgAndValueType SigPolicyHash
{
get
{
return this.sigPolicyHash;
}
set
{
this.sigPolicyHash = value;
}
}
/// <summary>
/// The SigPolicyQualifier element can contain additional information
/// qualifying the signature policy identifier
/// </summary>
public SigPolicyQualifiers SigPolicyQualifiers
{
get
{
return this.sigPolicyQualifiers;
}
set
{
this.sigPolicyQualifiers = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignaturePolicyId()
{
this.sigPolicyId = new ObjectIdentifier("SigPolicyId");
this.transforms = new Transforms();
this.sigPolicyHash = new DigestAlgAndValueType("SigPolicyHash");
this.sigPolicyQualifiers = new SigPolicyQualifiers();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.sigPolicyId != null && this.sigPolicyId.HasChanged())
{
retVal = true;
}
if (this.transforms != null && this.transforms.HasChanged())
{
retVal = true;
}
if (this.sigPolicyHash != null && this.sigPolicyHash.HasChanged())
{
retVal = true;
}
if (this.sigPolicyQualifiers != null && this.sigPolicyQualifiers.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyId", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("SigPolicyId missing");
}
this.sigPolicyId = new ObjectIdentifier("SigPolicyId");
this.sigPolicyId.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("ds:Transforms", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.transforms = new Transforms();
this.transforms.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyHash", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("SigPolicyHash missing");
}
this.sigPolicyHash = new DigestAlgAndValueType("SigPolicyHash");
this.sigPolicyHash.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyQualifiers", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.sigPolicyQualifiers = new SigPolicyQualifiers();
this.sigPolicyQualifiers.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignaturePolicyId", XadesSignedXml.XadesNamespaceUri);
if (this.sigPolicyId != null && this.sigPolicyId.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.sigPolicyId.GetXml(), true));
}
else
{
throw new CryptographicException("SigPolicyId element missing in SignaturePolicyId");
}
if (this.transforms != null && this.transforms.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.transforms.GetXml(), true));
}
if (this.sigPolicyHash != null && this.sigPolicyHash.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.sigPolicyHash.GetXml(), true));
}
else
{
throw new CryptographicException("SigPolicyHash element missing in SignaturePolicyId");
}
if (this.sigPolicyQualifiers != null && this.sigPolicyQualifiers.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.sigPolicyQualifiers.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,181 @@
// SignaturePolicyIdentifier.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains an identifier of a signature policy
/// </summary>
public class SignaturePolicyIdentifier
{
#region Private variables
private SignaturePolicyId signaturePolicyId;
private bool signaturePolicyImplied;
#endregion
#region Public properties
/// <summary>
/// The SignaturePolicyId element is an explicit and unambiguous identifier
/// of a Signature Policy together with a hash value of the signature
/// policy, so it can be verified that the policy selected by the signer is
/// the one being used by the verifier. An explicit signature policy has a
/// globally unique reference, which, in this way, is bound to an
/// electronic signature by the signer as part of the signature
/// calculation.
/// </summary>
public SignaturePolicyId SignaturePolicyId
{
get
{
return this.signaturePolicyId;
}
set
{
this.signaturePolicyId = value;
this.signaturePolicyImplied = false;
}
}
/// <summary>
/// The empty SignaturePolicyImplied element will appear when the
/// data object(s) being signed and other external data imply the
/// signature policy
/// </summary>
public bool SignaturePolicyImplied
{
get
{
return this.signaturePolicyImplied;
}
set
{
this.signaturePolicyImplied = value;
if (this.signaturePolicyImplied == true)
{
this.signaturePolicyId = null;
}
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignaturePolicyIdentifier()
{
this.signaturePolicyId = new SignaturePolicyId();
this.signaturePolicyImplied = false;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.signaturePolicyId != null && this.signaturePolicyId.HasChanged())
{
retVal = true;
}
if (this.signaturePolicyImplied)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyId", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.signaturePolicyId = new SignaturePolicyId();
this.signaturePolicyId.LoadXml((XmlElement)xmlNodeList.Item(0));
this.signaturePolicyImplied = false;
}
else
{
xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyImplied", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.signaturePolicyImplied = true;
this.signaturePolicyId = null;
}
else
{
throw new CryptographicException("SignaturePolicyId or SignaturePolicyImplied missing");
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignaturePolicyIdentifier", XadesSignedXml.XadesNamespaceUri);
if (this.signaturePolicyImplied)
{ //Append empty element as required
bufferXmlElement = creationXmlDocument.CreateElement("xades", "SignaturePolicyImplied", XadesSignedXml.XadesNamespaceUri);
retVal.AppendChild(bufferXmlElement);
}
else
{
if (this.signaturePolicyId != null && this.signaturePolicyId.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signaturePolicyId.GetXml(), true));
}
else
{
throw new CryptographicException("SignaturePolicyId or SignaturePolicyImplied missing in SignaturePolicyIdentifier");
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,228 @@
// SignatureProductionPlace.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// In some transactions the purported place where the signer was at the time
/// of signature creation may need to be indicated. In order to provide this
/// information a new property may be included in the signature.
/// This property specifies an address associated with the signer at a
/// particular geographical (e.g. city) location.
/// This is a signed property that qualifies the signer.
/// An XML electronic signature aligned with the present document MAY contain
/// at most one SignatureProductionPlace element.
/// </summary>
public class SignatureProductionPlace
{
#region Private variables
private string city;
private string stateOrProvince;
private string postalCode;
private string countryName;
#endregion
#region Public properties
/// <summary>
/// City where signature was produced
/// </summary>
public string City
{
get
{
return this.city;
}
set
{
this.city = value;
}
}
/// <summary>
/// State or province where signature was produced
/// </summary>
public string StateOrProvince
{
get
{
return this.stateOrProvince;
}
set
{
this.stateOrProvince = value;
}
}
/// <summary>
/// Postal code of place where signature was produced
/// </summary>
public string PostalCode
{
get
{
return this.postalCode;
}
set
{
this.postalCode = value;
}
}
/// <summary>
/// Country where signature was produced
/// </summary>
public string CountryName
{
get
{
return this.countryName;
}
set
{
this.countryName = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignatureProductionPlace()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.city))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.stateOrProvince))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.postalCode))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.countryName))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:City", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.city = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:PostalCode", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.postalCode = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:StateOrProvince", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.stateOrProvince = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:CountryName", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.countryName = xmlNodeList.Item(0).InnerText;
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignatureProductionPlace", XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.city))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "City", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.city;
retVal.AppendChild(bufferXmlElement);
}
if (!String.IsNullOrEmpty(this.stateOrProvince))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "StateOrProvince", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.stateOrProvince;
retVal.AppendChild(bufferXmlElement);
}
if (!String.IsNullOrEmpty(this.postalCode))
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "PostalCode", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.postalCode;
retVal.AppendChild(bufferXmlElement);
}
if (this.countryName != null && this.countryName != "")
{
bufferXmlElement = creationXmlDocument.CreateElement("xades", "CountryName", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = this.countryName;
retVal.AppendChild(bufferXmlElement);
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,63 @@
// SignatureTimeStampCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class SignatureTimeStampCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new TimeStamp this[int index]
{
get
{
return (TimeStamp)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public TimeStamp Add(TimeStamp objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <param name="tagName">Name of the tag when serializing into XML using GetXml()</param>
/// <returns>The newly created object that has been added to collection</returns>
public TimeStamp Add(string tagName)
{
return this.Add(new TimeStamp(tagName));
}
}
}

View File

@ -0,0 +1,323 @@
// SignedDataObjectProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The SignedDataObjectProperties element contains properties that qualify
/// some of the signed data objects
/// </summary>
public class SignedDataObjectProperties
{
#region Private variables
private DataObjectFormatCollection dataObjectFormatCollection;
private CommitmentTypeIndicationCollection commitmentTypeIndicationCollection;
private AllDataObjectsTimeStampCollection allDataObjectsTimeStampCollection;
private IndividualDataObjectsTimeStampCollection individualDataObjectsTimeStampCollection;
#endregion
#region Public properties
/// <summary>
/// Collection of signed data object formats
/// </summary>
public DataObjectFormatCollection DataObjectFormatCollection
{
get
{
return this.dataObjectFormatCollection;
}
set
{
this.dataObjectFormatCollection = value;
}
}
/// <summary>
/// Collection of commitment type indications
/// </summary>
public CommitmentTypeIndicationCollection CommitmentTypeIndicationCollection
{
get
{
return this.commitmentTypeIndicationCollection;
}
set
{
this.commitmentTypeIndicationCollection = value;
}
}
/// <summary>
/// Collection of all data object timestamps
/// </summary>
public AllDataObjectsTimeStampCollection AllDataObjectsTimeStampCollection
{
get
{
return this.allDataObjectsTimeStampCollection;
}
set
{
this.allDataObjectsTimeStampCollection = value;
}
}
/// <summary>
/// Collection of individual data object timestamps
/// </summary>
public IndividualDataObjectsTimeStampCollection IndividualDataObjectsTimeStampCollection
{
get
{
return this.individualDataObjectsTimeStampCollection;
}
set
{
this.individualDataObjectsTimeStampCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignedDataObjectProperties()
{
this.dataObjectFormatCollection = new DataObjectFormatCollection();
this.commitmentTypeIndicationCollection = new CommitmentTypeIndicationCollection();
this.allDataObjectsTimeStampCollection = new AllDataObjectsTimeStampCollection();
this.individualDataObjectsTimeStampCollection = new IndividualDataObjectsTimeStampCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.dataObjectFormatCollection.Count > 0)
{
retVal = true;
}
if (this.commitmentTypeIndicationCollection.Count > 0)
{
retVal = true;
}
if (this.allDataObjectsTimeStampCollection.Count > 0)
{
retVal = true;
}
if (this.individualDataObjectsTimeStampCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
DataObjectFormat newDataObjectFormat;
CommitmentTypeIndication newCommitmentTypeIndication;
TimeStamp newTimeStamp;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.dataObjectFormatCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:DataObjectFormat", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newDataObjectFormat = new DataObjectFormat();
newDataObjectFormat.LoadXml(iterationXmlElement);
this.dataObjectFormatCollection.Add(newDataObjectFormat);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
this.commitmentTypeIndicationCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:CommitmentTypeIndication", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCommitmentTypeIndication = new CommitmentTypeIndication();
newCommitmentTypeIndication.LoadXml(iterationXmlElement);
this.commitmentTypeIndicationCollection.Add(newCommitmentTypeIndication);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
this.allDataObjectsTimeStampCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:AllDataObjectsTimeStamp", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTimeStamp = new TimeStamp("AllDataObjectsTimeStamp");
newTimeStamp.LoadXml(iterationXmlElement);
this.allDataObjectsTimeStampCollection.Add(newTimeStamp);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
this.individualDataObjectsTimeStampCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:IndividualDataObjectsTimeStamp", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTimeStamp = new TimeStamp("IndividualDataObjectsTimeStamp");
newTimeStamp.LoadXml(iterationXmlElement);
this.individualDataObjectsTimeStampCollection.Add(newTimeStamp);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignedDataObjectProperties", XadesSignedXml.XadesNamespaceUri);
if (this.dataObjectFormatCollection.Count > 0)
{
foreach (DataObjectFormat dataObjectFormat in this.dataObjectFormatCollection)
{
if (dataObjectFormat.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(dataObjectFormat.GetXml(), true));
}
}
}
if (this.commitmentTypeIndicationCollection.Count > 0)
{
foreach (CommitmentTypeIndication commitmentTypeIndication in this.commitmentTypeIndicationCollection)
{
if (commitmentTypeIndication.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(commitmentTypeIndication.GetXml(), true));
}
}
}
if (this.allDataObjectsTimeStampCollection.Count > 0)
{
foreach (TimeStamp timeStamp in this.allDataObjectsTimeStampCollection)
{
if (timeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(timeStamp.GetXml(), true));
}
}
}
if (this.individualDataObjectsTimeStampCollection.Count > 0)
{
foreach (TimeStamp timeStamp in this.individualDataObjectsTimeStampCollection)
{
if (timeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(timeStamp.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,204 @@
// SignedProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The SignedProperties element contains a number of properties that are
/// collectively signed by the XMLDSIG signature
/// </summary>
public class SignedProperties
{
#region Constants
/// <summary>
/// Default value for the SignedProperties Id attribute
/// </summary>
public const string DefaultSignedPropertiesId = "SignedPropertiesId";
#endregion
#region Private variables
private string id;
private SignedSignatureProperties signedSignatureProperties;
private SignedDataObjectProperties signedDataObjectProperties;
#endregion
#region Public properties
/// <summary>
/// This Id is used to be able to point the signature reference to this
/// element. It is initialized by default.
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// The properties that qualify the signature itself or the signer are
/// included as content of the SignedSignatureProperties element
/// </summary>
public SignedSignatureProperties SignedSignatureProperties
{
get
{
return this.signedSignatureProperties;
}
set
{
this.signedSignatureProperties = value;
}
}
/// <summary>
/// The SignedDataObjectProperties element contains properties that qualify
/// some of the signed data objects
/// </summary>
public SignedDataObjectProperties SignedDataObjectProperties
{
get
{
return this.signedDataObjectProperties;
}
set
{
this.signedDataObjectProperties = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignedProperties()
{
this.id = DefaultSignedPropertiesId;
this.signedSignatureProperties = new SignedSignatureProperties();
this.signedDataObjectProperties = new SignedDataObjectProperties();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (this.signedSignatureProperties != null && this.signedSignatureProperties.HasChanged())
{
retVal = true;
}
if (this.signedDataObjectProperties != null && this.signedDataObjectProperties.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SignedSignatureProperties", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("SignedSignatureProperties missing");
}
this.signedSignatureProperties = new SignedSignatureProperties();
this.signedSignatureProperties.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:SignedDataObjectProperties", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.signedDataObjectProperties = new SignedDataObjectProperties();
this.signedDataObjectProperties.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignedProperties", XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.id))
{
retVal.SetAttribute("Id", this.id);
}
if (this.signedSignatureProperties != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signedSignatureProperties.GetXml(), true));
}
else
{
throw new CryptographicException("SignedSignatureProperties should not be null");
}
if (this.signedDataObjectProperties != null && this.signedDataObjectProperties.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signedDataObjectProperties.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,300 @@
// SignedSignatureProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
//
using System;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The properties that qualify the signature itself or the signer are
/// included as content of the SignedSignatureProperties element
/// </summary>
public class SignedSignatureProperties
{
#region Private variables
private DateTimeOffset signingTime;
private SigningCertificate signingCertificate;
private SignaturePolicyIdentifier signaturePolicyIdentifier;
private SignatureProductionPlace signatureProductionPlace;
private SignerRole signerRole;
#endregion
#region Public properties
/// <summary>
/// The signing time property specifies the time at which the signer
/// performed the signing process. This is a signed property that
/// qualifies the whole signature. An XML electronic signature aligned
/// with the present document MUST contain exactly one SigningTime element.
/// </summary>
public DateTimeOffset SigningTime
{
get
{
return this.signingTime;
}
set
{
this.signingTime = value;
}
}
/// <summary>
/// The SigningCertificate property is designed to prevent the simple
/// substitution of the certificate. This property contains references
/// to certificates and digest values computed on them. The certificate
/// used to verify the signature shall be identified in the sequence;
/// the signature policy may mandate other certificates be present,
/// that may include all the certificates up to the point of trust.
/// This is a signed property that qualifies the signature. An XML
/// electronic signature aligned with the present document MUST contain
/// exactly one SigningCertificate.
/// </summary>
public SigningCertificate SigningCertificate
{
get
{
return this.signingCertificate;
}
set
{
this.signingCertificate = value;
}
}
/// <summary>
/// The signature policy is a set of rules for the creation and
/// validation of an electronic signature, under which the signature
/// can be determined to be valid. A given legal/contractual context
/// may recognize a particular signature policy as meeting its
/// requirements.
/// An XML electronic signature aligned with the present document MUST
/// contain exactly one SignaturePolicyIdentifier element.
/// </summary>
public SignaturePolicyIdentifier SignaturePolicyIdentifier
{
get
{
return this.signaturePolicyIdentifier;
}
set
{
this.signaturePolicyIdentifier = value;
}
}
/// <summary>
/// In some transactions the purported place where the signer was at the time
/// of signature creation may need to be indicated. In order to provide this
/// information a new property may be included in the signature.
/// This property specifies an address associated with the signer at a
/// particular geographical (e.g. city) location.
/// This is a signed property that qualifies the signer.
/// An XML electronic signature aligned with the present document MAY contain
/// at most one SignatureProductionPlace element.
/// </summary>
public SignatureProductionPlace SignatureProductionPlace
{
get
{
return this.signatureProductionPlace;
}
set
{
this.signatureProductionPlace = value;
}
}
/// <summary>
/// According to what has been stated in the Introduction clause, an
/// electronic signature produced in accordance with the present document
/// incorporates: "a commitment that has been explicitly endorsed under a
/// signature policy, at a given time, by a signer under an identifier,
/// e.g. a name or a pseudonym, and optionally a role".
/// While the name of the signer is important, the position of the signer
/// within a company or an organization can be even more important. Some
/// contracts may only be valid if signed by a user in a particular role,
/// e.g. a Sales Director. In many cases who the sales Director really is,
/// is not that important but being sure that the signer is empowered by his
/// company to be the Sales Director is fundamental.
/// </summary>
public SignerRole SignerRole
{
get
{
return this.signerRole;
}
set
{
this.signerRole = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignedSignatureProperties()
{
this.signingTime = DateTimeOffset.MinValue;
this.signingCertificate = new SigningCertificate();
//this.signaturePolicyIdentifier = new SignaturePolicyIdentifier();
this.signatureProductionPlace = new SignatureProductionPlace();
this.signerRole = new SignerRole();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{ //Should always be serialized
bool retVal = false;
retVal = true;
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:SigningTime", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("SigningTime missing");
}
this.signingTime = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Utc);
xmlNodeList = xmlElement.SelectNodes("xsd:SigningCertificate", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("SigningCertificate missing");
}
this.signingCertificate = new SigningCertificate();
this.signingCertificate.LoadXml((XmlElement)xmlNodeList.Item(0));
xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyIdentifier", xmlNamespaceManager);
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//if (xmlNodeList.Count == 0)
//{
// throw new CryptographicException("SignaturePolicyIdentifier missing");
//}
//this.signaturePolicyIdentifier = new SignaturePolicyIdentifier();
//this.signaturePolicyIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
if (xmlNodeList.Count != 0)
{
this.signaturePolicyIdentifier = new SignaturePolicyIdentifier();
this.signaturePolicyIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:SignatureProductionPlace", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.signatureProductionPlace = new SignatureProductionPlace();
this.signatureProductionPlace.LoadXml((XmlElement)xmlNodeList.Item(0));
}
else
{
this.signatureProductionPlace = null;
}
xmlNodeList = xmlElement.SelectNodes("xsd:SignerRole", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.signerRole = new SignerRole();
this.signerRole.LoadXml((XmlElement)xmlNodeList.Item(0));
}
else
{
this.signerRole = null;
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignedSignatureProperties", XadesSignedXml.XadesNamespaceUri);
if (this.signingTime == DateTimeOffset.MinValue)
{
this.signingTime = DateTime.Now;
}
bufferXmlElement = creationXmlDocument.CreateElement("xades", "SigningTime", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.InnerText = signingTime.ToString(SigningTimeFormat);
retVal.AppendChild(bufferXmlElement);
if (this.signingCertificate != null && this.signingCertificate.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signingCertificate.GetXml(), true));
}
else
{
throw new CryptographicException("SigningCertificate element missing in SignedSignatureProperties");
}
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//if (this.signaturePolicyIdentifier != null && this.signaturePolicyIdentifier.HasChanged())
//{
// retVal.AppendChild(creationXmlDocument.ImportNode(this.signaturePolicyIdentifier.GetXml(), true));
//}
//else
//{
// throw new CryptographicException("SignaturePolicyIdentifier element missing in SignedSignatureProperties");
//}
if (this.signatureProductionPlace != null && this.signatureProductionPlace.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signatureProductionPlace.GetXml(), true));
}
if (this.signerRole != null && this.signerRole.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.signerRole.GetXml(), true));
}
return retVal;
}
#endregion
private const string SigningTimeFormat = "yyyy-MM-ddTHH:mm:ss.fffzzz";
}
}

View File

@ -0,0 +1,167 @@
// SignerRole.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// According to what has been stated in the Introduction clause, an
/// electronic signature produced in accordance with the present document
/// incorporates: "a commitment that has been explicitly endorsed under a
/// signature policy, at a given time, by a signer under an identifier,
/// e.g. a name or a pseudonym, and optionally a role".
/// While the name of the signer is important, the position of the signer
/// within a company or an organization can be even more important. Some
/// contracts may only be valid if signed by a user in a particular role,
/// e.g. a Sales Director. In many cases who the sales Director really is,
/// is not that important but being sure that the signer is empowered by his
/// company to be the Sales Director is fundamental.
/// </summary>
public class SignerRole
{
#region Private variables
private ClaimedRoles claimedRoles;
private CertifiedRoles certifiedRoles;
#endregion
#region Public properties
/// <summary>
/// The ClaimedRoles element contains a sequence of roles claimed by
/// the signer but not certified. Additional contents types may be
/// defined on a domain application basis and be part of this element.
/// The namespaces given to the corresponding XML schemas will allow
/// their unambiguous identification in the case these roles use XML.
/// </summary>
public ClaimedRoles ClaimedRoles
{
get
{
return this.claimedRoles;
}
set
{
this.claimedRoles = value;
}
}
/// <summary>
/// The CertifiedRoles element contains one or more wrapped attribute
/// certificates for the signer
/// </summary>
public CertifiedRoles CertifiedRoles
{
get
{
return this.certifiedRoles;
}
set
{
this.certifiedRoles = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SignerRole()
{
this.claimedRoles = new ClaimedRoles();
this.certifiedRoles = new CertifiedRoles();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.claimedRoles != null && this.claimedRoles.HasChanged())
{
retVal = true;
}
if (this.certifiedRoles != null && this.certifiedRoles.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:ClaimedRoles", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.claimedRoles = new ClaimedRoles();
this.claimedRoles.LoadXml((XmlElement)xmlNodeList.Item(0));
}
xmlNodeList = xmlElement.SelectNodes("xsd:CertifiedRoles", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.certifiedRoles = new CertifiedRoles();
this.certifiedRoles.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SignerRole", XadesSignedXml.XadesNamespaceUri);
if (this.claimedRoles != null && this.claimedRoles.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.claimedRoles.GetXml(), true));
}
if (this.certifiedRoles != null && this.certifiedRoles.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.certifiedRoles.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,147 @@
// SigningCertificate.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
//
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class has as purpose to provide the simple substitution of the
/// certificate. It contains references to certificates and digest values
/// computed on them.
/// </summary>
public class SigningCertificate
{
#region Private variables
private CertCollection certCollection;
#endregion
#region Public properties
/// <summary>
/// A collection of certs
/// </summary>
public CertCollection CertCollection
{
get
{
return this.certCollection;
}
set
{
this.certCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public SigningCertificate()
{
this.certCollection = new CertCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
return true; //Should always be considered dirty
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
Cert newCert;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.certCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:Cert", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newCert = new Cert();
newCert.LoadXml(iterationXmlElement);
this.certCollection.Add(newCert);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "SigningCertificate", XadesSignedXml.XadesNamespaceUri);
if (this.certCollection.Count > 0)
{
foreach (Cert cert in this.certCollection)
{
if (cert.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(cert.GetXml(), true));
}
}
}
else
{
throw new CryptographicException("SigningCertificate.Certcollection should have count > 0");
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,270 @@
// TimeStamp.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
//
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains timestamp information
/// </summary>
public class TimeStamp
{
#region Private variables
private string tagName;
private HashDataInfoCollection hashDataInfoCollection;
private EncapsulatedPKIData encapsulatedTimeStamp;
private XMLTimeStamp xmlTimeStamp;
#endregion
#region Public properties
/// <summary>
/// The name of the element when serializing
/// </summary>
public string TagName
{
get
{
return this.tagName;
}
set
{
this.tagName = value;
}
}
/// <summary>
/// A collection of hash data infos
/// </summary>
public HashDataInfoCollection HashDataInfoCollection
{
get
{
return this.hashDataInfoCollection;
}
set
{
this.hashDataInfoCollection = value;
}
}
/// <summary>
/// The time-stamp generated by a TSA encoded as an ASN.1 data
/// object
/// </summary>
public EncapsulatedPKIData EncapsulatedTimeStamp
{
get
{
return this.encapsulatedTimeStamp;
}
set
{
this.encapsulatedTimeStamp = value;
if (this.encapsulatedTimeStamp != null)
{
this.xmlTimeStamp = null;
}
}
}
/// <summary>
/// The time-stamp generated by a TSA encoded as a generic XML
/// timestamp
/// </summary>
public XMLTimeStamp XMLTimeStamp
{
get
{
return this.xmlTimeStamp;
}
set
{
this.xmlTimeStamp = value;
if (this.xmlTimeStamp != null)
{
this.encapsulatedTimeStamp = null;
}
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public TimeStamp()
{
this.hashDataInfoCollection = new HashDataInfoCollection();
this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
this.xmlTimeStamp = null;
}
/// <summary>
/// Constructor with TagName
/// </summary>
/// <param name="tagName">Name of the tag when serializing with GetXml</param>
public TimeStamp(string tagName) : this()
{
this.tagName = tagName;
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.hashDataInfoCollection.Count > 0)
{
retVal = true;
}
if (this.encapsulatedTimeStamp != null && this.encapsulatedTimeStamp.HasChanged())
{
retVal = true;
}
if (this.xmlTimeStamp != null && this.xmlTimeStamp.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
HashDataInfo newHashDataInfo;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.hashDataInfoCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:HashDataInfo", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newHashDataInfo = new HashDataInfo();
newHashDataInfo.LoadXml(iterationXmlElement);
this.hashDataInfoCollection.Add(newHashDataInfo);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
xmlNodeList = xmlElement.SelectNodes("xsd:EncapsulatedTimeStamp", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
this.xmlTimeStamp = null;
}
else
{
xmlNodeList = xmlElement.SelectNodes("xsd:XMLTimeStamp", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.xmlTimeStamp = new XMLTimeStamp();
this.xmlTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
this.encapsulatedTimeStamp = null;
}
else
{
throw new CryptographicException("EncapsulatedTimeStamp or XMLTimeStamp missing");
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", this.tagName, XadesSignedXml.XadesNamespaceUri);
if (this.hashDataInfoCollection.Count > 0)
{
foreach (HashDataInfo hashDataInfo in this.hashDataInfoCollection)
{
if (hashDataInfo.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(hashDataInfo.GetXml(), true));
}
}
}
else
{
throw new CryptographicException("HashDataInfoCollection is empty. TimeStamp needs at least one HashDataInfo element");
}
if (this.encapsulatedTimeStamp != null && this.encapsulatedTimeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.encapsulatedTimeStamp.GetXml(), true));
}
else
{
if (this.xmlTimeStamp != null && this.xmlTimeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.xmlTimeStamp.GetXml(), true));
}
else
{
throw new CryptographicException("EncapsulatedTimeStamp or XMLTimeStamp element missing");
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,158 @@
// Transform.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The Transform element contains a single transformation
/// </summary>
public class Transform
{
#region Private variables
private string algorithm;
private string xpath;
#endregion
#region Public properties
/// <summary>
/// Algorithm of the transformation
/// </summary>
public string Algorithm
{
get
{
return this.algorithm;
}
set
{
this.algorithm = value;
}
}
/// <summary>
/// XPath of the transformation
/// </summary>
public string XPath
{
get
{
return this.xpath;
}
set
{
this.xpath = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public Transform()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.algorithm))
{
retVal = true;
}
if (!String.IsNullOrEmpty(this.xpath))
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Algorithm"))
{
this.algorithm = xmlElement.GetAttribute("Algorithm");
}
else
{
this.algorithm = "";
}
xmlNodeList = xmlElement.SelectNodes("XPath");
if (xmlNodeList.Count != 0)
{
this.xpath = xmlNodeList.Item(0).InnerText;
}
else
{
this.xpath = "";
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("ds", "Transform", SignedXml.XmlDsigNamespaceUrl);
if (this.algorithm != null)
{
retVal.SetAttribute("Algorithm", this.algorithm);
}
else
{
retVal.SetAttribute("Algorithm", "");
}
if (this.xpath != null && this.xpath != "")
{
bufferXmlElement = creationXmlDocument.CreateElement("ds", "XPath", SignedXml.XmlDsigNamespaceUrl);
bufferXmlElement.InnerText = this.xpath;
retVal.AppendChild(bufferXmlElement);
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// TransformCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class TransformCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new Transform this[int index]
{
get
{
return (Transform)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public Transform Add(Transform objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public Transform Add()
{
return this.Add(new Transform());
}
}
}

View File

@ -0,0 +1,147 @@
// Transforms.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The Transforms element contains a collection of transformations
/// </summary>
public class Transforms
{
#region Private variables
private TransformCollection transformCollection;
#endregion
#region Public properties
/// <summary>
/// A collection of transforms
/// </summary>
public TransformCollection TransformCollection
{
get
{
return this.transformCollection;
}
set
{
this.transformCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public Transforms()
{
this.transformCollection = new TransformCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.transformCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
Transform newTransform;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
this.transformCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("ds:Transform", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTransform = new Transform();
newTransform.LoadXml(iterationXmlElement);
this.transformCollection.Add(newTransform);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "Transforms", XadesSignedXml.XadesNamespaceUri);
if (this.transformCollection.Count > 0)
{
foreach (Transform transform in this.transformCollection)
{
if (transform.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(transform.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,148 @@
// UnsignedDataObjectProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
//
using System;
using System.Collections;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The UnsignedDataObjectProperties element may contain properties that
/// qualify some of the signed data objects
/// </summary>
public class UnsignedDataObjectProperties
{
#region Private variables
private UnsignedDataObjectPropertyCollection unsignedDataObjectPropertyCollection;
#endregion
#region Public properties
/// <summary>
/// A collection of unsigned data object properties
/// </summary>
public UnsignedDataObjectPropertyCollection UnsignedDataObjectPropertyCollection
{
get
{
return this.unsignedDataObjectPropertyCollection;
}
set
{
this.unsignedDataObjectPropertyCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public UnsignedDataObjectProperties()
{
this.unsignedDataObjectPropertyCollection = new UnsignedDataObjectPropertyCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.unsignedDataObjectPropertyCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
UnsignedDataObjectProperty newUnsignedDataObjectProperty;
IEnumerator enumerator;
XmlElement iterationXmlElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.unsignedDataObjectPropertyCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:UnsignedDataObjectProperty", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newUnsignedDataObjectProperty = new UnsignedDataObjectProperty();
newUnsignedDataObjectProperty.LoadXml(iterationXmlElement);
this.unsignedDataObjectPropertyCollection.Add(newUnsignedDataObjectProperty);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "UnsignedDataObjectProperties", XadesSignedXml.XadesNamespaceUri);
if (this.unsignedDataObjectPropertyCollection.Count > 0)
{
foreach (UnsignedDataObjectProperty unsignedDataObjectProperty in this.unsignedDataObjectPropertyCollection)
{
if (unsignedDataObjectProperty.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(unsignedDataObjectProperty.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,104 @@
// UnsignedDataObjectProperty.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains properties that qualify some of the signed data
/// objects. The signature generated by the signer does not cover the content
/// of this element.
/// This information is added for the shake of completeness and to cope with
/// potential future needs for inclusion of such kind of properties.
/// </summary>
public class UnsignedDataObjectProperty
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents an unsigned data object
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public UnsignedDataObjectProperty()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "UnsignedDataObjectProperty", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,62 @@
// UnsignedDataObjectPropertyCollection.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Collections;
namespace Microsoft.Xades
{
/// <summary>
/// Collection class that derives from ArrayList. It provides the minimally
/// required functionality to add instances of typed classes and obtain typed
/// elements through a custom indexer.
/// </summary>
public class UnsignedDataObjectPropertyCollection : ArrayList
{
/// <summary>
/// New typed indexer for the collection
/// </summary>
/// <param name="index">Index of the object to retrieve from collection</param>
public new UnsignedDataObjectProperty this[int index]
{
get
{
return (UnsignedDataObjectProperty)base[index];
}
set
{
base[index] = value;
}
}
/// <summary>
/// Add typed object to the collection
/// </summary>
/// <param name="objectToAdd">Typed object to be added to collection</param>
/// <returns>The object that has been added to collection</returns>
public UnsignedDataObjectProperty Add(UnsignedDataObjectProperty objectToAdd)
{
base.Add(objectToAdd);
return objectToAdd;
}
/// <summary>
/// Add new typed object to the collection
/// </summary>
/// <returns>The newly created object that has been added to collection</returns>
public UnsignedDataObjectProperty Add()
{
return this.Add(new UnsignedDataObjectProperty());
}
}
}

View File

@ -0,0 +1,189 @@
// UnsignedProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// The UnsignedProperties element contains a number of properties that are
/// not signed by the XMLDSIG signature
/// </summary>
public class UnsignedProperties
{
#region Private variables
private string id;
private UnsignedSignatureProperties unsignedSignatureProperties;
private UnsignedDataObjectProperties unsignedDataObjectProperties;
#endregion
#region Public properties
/// <summary>
/// The optional Id attribute can be used to make a reference to the
/// UnsignedProperties element
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// UnsignedSignatureProperties may contain properties that qualify XML
/// signature itself or the signer
/// </summary>
public UnsignedSignatureProperties UnsignedSignatureProperties
{
get
{
return this.unsignedSignatureProperties;
}
set
{
this.unsignedSignatureProperties = value;
}
}
/// <summary>
/// The UnsignedDataObjectProperties element may contain properties that
/// qualify some of the signed data objects
/// </summary>
public UnsignedDataObjectProperties UnsignedDataObjectProperties
{
get
{
return this.unsignedDataObjectProperties;
}
set
{
this.unsignedDataObjectProperties = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public UnsignedProperties()
{
this.UnsignedSignatureProperties = new UnsignedSignatureProperties();
this.unsignedDataObjectProperties = new UnsignedDataObjectProperties();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (!String.IsNullOrEmpty(this.id))
{
retVal = true;
}
if (this.unsignedSignatureProperties != null && this.unsignedSignatureProperties.HasChanged())
{
retVal = true;
}
if (this.unsignedDataObjectProperties != null && this.unsignedDataObjectProperties.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
/// <param name="counterSignedXmlElement">Element containing parent signature (needed if there are counter signatures)</param>
public void LoadXml(System.Xml.XmlElement xmlElement, XmlElement counterSignedXmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:UnsignedSignatureProperties", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.unsignedSignatureProperties = new UnsignedSignatureProperties();
this.unsignedSignatureProperties.LoadXml((XmlElement)xmlNodeList.Item(0), counterSignedXmlElement);
}
xmlNodeList = xmlElement.SelectNodes("xsd:UnsignedDataObjectProperties", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.unsignedDataObjectProperties = new UnsignedDataObjectProperties();
this.unsignedDataObjectProperties.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "UnsignedProperties", XadesSignedXml.XadesNamespaceUri);
if (!String.IsNullOrEmpty(this.id))
{
retVal.SetAttribute("Id", this.id);
}
if (this.unsignedSignatureProperties != null && this.unsignedSignatureProperties.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.unsignedSignatureProperties.GetXml(), true));
}
if (this.unsignedDataObjectProperties != null && this.unsignedDataObjectProperties.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.unsignedDataObjectProperties.GetXml(), true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,601 @@
// UnsignedSignatureProperties.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// UnsignedSignatureProperties may contain properties that qualify XML
/// signature itself or the signer
/// </summary>
public class UnsignedSignatureProperties
{
#region Private variables
private CounterSignatureCollection counterSignatureCollection;
private SignatureTimeStampCollection signatureTimeStampCollection;
private CompleteCertificateRefs completeCertificateRefs;
private CompleteRevocationRefs completeRevocationRefs;
private bool refsOnlyTimeStampFlag;
private SignatureTimeStampCollection sigAndRefsTimeStampCollection;
private SignatureTimeStampCollection refsOnlyTimeStampCollection;
private CertificateValues certificateValues;
private RevocationValues revocationValues;
private SignatureTimeStampCollection archiveTimeStampCollection;
#endregion
#region Public properties
/// <summary>
/// A collection of counter signatures
/// </summary>
public CounterSignatureCollection CounterSignatureCollection
{
get
{
return this.counterSignatureCollection;
}
set
{
this.counterSignatureCollection = value;
}
}
/// <summary>
/// A collection of signature timestamps
/// </summary>
public SignatureTimeStampCollection SignatureTimeStampCollection
{
get
{
return this.signatureTimeStampCollection;
}
set
{
this.signatureTimeStampCollection = value;
}
}
/// <summary>
/// This clause defines the XML element containing the sequence of
/// references to the full set of CA certificates that have been used
/// to validate the electronic signature up to (but not including) the
/// signer's certificate. This is an unsigned property that qualifies
/// the signature.
/// An XML electronic signature aligned with the present document MAY
/// contain at most one CompleteCertificateRefs element.
/// </summary>
public CompleteCertificateRefs CompleteCertificateRefs
{
get
{
return this.completeCertificateRefs;
}
set
{
this.completeCertificateRefs = value;
}
}
/// <summary>
/// This clause defines the XML element containing a full set of
/// references to the revocation data that have been used in the
/// validation of the signer and CA certificates.
/// This is an unsigned property that qualifies the signature.
/// The XML electronic signature aligned with the present document
/// MAY contain at most one CompleteRevocationRefs element.
/// </summary>
public CompleteRevocationRefs CompleteRevocationRefs
{
get
{
return this.completeRevocationRefs;
}
set
{
this.completeRevocationRefs = value;
}
}
/// <summary>
/// Flag indicating if the RefsOnlyTimeStamp element (or several) is
/// present (RefsOnlyTimeStampFlag = true). If one or more
/// sigAndRefsTimeStamps are present, RefsOnlyTimeStampFlag will be false.
/// </summary>
public bool RefsOnlyTimeStampFlag
{
get
{
return this.refsOnlyTimeStampFlag;
}
set
{
this.refsOnlyTimeStampFlag = value;
}
}
/// <summary>
/// A collection of sig and refs timestamps
/// </summary>
public SignatureTimeStampCollection SigAndRefsTimeStampCollection
{
get
{
return this.sigAndRefsTimeStampCollection;
}
set
{
this.sigAndRefsTimeStampCollection = value;
}
}
/// <summary>
/// A collection of refs only timestamps
/// </summary>
public SignatureTimeStampCollection RefsOnlyTimeStampCollection
{
get
{
return this.refsOnlyTimeStampCollection;
}
set
{
this.refsOnlyTimeStampCollection = value;
}
}
/// <summary>
/// Certificate values
/// </summary>
public CertificateValues CertificateValues
{
get
{
return this.certificateValues;
}
set
{
this.certificateValues = value;
}
}
/// <summary>
/// Revocation values
/// </summary>
public RevocationValues RevocationValues
{
get
{
return this.revocationValues;
}
set
{
this.revocationValues = value;
}
}
/// <summary>
/// A collection of signature timestamp
/// </summary>
public SignatureTimeStampCollection ArchiveTimeStampCollection
{
get
{
return this.archiveTimeStampCollection;
}
set
{
this.archiveTimeStampCollection = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public UnsignedSignatureProperties()
{
this.counterSignatureCollection = new CounterSignatureCollection();
this.signatureTimeStampCollection = new SignatureTimeStampCollection();
this.completeCertificateRefs = new CompleteCertificateRefs();
this.completeRevocationRefs = new CompleteRevocationRefs();
this.refsOnlyTimeStampFlag = false;
this.sigAndRefsTimeStampCollection = new SignatureTimeStampCollection();
this.refsOnlyTimeStampCollection = new SignatureTimeStampCollection();
this.certificateValues = new CertificateValues();
this.revocationValues = new RevocationValues();
this.archiveTimeStampCollection = new SignatureTimeStampCollection();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.counterSignatureCollection.Count > 0)
{
retVal = true;
}
if (this.signatureTimeStampCollection.Count > 0)
{
retVal = true;
}
if (this.completeCertificateRefs != null && this.completeCertificateRefs.HasChanged())
{
retVal = true;
}
if (this.completeRevocationRefs != null && this.completeRevocationRefs.HasChanged())
{
retVal = true;
}
if (this.sigAndRefsTimeStampCollection.Count > 0)
{
retVal = true;
}
if (this.refsOnlyTimeStampCollection.Count > 0)
{
retVal = true;
}
if (this.certificateValues != null && this.certificateValues.HasChanged())
{
retVal = true;
}
if (this.revocationValues != null && this.revocationValues.HasChanged())
{
retVal = true;
}
if (this.archiveTimeStampCollection.Count > 0)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
/// <param name="counterSignedXmlElement">Element containing parent signature (needed if there are counter signatures)</param>
public void LoadXml(System.Xml.XmlElement xmlElement, XmlElement counterSignedXmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
XadesSignedXml newXadesSignedXml;
TimeStamp newTimeStamp;
XmlElement counterSignatureElement;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
this.counterSignatureCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:CounterSignature", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
if (counterSignedXmlElement != null)
{
newXadesSignedXml = new XadesSignedXml(counterSignedXmlElement);
}
else
{
newXadesSignedXml = new XadesSignedXml();
}
counterSignatureElement = null;
for (int childNodeCounter = 0; (childNodeCounter < iterationXmlElement.ChildNodes.Count) && (counterSignatureElement == null); childNodeCounter++)
{
if (iterationXmlElement.ChildNodes[childNodeCounter] is XmlElement)
{
counterSignatureElement = (XmlElement)iterationXmlElement.ChildNodes[childNodeCounter];
}
}
if (counterSignatureElement != null)
{
newXadesSignedXml.LoadXml(counterSignatureElement);
this.counterSignatureCollection.Add(newXadesSignedXml);
}
else
{
throw new CryptographicException("CounterSignature element does not contain signature");
}
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
this.signatureTimeStampCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:SignatureTimeStamp", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTimeStamp = new TimeStamp("SignatureTimeStamp");
newTimeStamp.LoadXml(iterationXmlElement);
this.signatureTimeStampCollection.Add(newTimeStamp);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
xmlNodeList = xmlElement.SelectNodes("xsd:CompleteCertificateRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.completeCertificateRefs = new CompleteCertificateRefs();
this.completeCertificateRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
else
{
this.completeCertificateRefs = null;
}
xmlNodeList = xmlElement.SelectNodes("xsd:CompleteRevocationRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.CompleteRevocationRefs = new CompleteRevocationRefs();
this.CompleteRevocationRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
else
{
this.completeRevocationRefs = null;
}
this.sigAndRefsTimeStampCollection.Clear();
this.refsOnlyTimeStampCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:SigAndRefsTimeStamp", xmlNamespaceManager);
if (xmlNodeList.Count > 0)
{
this.refsOnlyTimeStampFlag = false;
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTimeStamp = new TimeStamp("SigAndRefsTimeStamp");
newTimeStamp.LoadXml(iterationXmlElement);
this.sigAndRefsTimeStampCollection.Add(newTimeStamp);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
else
{
xmlNodeList = xmlElement.SelectNodes("xsd:RefsOnlyTimeStamp", xmlNamespaceManager);
if (xmlNodeList.Count > 0)
{
this.refsOnlyTimeStampFlag = true;
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTimeStamp = new TimeStamp("RefsOnlyTimeStamp");
newTimeStamp.LoadXml(iterationXmlElement);
this.refsOnlyTimeStampCollection.Add(newTimeStamp);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
else
{
this.refsOnlyTimeStampFlag = false;
}
}
xmlNodeList = xmlElement.SelectNodes("xsd:CertificateValues", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.certificateValues = new CertificateValues();
this.certificateValues.LoadXml((XmlElement)xmlNodeList.Item(0));
}
else
{
this.certificateValues = null;
}
xmlNodeList = xmlElement.SelectNodes("xsd:RevocationValues", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.revocationValues = new RevocationValues();
this.revocationValues.LoadXml((XmlElement)xmlNodeList.Item(0));
}
else
{
this.revocationValues = null;
}
this.archiveTimeStampCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xsd:ArchiveTimeStamp", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newTimeStamp = new TimeStamp("ArchiveTimeStamp");
newTimeStamp.LoadXml(iterationXmlElement);
this.archiveTimeStampCollection.Add(newTimeStamp);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
XmlElement bufferXmlElement;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "UnsignedSignatureProperties", XadesSignedXml.XadesNamespaceUri);
if (this.counterSignatureCollection.Count > 0)
{
foreach (XadesSignedXml xadesSignedXml in this.counterSignatureCollection)
{
bufferXmlElement = creationXmlDocument.CreateElement("CounterSignature", XadesSignedXml.XadesNamespaceUri);
bufferXmlElement.AppendChild(creationXmlDocument.ImportNode(xadesSignedXml.GetXml(), true));
retVal.AppendChild(creationXmlDocument.ImportNode(bufferXmlElement, true));
}
}
if (this.signatureTimeStampCollection.Count > 0)
{
foreach (TimeStamp timeStamp in this.signatureTimeStampCollection)
{
if (timeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(timeStamp.GetXml(), true));
}
}
}
if (this.completeCertificateRefs != null && this.completeCertificateRefs.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.completeCertificateRefs.GetXml(), true));
}
if (this.completeRevocationRefs != null && this.completeRevocationRefs.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.completeRevocationRefs.GetXml(), true));
}
if (!this.refsOnlyTimeStampFlag)
{
foreach (TimeStamp timeStamp in this.sigAndRefsTimeStampCollection)
{
if (timeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(timeStamp.GetXml(), true));
}
}
}
else
{
foreach (TimeStamp timeStamp in this.refsOnlyTimeStampCollection)
{
if (timeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(timeStamp.GetXml(), true));
}
}
}
if (this.certificateValues != null && this.certificateValues.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.certificateValues.GetXml(), true));
}
if (this.revocationValues != null && this.revocationValues.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.revocationValues.GetXml(), true));
}
if (this.archiveTimeStampCollection.Count > 0)
{
foreach (TimeStamp timeStamp in this.archiveTimeStampCollection)
{
if (timeStamp.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(timeStamp.GetXml(), true));
}
}
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,466 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://uri.etsi.org/01903/v1.3.2#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://uri.etsi.org/01903/v1.3.2#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified">
<xsd:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
<!-- Start auxiliary types definitions: AnyType, ObjectIdentifierType,
EncapsulatedPKIDataType and containers for time-stamp tokens -->
<!-- Start AnyType -->
<xsd:element name="Any" type="AnyType"/>
<xsd:complexType name="AnyType" mixed="true">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:any namespace="##any" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##any"/>
</xsd:complexType>
<!-- End AnyType -->
<!-- Start ObjectIdentifierType-->
<xsd:element name="ObjectIdentifier" type="ObjectIdentifierType"/>
<xsd:complexType name="ObjectIdentifierType">
<xsd:sequence>
<xsd:element name="Identifier" type="IdentifierType"/>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="DocumentationReferences" type="DocumentationReferencesType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="IdentifierType">
<xsd:simpleContent>
<xsd:extension base="xsd:anyURI">
<xsd:attribute name="Qualifier" type="QualifierType" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="QualifierType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="OIDAsURI"/>
<xsd:enumeration value="OIDAsURN"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="DocumentationReferencesType">
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="DocumentationReference" type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>
<!-- End ObjectIdentifierType-->
<!-- Start EncapsulatedPKIDataType-->
<xsd:element name="EncapsulatedPKIData" type="EncapsulatedPKIDataType"/>
<xsd:complexType name="EncapsulatedPKIDataType">
<xsd:simpleContent>
<xsd:extension base="xsd:base64Binary">
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="Encoding" type="xsd:anyURI" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- End EncapsulatedPKIDataType -->
<!-- Start time-stamp containers types -->
<!-- Start GenericTimeStampType -->
<xsd:element name="Include" type="IncludeType"/>
<xsd:complexType name="IncludeType">
<xsd:attribute name="URI" type="xsd:anyURI" use="required"/>
<xsd:attribute name="referencedData" type="xsd:boolean" use="optional"/>
</xsd:complexType>
<xsd:element name="ReferenceInfo" type="ReferenceInfoType"/>
<xsd:complexType name="ReferenceInfoType">
<xsd:sequence>
<xsd:element ref="ds:DigestMethod"/>
<xsd:element ref="ds:DigestValue"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="GenericTimeStampType" abstract="true">
<xsd:sequence>
<xsd:choice minOccurs="0">
<xsd:element ref="Include" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="ReferenceInfo" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End GenericTimeStampType -->
<!-- Start XAdESTimeStampType -->
<xsd:element name="XAdESTimeStamp" type="XAdESTimeStampType"/>
<xsd:complexType name="XAdESTimeStampType">
<xsd:complexContent>
<xsd:restriction base="GenericTimeStampType">
<xsd:sequence>
<xsd:element ref="Include" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!-- End XAdESTimeStampType -->
<!-- Start OtherTimeStampType -->
<xsd:element name="OtherTimeStamp" type="OtherTimeStampType"/>
<xsd:complexType name="OtherTimeStampType">
<xsd:complexContent>
<xsd:restriction base="GenericTimeStampType">
<xsd:sequence>
<xsd:element ref="ReferenceInfo" maxOccurs="unbounded"/>
<xsd:element ref="ds:CanonicalizationMethod" minOccurs="0"/>
<xsd:choice>
<xsd:element name="EncapsulatedTimeStamp" type="EncapsulatedPKIDataType"/>
<xsd:element name="XMLTimeStamp" type="AnyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<!-- End OtherTimeStampType -->
<!-- End time-stamp containers types -->
<!-- End auxiliary types definitions-->
<!-- Start container types -->
<!-- Start QualifyingProperties -->
<xsd:element name="QualifyingProperties" type="QualifyingPropertiesType"/>
<xsd:complexType name="QualifyingPropertiesType">
<xsd:sequence>
<xsd:element name="SignedProperties" type="SignedPropertiesType" minOccurs="0"/>
<xsd:element name="UnsignedProperties" type="UnsignedPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Target" type="xsd:anyURI" use="required"/>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End QualifyingProperties -->
<!-- Start SignedProperties-->
<xsd:element name="SignedProperties" type="SignedPropertiesType"/>
<xsd:complexType name="SignedPropertiesType">
<xsd:sequence>
<xsd:element name="SignedSignatureProperties" type="SignedSignaturePropertiesType" minOccurs="0"/>
<xsd:element name="SignedDataObjectProperties" type="SignedDataObjectPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedProperties-->
<!-- Start UnsignedProperties-->
<xsd:element name="UnsignedProperties" type="UnsignedPropertiesType"/>
<xsd:complexType name="UnsignedPropertiesType">
<xsd:sequence>
<xsd:element name="UnsignedSignatureProperties" type="UnsignedSignaturePropertiesType" minOccurs="0"/>
<xsd:element name="UnsignedDataObjectProperties" type="UnsignedDataObjectPropertiesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedProperties-->
<!-- Start SignedSignatureProperties-->
<xsd:element name="SignedSignatureProperties" type="SignedSignaturePropertiesType"/>
<xsd:complexType name="SignedSignaturePropertiesType">
<xsd:sequence>
<xsd:element name="SigningTime" type="xsd:dateTime" minOccurs="0"/>
<xsd:element name="SigningCertificate" type="CertIDListType" minOccurs="0"/>
<xsd:element name="SignaturePolicyIdentifier" type="SignaturePolicyIdentifierType" minOccurs="0"/>
<xsd:element name="SignatureProductionPlace" type="SignatureProductionPlaceType" minOccurs="0"/>
<xsd:element name="SignerRole" type="SignerRoleType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedSignatureProperties-->
<!-- Start SignedDataObjectProperties-->
<xsd:element name="SignedDataObjectProperties" type="SignedDataObjectPropertiesType"/>
<xsd:complexType name="SignedDataObjectPropertiesType">
<xsd:sequence>
<xsd:element name="DataObjectFormat" type="DataObjectFormatType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="CommitmentTypeIndication" type="CommitmentTypeIndicationType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="AllDataObjectsTimeStamp" type="XAdESTimeStampType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="IndividualDataObjectsTimeStamp" type="XAdESTimeStampType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End SignedDataObjectProperties-->
<!-- Start UnsignedSignatureProperties-->
<xsd:element name="UnsignedSignatureProperties" type="UnsignedSignaturePropertiesType"/>
<xsd:complexType name="UnsignedSignaturePropertiesType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="CounterSignature" type="CounterSignatureType"/>
<xsd:element name="SignatureTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="CompleteCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="CompleteRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="AttributeCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="AttributeRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="SigAndRefsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="RefsOnlyTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="CertificateValues" type="CertificateValuesType"/>
<xsd:element name="RevocationValues" type="RevocationValuesType"/>
<xsd:element name="AttrAuthoritiesCertValues" type="CertificateValuesType"/>
<xsd:element name="AttributeRevocationValues" type="RevocationValuesType"/>
<xsd:element name="ArchiveTimeStamp" type="XAdESTimeStampType"/>
<xsd:any namespace="##other"/>
</xsd:choice>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedSignatureProperties-->
<!-- Start UnsignedDataObjectProperties-->
<xsd:element name="UnsignedDataObjectProperties" type="UnsignedDataObjectPropertiesType"/>
<xsd:complexType name="UnsignedDataObjectPropertiesType">
<xsd:sequence>
<xsd:element name="UnsignedDataObjectProperty" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End UnsignedDataObjectProperties-->
<!-- Start QualifyingPropertiesReference-->
<xsd:element name="QualifyingPropertiesReference" type="QualifyingPropertiesReferenceType"/>
<xsd:complexType name="QualifyingPropertiesReferenceType">
<xsd:attribute name="URI" type="xsd:anyURI" use="required"/>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End QualifyingPropertiesReference-->
<!-- End container types -->
<!-- Start SigningTime element -->
<xsd:element name="SigningTime" type="xsd:dateTime"/>
<!-- End SigningTime element -->
<!-- Start SigningCertificate -->
<xsd:element name="SigningCertificate" type="CertIDListType"/>
<xsd:complexType name="CertIDListType">
<xsd:sequence>
<xsd:element name="Cert" type="CertIDType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CertIDType">
<xsd:sequence>
<xsd:element name="CertDigest" type="DigestAlgAndValueType"/>
<xsd:element name="IssuerSerial" type="ds:X509IssuerSerialType"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="DigestAlgAndValueType">
<xsd:sequence>
<xsd:element ref="ds:DigestMethod"/>
<xsd:element ref="ds:DigestValue"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SigningCertificate -->
<!-- Start SignaturePolicyIdentifier -->
<xsd:element name="SignaturePolicyIdentifier" type="SignaturePolicyIdentifierType"/>
<xsd:complexType name="SignaturePolicyIdentifierType">
<xsd:choice>
<xsd:element name="SignaturePolicyId" type="SignaturePolicyIdType"/>
<xsd:element name="SignaturePolicyImplied"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="SignaturePolicyIdType">
<xsd:sequence>
<xsd:element name="SigPolicyId" type="ObjectIdentifierType"/>
<xsd:element ref="ds:Transforms" minOccurs="0"/>
<xsd:element name="SigPolicyHash" type="DigestAlgAndValueType"/>
<xsd:element name="SigPolicyQualifiers" type="SigPolicyQualifiersListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SigPolicyQualifiersListType">
<xsd:sequence>
<xsd:element name="SigPolicyQualifier" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SPURI" type="xsd:anyURI"/>
<xsd:element name="SPUserNotice" type="SPUserNoticeType"/>
<xsd:complexType name="SPUserNoticeType">
<xsd:sequence>
<xsd:element name="NoticeRef" type="NoticeReferenceType" minOccurs="0"/>
<xsd:element name="ExplicitText" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="NoticeReferenceType">
<xsd:sequence>
<xsd:element name="Organization" type="xsd:string"/>
<xsd:element name="NoticeNumbers" type="IntegerListType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="IntegerListType">
<xsd:sequence>
<xsd:element name="int" type="xsd:integer" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignaturePolicyIdentifier -->
<!-- Start CounterSignature -->
<xsd:element name="CounterSignature" type="CounterSignatureType"/>
<xsd:complexType name="CounterSignatureType">
<xsd:sequence>
<xsd:element ref="ds:Signature"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CounterSignature -->
<!-- Start DataObjectFormat -->
<xsd:element name="DataObjectFormat" type="DataObjectFormatType"/>
<xsd:complexType name="DataObjectFormatType">
<xsd:sequence>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="ObjectIdentifier" type="ObjectIdentifierType" minOccurs="0"/>
<xsd:element name="MimeType" type="xsd:string" minOccurs="0"/>
<xsd:element name="Encoding" type="xsd:anyURI" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="ObjectReference" type="xsd:anyURI" use="required"/>
</xsd:complexType>
<!-- End DataObjectFormat -->
<!-- Start CommitmentTypeIndication -->
<xsd:element name="CommitmentTypeIndication" type="CommitmentTypeIndicationType"/>
<xsd:complexType name="CommitmentTypeIndicationType">
<xsd:sequence>
<xsd:element name="CommitmentTypeId" type="ObjectIdentifierType"/>
<xsd:choice>
<xsd:element name="ObjectReference" type="xsd:anyURI" maxOccurs="unbounded"/>
<xsd:element name="AllSignedDataObjects"/>
</xsd:choice>
<xsd:element name="CommitmentTypeQualifiers" type="CommitmentTypeQualifiersListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CommitmentTypeQualifiersListType">
<xsd:sequence>
<xsd:element name="CommitmentTypeQualifier" type="AnyType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CommitmentTypeIndication -->
<!-- Start SignatureProductionPlace -->
<xsd:element name="SignatureProductionPlace" type="SignatureProductionPlaceType"/>
<xsd:complexType name="SignatureProductionPlaceType">
<xsd:sequence>
<xsd:element name="City" type="xsd:string" minOccurs="0"/>
<xsd:element name="StateOrProvince" type="xsd:string" minOccurs="0"/>
<xsd:element name="PostalCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="CountryName" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignatureProductionPlace -->
<!-- Start SignerRole -->
<xsd:element name="SignerRole" type="SignerRoleType"/>
<xsd:complexType name="SignerRoleType">
<xsd:sequence>
<xsd:element name="ClaimedRoles" type="ClaimedRolesListType" minOccurs="0"/>
<xsd:element name="CertifiedRoles" type="CertifiedRolesListType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ClaimedRolesListType">
<xsd:sequence>
<xsd:element name="ClaimedRole" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CertifiedRolesListType">
<xsd:sequence>
<xsd:element name="CertifiedRole" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End SignerRole -->
<xsd:element name="AllDataObjectsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="IndividualDataObjectsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="SignatureTimeStamp" type="XAdESTimeStampType"/>
<!-- Start CompleteCertificateRefs -->
<xsd:element name="CompleteCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:complexType name="CompleteCertificateRefsType">
<xsd:sequence>
<xsd:element name="CertRefs" type="CertIDListType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End CompleteCertificateRefs -->
<!-- Start CompleteRevocationRefs-->
<xsd:element name="CompleteRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:complexType name="CompleteRevocationRefsType">
<xsd:sequence>
<xsd:element name="CRLRefs" type="CRLRefsType" minOccurs="0"/>
<xsd:element name="OCSPRefs" type="OCSPRefsType" minOccurs="0"/>
<xsd:element name="OtherRefs" type="OtherCertStatusRefsType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CRLRefsType">
<xsd:sequence>
<xsd:element name="CRLRef" type="CRLRefType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CRLRefType">
<xsd:sequence>
<xsd:element name="DigestAlgAndValue" type="DigestAlgAndValueType"/>
<xsd:element name="CRLIdentifier" type="CRLIdentifierType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="CRLIdentifierType">
<xsd:sequence>
<xsd:element name="Issuer" type="xsd:string"/>
<xsd:element name="IssueTime" type="xsd:dateTime"/>
<xsd:element name="Number" type="xsd:integer" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="OCSPRefsType">
<xsd:sequence>
<xsd:element name="OCSPRef" type="OCSPRefType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OCSPRefType">
<xsd:sequence>
<xsd:element name="OCSPIdentifier" type="OCSPIdentifierType"/>
<xsd:element name="DigestAlgAndValue" type="DigestAlgAndValueType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ResponderIDType">
<xsd:choice>
<xsd:element name="ByName" type="xsd:string"/>
<xsd:element name="ByKey" type="xsd:base64Binary"/>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="OCSPIdentifierType">
<xsd:sequence>
<xsd:element name="ResponderID" type="ResponderIDType"/>
<xsd:element name="ProducedAt" type="xsd:dateTime"/>
</xsd:sequence>
<xsd:attribute name="URI" type="xsd:anyURI" use="optional"/>
</xsd:complexType>
<xsd:complexType name="OtherCertStatusRefsType">
<xsd:sequence>
<xsd:element name="OtherRef" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End CompleteRevocationRefs-->
<xsd:element name="AttributeCertificateRefs" type="CompleteCertificateRefsType"/>
<xsd:element name="AttributeRevocationRefs" type="CompleteRevocationRefsType"/>
<xsd:element name="SigAndRefsTimeStamp" type="XAdESTimeStampType"/>
<xsd:element name="RefsOnlyTimeStamp" type="XAdESTimeStampType"/>
<!-- Start CertificateValues -->
<xsd:element name="CertificateValues" type="CertificateValuesType"/>
<xsd:complexType name="CertificateValuesType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="EncapsulatedX509Certificate" type="EncapsulatedPKIDataType"/>
<xsd:element name="OtherCertificate" type="AnyType"/>
</xsd:choice>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<!-- End CertificateValues -->
<!-- Start RevocationValues-->
<xsd:element name="RevocationValues" type="RevocationValuesType"/>
<xsd:complexType name="RevocationValuesType">
<xsd:sequence>
<xsd:element name="CRLValues" type="CRLValuesType" minOccurs="0"/>
<xsd:element name="OCSPValues" type="OCSPValuesType" minOccurs="0"/>
<xsd:element name="OtherValues" type="OtherCertStatusValuesType" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="optional"/>
</xsd:complexType>
<xsd:complexType name="CRLValuesType">
<xsd:sequence>
<xsd:element name="EncapsulatedCRLValue" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OCSPValuesType">
<xsd:sequence>
<xsd:element name="EncapsulatedOCSPValue" type="EncapsulatedPKIDataType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OtherCertStatusValuesType">
<xsd:sequence>
<xsd:element name="OtherValue" type="AnyType" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!-- End RevocationValues-->
<xsd:element name="AttrAuthoritiesCertValues" type="CertificateValuesType"/>
<xsd:element name="AttributeRevocationValues" type="RevocationValuesType"/>
<xsd:element name="ArchiveTimeStamp" type="XAdESTimeStampType"/>
</xsd:schema>

View File

@ -0,0 +1,100 @@
// XMLTimeStamp.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class contains a timestamp encoded as XML
/// </summary>
public class XMLTimeStamp
{
#region Private variables
private XmlElement anyXmlElement;
#endregion
#region Public properties
/// <summary>
/// The generic XML element that represents an XML timestamp
/// </summary>
public XmlElement AnyXmlElement
{
get
{
return this.anyXmlElement;
}
set
{
this.anyXmlElement = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public XMLTimeStamp()
{
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.anyXmlElement != null)
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
this.anyXmlElement = xmlElement;
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("xades", "XMLTimeStamp", XadesSignedXml.XadesNamespaceUri);
if (this.anyXmlElement != null)
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.anyXmlElement, true));
}
return retVal;
}
#endregion
}
}

View File

@ -0,0 +1,164 @@
// XadesObject.cs
//
// XAdES Starter Kit for Microsoft .NET 3.5 (and above)
// 2010 Microsoft France
// Published under the CECILL-B Free Software license agreement.
// (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt)
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// THE ENTIRE RISK OF USE OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE
// AND INFORMATION REMAINS WITH THE USER.
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
namespace Microsoft.Xades
{
/// <summary>
/// This class represents the unique object of a XAdES signature that
/// contains all XAdES information
/// </summary>
public class XadesObject
{
#region Private variable
private string id;
private QualifyingProperties qualifyingProperties;
#endregion
#region Public properties
/// <summary>
/// Id attribute of the XAdES object
/// </summary>
public string Id
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
/// <summary>
/// The QualifyingProperties element acts as a container element for
/// all the qualifying information that should be added to an XML
/// signature
/// </summary>
public QualifyingProperties QualifyingProperties
{
get
{
return this.qualifyingProperties;
}
set
{
this.qualifyingProperties = value;
}
}
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public XadesObject()
{
this.qualifyingProperties = new QualifyingProperties();
}
#endregion
#region Public methods
/// <summary>
/// Check to see if something has changed in this instance and needs to be serialized
/// </summary>
/// <returns>Flag indicating if a member needs serialization</returns>
public bool HasChanged()
{
bool retVal = false;
if (this.id != null && this.id != "")
{
retVal = true;
}
if (this.qualifyingProperties != null && this.qualifyingProperties.HasChanged())
{
retVal = true;
}
return retVal;
}
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
/// <param name="counterSignedXmlElement">Element containing parent signature (needed if there are counter signatures)</param>
public void LoadXml(XmlElement xmlElement, XmlElement counterSignedXmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:QualifyingProperties", xmlNamespaceManager);
if (xmlNodeList.Count == 0)
{
throw new CryptographicException("QualifyingProperties missing");
}
this.qualifyingProperties = new QualifyingProperties();
this.qualifyingProperties.LoadXml((XmlElement)xmlNodeList.Item(0), counterSignedXmlElement);
xmlNodeList = xmlElement.SelectNodes("xsd:QualifyingPropertiesReference", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
throw new CryptographicException("Current implementation can't handle QualifyingPropertiesReference element");
}
}
/// <summary>
/// Returns the XML representation of the this object
/// </summary>
/// <returns>XML element containing the state of this object</returns>
public XmlElement GetXml()
{
XmlDocument creationXmlDocument;
XmlElement retVal;
creationXmlDocument = new XmlDocument();
retVal = creationXmlDocument.CreateElement("ds", "Object", SignedXml.XmlDsigNamespaceUrl);
if (this.id != null && this.id != "")
{
retVal.SetAttribute("Id", this.id);
}
if (this.qualifyingProperties != null && this.qualifyingProperties.HasChanged())
{
retVal.AppendChild(creationXmlDocument.ImportNode(this.qualifyingProperties.GetXml(), true));
}
return retVal;
}
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,309 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Schema for XML Signatures
http://www.w3.org/2000/09/xmldsig#
$Revision: 1.1 $ on $Date: 2002/02/08 20:32:26 $ by $Author: reagle $
Copyright 2001 The Internet Society and W3C (Massachusetts Institute
of Technology, Institut National de Recherche en Informatique et en
Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
This document is governed by the W3C Software License [1] as described
in the FAQ [2].
[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
targetNamespace="http://www.w3.org/2000/09/xmldsig#"
version="0.1" elementFormDefault="qualified">
<!-- Basic Types Defined for Signatures -->
<simpleType name="CryptoBinary">
<restriction base="base64Binary">
</restriction>
</simpleType>
<!-- Start Signature -->
<element name="Signature" type="ds:SignatureType"/>
<complexType name="SignatureType">
<sequence>
<element ref="ds:SignedInfo"/>
<element ref="ds:SignatureValue"/>
<element ref="ds:KeyInfo" minOccurs="0"/>
<element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="SignatureValue" type="ds:SignatureValueType"/>
<complexType name="SignatureValueType">
<simpleContent>
<extension base="base64Binary">
<attribute name="Id" type="ID" use="optional"/>
</extension>
</simpleContent>
</complexType>
<!-- Start SignedInfo -->
<element name="SignedInfo" type="ds:SignedInfoType"/>
<complexType name="SignedInfoType">
<sequence>
<element ref="ds:CanonicalizationMethod"/>
<element ref="ds:SignatureMethod"/>
<element ref="ds:Reference" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
<complexType name="CanonicalizationMethodType" mixed="true">
<sequence>
<any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) namespace -->
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<element name="SignatureMethod" type="ds:SignatureMethodType"/>
<complexType name="SignatureMethodType" mixed="true">
<sequence>
<element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
<any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) external namespace -->
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<!-- Start Reference -->
<element name="Reference" type="ds:ReferenceType"/>
<complexType name="ReferenceType">
<sequence>
<element ref="ds:Transforms" minOccurs="0"/>
<element ref="ds:DigestMethod"/>
<element ref="ds:DigestValue"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
<attribute name="URI" type="string" use="optional"/> <!-- <attribute name="URI" type="anyURI" use="optional"/> -->
<attribute name="Type" type="anyURI" use="optional"/>
</complexType>
<element name="Transforms" type="ds:TransformsType"/>
<complexType name="TransformsType">
<sequence>
<element ref="ds:Transform" maxOccurs="unbounded"/>
</sequence>
</complexType>
<element name="Transform" type="ds:TransformType"/>
<complexType name="TransformType" mixed="true">
<choice minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
<element name="XPath" type="string"/>
</choice>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<!-- End Reference -->
<element name="DigestMethod" type="ds:DigestMethodType"/>
<complexType name="DigestMethodType" mixed="true">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
<element name="DigestValue" type="ds:DigestValueType"/>
<simpleType name="DigestValueType">
<restriction base="base64Binary"/>
</simpleType>
<!-- End SignedInfo -->
<!-- Start KeyInfo -->
<element name="KeyInfo" type="ds:KeyInfoType"/>
<complexType name="KeyInfoType" mixed="true">
<choice maxOccurs="unbounded">
<element ref="ds:KeyName"/>
<element ref="ds:KeyValue"/>
<element ref="ds:RetrievalMethod"/>
<element ref="ds:X509Data"/>
<element ref="ds:PGPData"/>
<element ref="ds:SPKIData"/>
<element ref="ds:MgmtData"/>
<any processContents="lax" namespace="##other"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
</choice>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="KeyName" type="string"/>
<element name="MgmtData" type="string"/>
<element name="KeyValue" type="ds:KeyValueType"/>
<complexType name="KeyValueType" mixed="true">
<choice>
<element ref="ds:DSAKeyValue"/>
<element ref="ds:RSAKeyValue"/>
<any namespace="##other" processContents="lax"/>
</choice>
</complexType>
<element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
<complexType name="RetrievalMethodType">
<sequence>
<element ref="ds:Transforms" minOccurs="0"/>
</sequence>
<attribute name="URI" type="anyURI"/>
<attribute name="Type" type="anyURI" use="optional"/>
</complexType>
<!-- Start X509Data -->
<element name="X509Data" type="ds:X509DataType"/>
<complexType name="X509DataType">
<sequence maxOccurs="unbounded">
<choice>
<element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
<element name="X509SKI" type="base64Binary"/>
<element name="X509SubjectName" type="string"/>
<element name="X509Certificate" type="base64Binary"/>
<element name="X509CRL" type="base64Binary"/>
<any namespace="##other" processContents="lax"/>
</choice>
</sequence>
</complexType>
<complexType name="X509IssuerSerialType">
<sequence>
<element name="X509IssuerName" type="string"/>
<element name="X509SerialNumber" type="string"/> <!--Can be 128bit! <element name="X509SerialNumber" type="integer"/> -->
</sequence>
</complexType>
<!-- End X509Data -->
<!-- Begin PGPData -->
<element name="PGPData" type="ds:PGPDataType"/>
<complexType name="PGPDataType">
<choice>
<sequence>
<element name="PGPKeyID" type="base64Binary"/>
<element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<sequence>
<element name="PGPKeyPacket" type="base64Binary"/>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
</choice>
</complexType>
<!-- End PGPData -->
<!-- Begin SPKIData -->
<element name="SPKIData" type="ds:SPKIDataType"/>
<complexType name="SPKIDataType">
<sequence maxOccurs="unbounded">
<element name="SPKISexp" type="base64Binary"/>
<any namespace="##other" processContents="lax" minOccurs="0"/>
</sequence>
</complexType>
<!-- End SPKIData -->
<!-- End KeyInfo -->
<!-- Start Object (Manifest, SignatureProperty) -->
<element name="Object" type="ds:ObjectType"/>
<complexType name="ObjectType" mixed="true">
<sequence minOccurs="0" maxOccurs="unbounded">
<any namespace="##any" processContents="lax"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
<attribute name="MimeType" type="string" use="optional"/> <!-- add a grep facet -->
<attribute name="Encoding" type="anyURI" use="optional"/>
</complexType>
<element name="Manifest" type="ds:ManifestType"/>
<complexType name="ManifestType">
<sequence>
<element ref="ds:Reference" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
<complexType name="SignaturePropertiesType">
<sequence>
<element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
</sequence>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<element name="SignatureProperty" type="ds:SignaturePropertyType"/>
<complexType name="SignaturePropertyType" mixed="true">
<choice maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (1,unbounded) namespaces -->
</choice>
<attribute name="Target" type="anyURI" use="required"/>
<attribute name="Id" type="ID" use="optional"/>
</complexType>
<!-- End Object (Manifest, SignatureProperty) -->
<!-- Start Algorithm Parameters -->
<simpleType name="HMACOutputLengthType">
<restriction base="integer"/>
</simpleType>
<!-- Start KeyValue Element-types -->
<element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
<complexType name="DSAKeyValueType">
<sequence>
<sequence minOccurs="0">
<element name="P" type="ds:CryptoBinary"/>
<element name="Q" type="ds:CryptoBinary"/>
</sequence>
<element name="G" type="ds:CryptoBinary" minOccurs="0"/>
<element name="Y" type="ds:CryptoBinary"/>
<element name="J" type="ds:CryptoBinary" minOccurs="0"/>
<sequence minOccurs="0">
<element name="Seed" type="ds:CryptoBinary"/>
<element name="PgenCounter" type="ds:CryptoBinary"/>
</sequence>
</sequence>
</complexType>
<element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
<complexType name="RSAKeyValueType">
<sequence>
<element name="Modulus" type="ds:CryptoBinary"/>
<element name="Exponent" type="ds:CryptoBinary"/>
</sequence>
</complexType>
<!-- End KeyValue Element-types -->
<!-- End Signature -->
</schema>