View Javadoc

1   /*
2    * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /**
18   * 
19   */
20  
21  package org.opensaml.saml2.metadata.impl;
22  
23  import org.opensaml.saml2.core.Attribute;
24  import org.opensaml.saml2.metadata.AssertionIDRequestService;
25  import org.opensaml.saml2.metadata.AttributeProfile;
26  import org.opensaml.saml2.metadata.IDPSSODescriptor;
27  import org.opensaml.saml2.metadata.NameIDMappingService;
28  import org.opensaml.saml2.metadata.SingleSignOnService;
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   * A thread safe Unmarshaller for {@link org.opensaml.saml2.metadata.SSODescriptor} objects.
36   */
37  public class IDPSSODescriptorUnmarshaller extends SSODescriptorUnmarshaller {
38  
39      /** {@inheritDoc} */
40      protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
41          IDPSSODescriptor descriptor = (IDPSSODescriptor) parentObject;
42  
43          if (childObject instanceof SingleSignOnService) {
44              descriptor.getSingleSignOnServices().add((SingleSignOnService) childObject);
45          } else if (childObject instanceof NameIDMappingService) {
46              descriptor.getNameIDMappingServices().add((NameIDMappingService) childObject);
47          } else if (childObject instanceof AssertionIDRequestService) {
48              descriptor.getAssertionIDRequestServices().add((AssertionIDRequestService) childObject);
49          } else if (childObject instanceof AttributeProfile) {
50              descriptor.getAttributeProfiles().add((AttributeProfile) childObject);
51          } else if (childObject instanceof Attribute) {
52              descriptor.getAttributes().add((Attribute) childObject);
53          } else {
54              super.processChildElement(parentObject, childObject);
55          }
56      }
57  
58      /** {@inheritDoc} */
59      protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
60          IDPSSODescriptor descriptor = (IDPSSODescriptor) samlObject;
61  
62          if (attribute.getLocalName().equals(IDPSSODescriptor.WANT_AUTHN_REQ_SIGNED_ATTRIB_NAME)) {
63              descriptor.setWantAuthnRequestsSigned(XSBooleanValue.valueOf(attribute.getValue()));
64          } else {
65              super.processAttribute(samlObject, attribute);
66          }
67      }
68  }