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.opensaml.saml2.core.AuthnRequest;
24 import org.opensaml.saml2.core.Conditions;
25 import org.opensaml.saml2.core.NameIDPolicy;
26 import org.opensaml.saml2.core.RequestedAuthnContext;
27 import org.opensaml.saml2.core.Scoping;
28 import org.opensaml.saml2.core.Subject;
29 import org.opensaml.xml.XMLObject;
30 import org.opensaml.xml.io.UnmarshallingException;
31 import org.opensaml.xml.schema.XSBooleanValue;
32 import org.w3c.dom.Attr;
33
34
35
36
37 public class AuthnRequestUnmarshaller extends RequestAbstractTypeUnmarshaller {
38
39
40 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
41 AuthnRequest req = (AuthnRequest) samlObject;
42
43 if (attribute.getLocalName().equals(AuthnRequest.FORCE_AUTHN_ATTRIB_NAME)) {
44 req.setForceAuthn(XSBooleanValue.valueOf(attribute.getValue()));
45 } else if (attribute.getLocalName().equals(AuthnRequest.IS_PASSIVE_ATTRIB_NAME)) {
46 req.setIsPassive(XSBooleanValue.valueOf(attribute.getValue()));
47 } else if (attribute.getLocalName().equals(AuthnRequest.PROTOCOL_BINDING_ATTRIB_NAME)) {
48 req.setProtocolBinding(attribute.getValue());
49 } else if (attribute.getLocalName().equals(AuthnRequest.ASSERTION_CONSUMER_SERVICE_INDEX_ATTRIB_NAME)) {
50 req.setAssertionConsumerServiceIndex(Integer.valueOf(attribute.getValue()));
51 } else if (attribute.getLocalName().equals(AuthnRequest.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME)) {
52 req.setAssertionConsumerServiceURL(attribute.getValue());
53 } else if (attribute.getLocalName().equals(AuthnRequest.ATTRIBUTE_CONSUMING_SERVICE_INDEX_ATTRIB_NAME)) {
54 req.setAttributeConsumingServiceIndex(Integer.valueOf(attribute.getValue()));
55 } else if (attribute.getLocalName().equals(AuthnRequest.PROVIDER_NAME_ATTRIB_NAME)) {
56 req.setProviderName(attribute.getValue());
57 } else {
58 super.processAttribute(samlObject, attribute);
59 }
60 }
61
62
63 protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
64 throws UnmarshallingException {
65 AuthnRequest req = (AuthnRequest) parentSAMLObject;
66
67 if (childSAMLObject instanceof Subject) {
68 req.setSubject((Subject) childSAMLObject);
69 } else if (childSAMLObject instanceof NameIDPolicy) {
70 req.setNameIDPolicy((NameIDPolicy) childSAMLObject);
71 } else if (childSAMLObject instanceof Conditions) {
72 req.setConditions((Conditions) childSAMLObject);
73 } else if (childSAMLObject instanceof RequestedAuthnContext) {
74 req.setRequestedAuthnContext((RequestedAuthnContext) childSAMLObject);
75 } else if (childSAMLObject instanceof Scoping) {
76 req.setScoping((Scoping) childSAMLObject);
77 } else {
78 super.processChildElement(parentSAMLObject, childSAMLObject);
79 }
80 }
81 }