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.RequestAbstractType;
33  import org.opensaml.xml.XMLObject;
34  
35  /**
36   * Concrete implementation of {@link org.opensaml.saml2.core.RequestAbstractType}.
37   */
38  public abstract class RequestAbstractTypeImpl extends AbstractSignableSAMLObject implements RequestAbstractType {
39  
40      /** SAML Version of the request. */
41      private SAMLVersion version;
42  
43      /** Unique identifier of the request. */
44      private String id;
45  
46      /** Date/time request was issued. */
47      private DateTime issueInstant;
48  
49      /** URI of the request destination. */
50      private String destination;
51  
52      /** URI of the SAML user consent type. */
53      private String consent;
54  
55      /** URI of the SAML user consent type. */
56      private Issuer issuer;
57  
58      /** Extensions child element. */
59      private Extensions extensions;
60  
61      /**
62       * Constructor.
63       * 
64       * @param namespaceURI the namespace the element is in
65       * @param elementLocalName the local name of the XML element this Object represents
66       * @param namespacePrefix the prefix for the given namespace
67       */
68      protected RequestAbstractTypeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
69          super(namespaceURI, elementLocalName, namespacePrefix);
70          version = SAMLVersion.VERSION_20;
71      }
72  
73      /** {@inheritDoc} */
74      public SAMLVersion getVersion() {
75          return version;
76      }
77  
78      /** {@inheritDoc} */
79      public void setVersion(SAMLVersion newVersion) {
80          this.version = prepareForAssignment(this.version, newVersion);
81      }
82  
83      /** {@inheritDoc} */
84      public String getID() {
85          return id;
86      }
87  
88      /** {@inheritDoc} */
89      public void setID(String newID) {
90          String oldID = this.id;
91          this.id = prepareForAssignment(this.id, newID);
92          registerOwnID(oldID, this.id);
93      }
94  
95      /** {@inheritDoc} */
96      public DateTime getIssueInstant() {
97          return issueInstant;
98      }
99  
100     /** {@inheritDoc} */
101     public void setIssueInstant(DateTime newIssueInstant) {
102         this.issueInstant = prepareForAssignment(this.issueInstant, newIssueInstant);
103     }
104 
105     /** {@inheritDoc} */
106     public String getDestination() {
107         return destination;
108     }
109 
110     /** {@inheritDoc} */
111     public void setDestination(String newDestination) {
112         this.destination = prepareForAssignment(this.destination, newDestination);
113     }
114 
115     /** {@inheritDoc} */
116     public String getConsent() {
117         return consent;
118     }
119 
120     /** {@inheritDoc} */
121     public void setConsent(String newConsent) {
122         this.consent = prepareForAssignment(this.consent, newConsent);
123     }
124 
125     /** {@inheritDoc} */
126     public Issuer getIssuer() {
127         return issuer;
128     }
129 
130     /** {@inheritDoc} */
131     public void setIssuer(Issuer newIssuer) {
132         this.issuer = prepareForAssignment(this.issuer, newIssuer);
133     }
134 
135     /** {@inheritDoc} */
136     public Extensions getExtensions() {
137         return this.extensions;
138     }
139 
140     /** {@inheritDoc} */
141     public void setExtensions(Extensions newExtensions) {
142         this.extensions = prepareForAssignment(this.extensions, newExtensions);
143     }
144 
145     /** {@inheritDoc} */
146     public String getSignatureReferenceID() {
147         return id;
148     }
149 
150     /** {@inheritDoc} */
151     public List<XMLObject> getOrderedChildren() {
152         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
153 
154         if (issuer != null) {
155             children.add(issuer);
156         }
157         if (getSignature() != null) {
158             children.add(getSignature());
159         }
160         if (extensions != null) {
161             children.add(extensions);
162         }
163 
164         if (children.size() == 0) {
165             return null;
166         }
167 
168         return Collections.unmodifiableList(children);
169     }
170 }