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.ResponseAbstractType;
27  import org.opensaml.xml.XMLObject;
28  
29  /**
30   * Abstract implementation of {@link org.opensaml.saml1.core.ResponseAbstractType} Object
31   */
32  public abstract class ResponseAbstractTypeImpl extends AbstractSignableSAMLObject implements ResponseAbstractType {
33  
34      /** Contains the ID */
35      private String id;
36  
37      private SAMLVersion version;
38  
39      /** Contents of the InResponseTo attribute */
40      private String inResponseTo = null;
41  
42      /** Contents of the Date attribute */
43      private DateTime issueInstant = null;
44  
45      /** Contents of the recipient attribute */
46      private String recipient = null;
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 ResponseAbstractTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
56          super(namespaceURI, elementLocalName, namespacePrefix);
57          version = SAMLVersion.VERSION_11;
58      }
59  
60      /** {@inheritDoc} */
61      public String getID() {
62          return id;
63      }
64  
65      /** {@inheritDoc} */
66      public void setID(String id) {
67          String oldID = this.id;
68          this.id = prepareForAssignment(this.id, id);
69          registerOwnID(oldID, this.id);
70      }
71  
72      /** {@inheritDoc} */
73      public String getInResponseTo() {
74          return inResponseTo;
75      }
76  
77      /** {@inheritDoc} */
78      public void setInResponseTo(String inResponseTo) {
79          this.inResponseTo = prepareForAssignment(this.inResponseTo, inResponseTo);
80      }
81  
82      /** {@inheritDoc} */
83      public int getMinorVersion() {
84          return version.getMinorVersion();
85      }
86  
87      /** {@inheritDoc} */
88      public int getMajorVersion() {
89          return version.getMajorVersion();
90      }
91  
92      /** {@inheritDoc} */
93      public void setVersion(SAMLVersion newVersion) {
94          version = prepareForAssignment(version, newVersion);
95      }
96  
97      /** {@inheritDoc} */
98      public DateTime getIssueInstant() {
99  
100         return issueInstant;
101     }
102 
103     /** {@inheritDoc} */
104     public void setIssueInstant(DateTime date) {
105         this.issueInstant = prepareForAssignment(this.issueInstant, date);
106     }
107 
108     /** {@inheritDoc} */
109     public String getRecipient() {
110         return recipient;
111     }
112 
113     /** {@inheritDoc} */
114     public void setRecipient(String recipient) {
115         this.recipient = prepareForAssignment(this.recipient, recipient);
116     }
117     
118     /** {@inheritDoc} */
119     public String getSignatureReferenceID(){
120         return id;
121     }
122 
123     /** {@inheritDoc} */
124     public List<XMLObject> getOrderedChildren() {
125         List<XMLObject> children = new ArrayList<XMLObject>();
126         
127         if(getSignature() != null){
128             children.add(getSignature());
129         }
130         
131         return Collections.unmodifiableList(children);
132     }
133 }