1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml2.core.impl;
18
19 import javax.xml.namespace.QName;
20
21 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
22 import org.opensaml.common.xml.SAMLConstants;
23 import org.opensaml.saml2.core.Attribute;
24 import org.opensaml.xml.XMLObject;
25 import org.opensaml.xml.io.UnmarshallingException;
26 import org.opensaml.xml.util.XMLHelper;
27 import org.w3c.dom.Attr;
28
29
30
31
32 public class AttributeUnmarshaller extends AbstractSAMLObjectUnmarshaller {
33
34
35 protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
36 throws UnmarshallingException {
37
38 Attribute attribute = (Attribute) parentSAMLObject;
39
40 QName childQName = childSAMLObject.getElementQName();
41 if (childQName.getLocalPart().equals("AttributeValue")
42 && childQName.getNamespaceURI().equals(SAMLConstants.SAML20_NS)) {
43 attribute.getAttributeValues().add(childSAMLObject);
44 } else {
45 super.processChildElement(parentSAMLObject, childSAMLObject);
46 }
47 }
48
49
50 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
51
52 Attribute attrib = (Attribute) samlObject;
53
54 if (attribute.getLocalName().equals(Attribute.NAME_ATTTRIB_NAME)) {
55 attrib.setName(attribute.getValue());
56 } else if (attribute.getLocalName().equals(Attribute.NAME_FORMAT_ATTRIB_NAME)) {
57 attrib.setNameFormat(attribute.getValue());
58 } else if (attribute.getLocalName().equals(Attribute.FRIENDLY_NAME_ATTRIB_NAME)) {
59 attrib.setFriendlyName(attribute.getValue());
60 } else {
61 QName attribQName = XMLHelper.getNodeQName(attribute);
62 if (attribute.isId()) {
63 attrib.getUnknownAttributes().registerID(attribQName);
64 }
65 attrib.getUnknownAttributes().put(attribQName, attribute.getValue());
66 }
67 }
68 }