1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opensaml.saml2.metadata.impl;
22
23 import javax.xml.namespace.QName;
24
25 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
26 import org.opensaml.saml2.common.Extensions;
27 import org.opensaml.saml2.metadata.Company;
28 import org.opensaml.saml2.metadata.ContactPerson;
29 import org.opensaml.saml2.metadata.ContactPersonTypeEnumeration;
30 import org.opensaml.saml2.metadata.EmailAddress;
31 import org.opensaml.saml2.metadata.GivenName;
32 import org.opensaml.saml2.metadata.SurName;
33 import org.opensaml.saml2.metadata.TelephoneNumber;
34 import org.opensaml.xml.XMLObject;
35 import org.opensaml.xml.io.UnmarshallingException;
36 import org.opensaml.xml.util.XMLHelper;
37 import org.w3c.dom.Attr;
38
39
40
41
42 public class ContactPersonUnmarshaller extends AbstractSAMLObjectUnmarshaller {
43
44
45 protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
46 throws UnmarshallingException {
47 ContactPerson person = (ContactPerson) parentSAMLObject;
48
49 if (childSAMLObject instanceof Extensions) {
50 person.setExtensions((Extensions) childSAMLObject);
51 } else if (childSAMLObject instanceof Company) {
52 person.setCompany((Company) childSAMLObject);
53 } else if (childSAMLObject instanceof GivenName) {
54 person.setGivenName((GivenName) childSAMLObject);
55 } else if (childSAMLObject instanceof SurName) {
56 person.setSurName((SurName) childSAMLObject);
57 } else if (childSAMLObject instanceof EmailAddress) {
58 person.getEmailAddresses().add((EmailAddress) childSAMLObject);
59 } else if (childSAMLObject instanceof TelephoneNumber) {
60 person.getTelephoneNumbers().add((TelephoneNumber) childSAMLObject);
61 } else {
62 super.processChildElement(parentSAMLObject, childSAMLObject);
63 }
64 }
65
66
67 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
68 ContactPerson person = (ContactPerson) samlObject;
69
70 if (attribute.getLocalName().equals(ContactPerson.CONTACT_TYPE_ATTRIB_NAME)) {
71 if (ContactPersonTypeEnumeration.TECHNICAL.toString().equals(attribute.getValue())) {
72 person.setType(ContactPersonTypeEnumeration.TECHNICAL);
73 } else if (ContactPersonTypeEnumeration.SUPPORT.toString().equals(attribute.getValue())) {
74 person.setType(ContactPersonTypeEnumeration.SUPPORT);
75 } else if (ContactPersonTypeEnumeration.ADMINISTRATIVE.toString().equals(attribute.getValue())) {
76 person.setType(ContactPersonTypeEnumeration.ADMINISTRATIVE);
77 } else if (ContactPersonTypeEnumeration.BILLING.toString().equals(attribute.getValue())) {
78 person.setType(ContactPersonTypeEnumeration.BILLING);
79 } else if (ContactPersonTypeEnumeration.OTHER.toString().equals(attribute.getValue())) {
80 person.setType(ContactPersonTypeEnumeration.OTHER);
81 } else {
82 super.processAttribute(samlObject, attribute);
83 }
84 } else {
85 QName attribQName = XMLHelper.getNodeQName(attribute);
86 if (attribute.isId()) {
87 person.getUnknownAttributes().registerID(attribQName);
88 }
89 person.getUnknownAttributes().put(attribQName, attribute.getValue());
90 }
91 }
92 }