2 // EncryptionProperty.cs - EncryptionProperty implementation for XML Encryption
3 // http://www.w3.org/2001/04/xmlenc#sec-EncryptionProperty
6 // Tim Coleman (tim@timcoleman.com)
8 // Copyright (C) Tim Coleman, 2004
14 namespace System.Security.Cryptography.Xml {
15 public sealed class EncryptionProperty {
27 public EncryptionProperty ()
31 public EncryptionProperty (XmlElement elemProp)
36 #endregion // Constructors
44 public XmlElement PropertyElement {
45 get { return elemProp; }
46 set { LoadXml (value); }
49 public string Target {
50 get { return target; }
53 #endregion // Properties
57 public XmlElement GetXml ()
59 return GetXml (new XmlDocument ());
62 internal XmlElement GetXml (XmlDocument document)
64 XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptionProperty, EncryptedXml.XmlEncNamespaceUrl);
67 xel.SetAttribute (XmlEncryption.AttributeNames.Id, Id);
69 xel.SetAttribute (XmlEncryption.AttributeNames.Target, Target);
74 public void LoadXml (XmlElement value)
77 throw new ArgumentNullException ("value");
79 if ((value.LocalName != XmlEncryption.ElementNames.EncryptionProperty) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
80 throw new CryptographicException ("Malformed EncryptionProperty element.");
82 if (value.HasAttribute (XmlEncryption.AttributeNames.Id))
83 this.id = value.Attributes [XmlEncryption.AttributeNames.Id].Value;
84 if (value.HasAttribute (XmlEncryption.AttributeNames.Target))
85 this.target = value.Attributes [XmlEncryption.AttributeNames.Target].Value;