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.core.impl;
22  
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.joda.time.DateTime;
28  import org.opensaml.common.SAMLVersion;
29  import org.opensaml.common.impl.AbstractSignableSAMLObject;
30  import org.opensaml.saml2.common.Extensions;
31  import org.opensaml.saml2.core.Issuer;
32  import org.opensaml.saml2.core.Status;
33  import org.opensaml.saml2.core.StatusResponseType;
34  import org.opensaml.xml.XMLObject;
35  
36  /**
37   * Concrete implementation of {@link org.opensaml.saml2.core.StatusResponseType}.
38   */
39  public abstract class StatusResponseTypeImpl extends AbstractSignableSAMLObject implements StatusResponseType {
40  
41      /** SAML Version attribute. */
42      private SAMLVersion version;
43      
44      /** ID attribute. */
45      private String id;
46  
47      /** InResponseTo attribute. */
48      private String inResponseTo;
49  
50      /** IssueInstant attribute. */
51      private DateTime issueInstant;
52  
53      /** Destination attribute. */
54      private String destination;
55  
56      /** Consent attribute. */
57      private String consent;
58  
59      /** Issuer child element. */
60      private Issuer issuer;
61  
62      /** Extensions child element. */
63      private Extensions extensions;
64  
65      /** Status child element. */
66      private Status status;
67  
68      /**
69       * Constructor.
70       * 
71       * @param namespaceURI the namespace the element is in
72       * @param elementLocalName the local name of the XML element this Object represents
73       * @param namespacePrefix the prefix for the given namespace
74       */
75      protected StatusResponseTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
76          super(namespaceURI, elementLocalName, namespacePrefix);
77          version = SAMLVersion.VERSION_20;
78      }
79  
80      /** {@inheritDoc} */
81      public SAMLVersion getVersion() {
82          return version;
83      }
84  
85      /** {@inheritDoc} */
86      public void setVersion(SAMLVersion newVersion) {
87          this.version = prepareForAssignment(this.version, newVersion);
88      }
89      
90      /** {@inheritDoc} */
91      public String getID() {
92          return this.id;
93      }
94  
95      /** {@inheritDoc} */
96      public void setID(String newID) {
97          String oldID = this.id;
98          this.id = prepareForAssignment(this.id, newID);
99          registerOwnID(oldID, this.id);
100     }
101 
102     /** {@inheritDoc} */
103     public String getInResponseTo() {
104         return this.inResponseTo;
105     }
106 
107     /** {@inheritDoc} */
108     public void setInResponseTo(String newInResponseTo) {
109         this.inResponseTo = prepareForAssignment(this.inResponseTo, newInResponseTo);
110     }
111 
112     /** {@inheritDoc} */
113     public DateTime getIssueInstant() {
114         return this.issueInstant;
115     }
116 
117     /** {@inheritDoc} */
118     public void setIssueInstant(DateTime newIssueInstant) {
119         this.issueInstant = prepareForAssignment(this.issueInstant, newIssueInstant);
120     }
121 
122     /** {@inheritDoc} */
123     public String getDestination() {
124         return this.destination;
125     }
126 
127     /** {@inheritDoc} */
128     public void setDestination(String newDestination) {
129         this.destination = prepareForAssignment(this.destination, newDestination);
130     }
131 
132     /** {@inheritDoc} */
133     public String getConsent() {
134         return this.consent;
135     }
136 
137     /** {@inheritDoc} */
138     public void setConsent(String newConsent) {
139         this.consent = prepareForAssignment(this.consent, newConsent);
140     }
141 
142     /** {@inheritDoc} */
143     public Issuer getIssuer() {
144         return this.issuer;
145     }
146 
147     /** {@inheritDoc} */
148     public void setIssuer(Issuer newIssuer) {
149         this.issuer = prepareForAssignment(this.issuer, newIssuer);
150     }
151 
152     /** {@inheritDoc} */
153     public Extensions getExtensions() {
154         return this.extensions;
155     }
156 
157     /** {@inheritDoc} */
158     public void setExtensions(Extensions newExtensions) {
159         this.extensions = prepareForAssignment(this.extensions, newExtensions);
160     }
161 
162     /** {@inheritDoc} */
163     public Status getStatus() {
164         return this.status;
165     }
166 
167     /** {@inheritDoc} */
168     public void setStatus(Status newStatus) {
169         this.status = prepareForAssignment(this.status, newStatus);
170     }
171     
172     /** {@inheritDoc} */
173     public String getSignatureReferenceID(){
174         return id;
175     }
176 
177     /** {@inheritDoc} */
178     public List<XMLObject> getOrderedChildren() {
179         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
180 
181         if (issuer != null){
182             children.add(issuer);
183         }
184         if(getSignature() != null){
185             children.add(getSignature());
186         }
187         if (extensions != null){
188             children.add(extensions);
189         }
190         if (status != null){
191             children.add(status);
192         }
193 
194         return Collections.unmodifiableList(children);
195     }
196 }