View Javadoc

1   /*
2   Copyright 2008 Members of the EGEE Collaboration.
3   Copyright 2008 University Corporation for Advanced Internet Development,
4   Inc.
5   
6   Licensed under the Apache License, Version 2.0 (the "License");
7   you may not use this file except in compliance with the License.
8   You may obtain a copy of the License at
9   
10      http://www.apache.org/licenses/LICENSE-2.0
11  
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17   */
18  
19  package org.opensaml.xacml.ctx.impl;
20  
21  import org.opensaml.xacml.ctx.ActionType;
22  import org.opensaml.xacml.ctx.EnvironmentType;
23  import org.opensaml.xacml.ctx.RequestType;
24  import org.opensaml.xacml.ctx.ResourceType;
25  import org.opensaml.xacml.ctx.SubjectType;
26  import org.opensaml.xml.XMLObject;
27  import org.opensaml.xml.io.AbstractXMLObjectUnmarshaller;
28  import org.opensaml.xml.io.UnmarshallingException;
29  import org.w3c.dom.Attr;
30  
31  /** Unmarshaller for {@link EnvironmentType} objects. */
32  public class RequestTypeUnmarshaller extends AbstractXMLObjectUnmarshaller {
33  
34      /** Constructor. */
35      public RequestTypeUnmarshaller() {
36          super();
37      }
38  
39      /**
40       * Constructor.
41       * 
42       * @param targetNamespaceURI the namespace URI of either the schema type QName or element QName of the elements this
43       *            unmarshaller operates on
44       * @param targetLocalName the local name of either the schema type QName or element QName of the elements this
45       *            unmarshaller operates on
46       */
47      protected RequestTypeUnmarshaller(String targetNamespaceURI, String targetLocalName) {
48          super(targetNamespaceURI, targetLocalName);
49      }
50  
51      /** {@inheritDoc} */
52      protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
53              throws UnmarshallingException {
54          RequestType request = (RequestType) parentSAMLObject;
55  
56          if (childSAMLObject instanceof ActionType) {
57              request.setAction((ActionType) childSAMLObject);
58          } else if (childSAMLObject instanceof EnvironmentType) {
59              request.setEnvironment((EnvironmentType) childSAMLObject);
60          } else if (childSAMLObject instanceof SubjectType) {
61              request.getSubjects().add((SubjectType) childSAMLObject);
62          } else if (childSAMLObject instanceof ResourceType) {
63              request.getResources().add((ResourceType) childSAMLObject);
64          }
65      }
66  
67      /** {@inheritDoc} */
68      protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
69      }
70  
71      /** {@inheritDoc} */
72      protected void processElementContent(XMLObject xmlObject, String elementContent) {
73      }
74  }