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  package org.opensaml.saml1.core.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.joda.time.DateTime;
24  import org.opensaml.common.SAMLVersion;
25  import org.opensaml.common.impl.AbstractSignableSAMLObject;
26  import org.opensaml.saml1.core.RequestAbstractType;
27  import org.opensaml.saml1.core.RespondWith;
28  import org.opensaml.xml.XMLObject;
29  import org.opensaml.xml.util.XMLObjectChildrenList;
30  
31  /**
32   * Implementation of {@link org.opensaml.saml1.core.RequestAbstractType}.
33   */
34  public abstract class RequestAbstractTypeImpl extends AbstractSignableSAMLObject implements RequestAbstractType {
35  
36      /** Contains the ID */
37      private String id;
38  
39      /** Containt the IssueInstant */
40      private DateTime issueInstant;
41  
42      /** Version of this SAML message */
43      private SAMLVersion version;
44  
45      /** Contains the respondWiths */
46      public final XMLObjectChildrenList<RespondWith> respondWiths;
47  
48      /**
49       * Constructor
50       * 
51       * @param namespaceURI the namespace the element is in
52       * @param elementLocalName the local name of the XML element this Object represents
53       * @param namespacePrefix the prefix for the given namespace
54       */
55      protected RequestAbstractTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
56          super(namespaceURI, elementLocalName, namespacePrefix);
57          version = SAMLVersion.VERSION_11;
58          respondWiths = new XMLObjectChildrenList<RespondWith>(this);
59      }
60  
61      /** {@inheritDoc} */
62      public String getID() {
63          return id;
64      }
65  
66      /** {@inheritDoc} */
67      public void setID(String id) {
68          String oldID = this.id;
69          this.id = prepareForAssignment(this.id, id);
70          registerOwnID(oldID, this.id);
71      }
72  
73      /** {@inheritDoc} */
74      public int getMajorVersion() {
75          return version.getMajorVersion();
76      }
77  
78      /** {@inheritDoc} */
79      public int getMinorVersion() {
80          return version.getMinorVersion();
81      }
82  
83      /** {@inheritDoc} */
84      public void setVersion(SAMLVersion newVersion) {
85          version = prepareForAssignment(version, newVersion);
86      }
87  
88      /** {@inheritDoc} */
89      public DateTime getIssueInstant() {
90          return issueInstant;
91      }
92  
93      /** {@inheritDoc} */
94      public void setIssueInstant(DateTime instant) {
95          this.issueInstant = prepareForAssignment(this.issueInstant, instant);
96      }
97  
98      /** {@inheritDoc} */
99      public List<RespondWith> getRespondWiths() {
100         return respondWiths;
101     }
102     
103     /** {@inheritDoc} */
104     public String getSignatureReferenceID(){
105         return id;
106     }
107 
108     /** {@inheritDoc} */
109     public List<XMLObject> getOrderedChildren() {
110         List<XMLObject> children = new ArrayList<XMLObject>();
111 
112         children.addAll(respondWiths);
113         
114         if(getSignature() != null){
115             children.add(getSignature());
116         }
117         
118         return Collections.unmodifiableList(children);
119     }
120 }