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.core.impl;
22
23 import org.joda.time.DateTime;
24 import org.joda.time.chrono.ISOChronology;
25 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
26 import org.opensaml.saml2.core.AuthnContext;
27 import org.opensaml.saml2.core.AuthnStatement;
28 import org.opensaml.saml2.core.SubjectLocality;
29 import org.opensaml.xml.XMLObject;
30 import org.opensaml.xml.io.UnmarshallingException;
31 import org.opensaml.xml.util.DatatypeHelper;
32 import org.w3c.dom.Attr;
33
34
35
36
37 public class AuthnStatementUnmarshaller extends AbstractSAMLObjectUnmarshaller {
38
39
40 protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
41 AuthnStatement authnStatement = (AuthnStatement) parentObject;
42 if (childObject instanceof SubjectLocality) {
43 authnStatement.setSubjectLocality((SubjectLocality) childObject);
44 } else if (childObject instanceof AuthnContext) {
45 authnStatement.setAuthnContext((AuthnContext) childObject);
46 } else {
47 super.processChildElement(parentObject, childObject);
48 }
49 }
50
51
52 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
53 AuthnStatement authnStatement = (AuthnStatement) samlObject;
54 if (attribute.getLocalName().equals(AuthnStatement.AUTHN_INSTANT_ATTRIB_NAME)
55 && !DatatypeHelper.isEmpty(attribute.getValue())) {
56 authnStatement.setAuthnInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
57 } else if (attribute.getLocalName().equals(AuthnStatement.SESSION_INDEX_ATTRIB_NAME)) {
58 authnStatement.setSessionIndex(attribute.getValue());
59 } else if (attribute.getLocalName().equals(AuthnStatement.SESSION_NOT_ON_OR_AFTER_ATTRIB_NAME)
60 && !DatatypeHelper.isEmpty(attribute.getValue())) {
61 authnStatement.setSessionNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
62 } else {
63 super.processAttribute(samlObject, attribute);
64 }
65 }
66 }