1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.xml.encryption.impl;
18
19 import java.util.Map.Entry;
20
21 import javax.xml.namespace.QName;
22
23 import org.opensaml.xml.Configuration;
24 import org.opensaml.xml.XMLObject;
25 import org.opensaml.xml.encryption.EncryptionProperty;
26 import org.opensaml.xml.io.MarshallingException;
27 import org.opensaml.xml.util.XMLHelper;
28 import org.w3c.dom.Attr;
29 import org.w3c.dom.Element;
30
31
32
33
34 public class EncryptionPropertyMarshaller extends AbstractXMLEncryptionMarshaller {
35
36
37 protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
38 EncryptionProperty ep = (EncryptionProperty) xmlObject;
39
40 if (ep.getID() != null) {
41 domElement.setAttributeNS(null, EncryptionProperty.ID_ATTRIB_NAME, ep.getID());
42 domElement.setIdAttributeNS(null, EncryptionProperty.ID_ATTRIB_NAME, true);
43 }
44 if (ep.getTarget() != null) {
45 domElement.setAttributeNS(null, EncryptionProperty.TARGET_ATTRIB_NAME, ep.getTarget());
46 }
47
48 Attr attribute;
49 for (Entry<QName, String> entry : ep.getUnknownAttributes().entrySet()) {
50 attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
51 attribute.setValue(entry.getValue());
52 domElement.setAttributeNodeNS(attribute);
53 if (Configuration.isIDAttribute(entry.getKey()) || ep.getUnknownAttributes().isIDAttribute(entry.getKey())) {
54 attribute.getOwnerElement().setIdAttributeNode(attribute, true);
55 }
56 }
57 }
58
59 }