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 org.opensaml.common.impl.AbstractSAMLObjectMarshaller;
20 import org.opensaml.saml2.core.NameID;
21 import org.opensaml.saml2.core.NameIDType;
22 import org.opensaml.xml.XMLObject;
23 import org.opensaml.xml.io.MarshallingException;
24 import org.opensaml.xml.util.XMLHelper;
25 import org.w3c.dom.Element;
26
27
28
29
30 public abstract class AbstractNameIDTypeMarshaller extends AbstractSAMLObjectMarshaller {
31
32
33 protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
34 NameIDType nameID = (NameIDType) samlObject;
35
36 if (nameID.getNameQualifier() != null) {
37 domElement.setAttributeNS(null, NameID.NAME_QUALIFIER_ATTRIB_NAME, nameID.getNameQualifier());
38 }
39
40 if (nameID.getSPNameQualifier() != null) {
41 domElement.setAttributeNS(null, NameID.SP_NAME_QUALIFIER_ATTRIB_NAME, nameID.getSPNameQualifier());
42 }
43
44 if (nameID.getFormat() != null) {
45 domElement.setAttributeNS(null, NameID.FORMAT_ATTRIB_NAME, nameID.getFormat());
46 }
47
48 if (nameID.getSPProvidedID() != null) {
49 domElement.setAttributeNS(null, NameID.SPPROVIDED_ID_ATTRIB_NAME, nameID.getSPProvidedID());
50 }
51 }
52
53
54 protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
55 NameIDType nameID = (NameIDType) samlObject;
56 XMLHelper.appendTextContent(domElement, nameID.getValue());
57 }
58 }