1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml1.core.impl;
18
19 import org.joda.time.format.ISODateTimeFormat;
20 import org.opensaml.common.impl.AbstractSAMLObjectMarshaller;
21 import org.opensaml.saml1.core.Assertion;
22 import org.opensaml.xml.XMLObject;
23 import org.opensaml.xml.io.MarshallingException;
24 import org.w3c.dom.Element;
25
26
27
28
29 public class AssertionMarshaller extends AbstractSAMLObjectMarshaller {
30
31
32 protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
33
34 Assertion assertion = (Assertion) samlElement;
35
36 if (assertion.getID() != null) {
37 domElement.setAttributeNS(null, Assertion.ID_ATTRIB_NAME, assertion.getID());
38 if (assertion.getMinorVersion() != 0) {
39 domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true);
40 }
41 }
42
43 if (assertion.getIssuer() != null) {
44 domElement.setAttributeNS(null, Assertion.ISSUER_ATTRIB_NAME, assertion.getIssuer());
45 }
46
47 if (assertion.getIssueInstant() != null) {
48 String date = ISODateTimeFormat.dateTime().print(assertion.getIssueInstant());
49 domElement.setAttributeNS(null, Assertion.ISSUEINSTANT_ATTRIB_NAME, date);
50 }
51
52 domElement.setAttributeNS(null, Assertion.MAJORVERSION_ATTRIB_NAME, "1");
53 if (assertion.getMinorVersion() == 0) {
54 domElement.setAttributeNS(null, Assertion.MINORVERSION_ATTRIB_NAME, "0");
55 } else {
56 domElement.setAttributeNS(null, Assertion.MINORVERSION_ATTRIB_NAME, "1");
57 }
58 }
59 }