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.saml2.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.saml2.core.BaseID;
25  import org.opensaml.saml2.core.EncryptedID;
26  import org.opensaml.saml2.core.LogoutRequest;
27  import org.opensaml.saml2.core.NameID;
28  import org.opensaml.saml2.core.SessionIndex;
29  import org.opensaml.xml.XMLObject;
30  import org.opensaml.xml.util.XMLObjectChildrenList;
31  
32  /**
33   * A concrete implementation of {@link org.opensaml.saml2.core.LogoutRequest}.
34   */
35  public class LogoutRequestImpl extends RequestAbstractTypeImpl implements LogoutRequest {
36  
37      /** Reason attribute. */
38      private String reason;
39  
40      /** NotOnOrAfter attribute. */
41      private DateTime notOnOrAfter;
42  
43      /** BaseID child element. */
44      private BaseID baseID;
45  
46      /** NameID child element. */
47      private NameID nameID;
48      
49      /** EncryptedID child element. */
50      private EncryptedID encryptedID;
51  
52  
53      /** SessionIndex child elements. */
54      private final XMLObjectChildrenList<SessionIndex> sessionIndexes;
55  
56      /**
57       * Constructor.
58       * 
59       * @param namespaceURI the namespace the element is in
60       * @param elementLocalName the local name of the XML element this Object represents
61       * @param namespacePrefix the prefix for the given namespace
62       */
63      protected LogoutRequestImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
64          super(namespaceURI, elementLocalName, namespacePrefix);
65          sessionIndexes = new XMLObjectChildrenList<SessionIndex>(this);
66      }
67  
68      /** {@inheritDoc} */
69      public String getReason() {
70          return this.reason;
71      }
72  
73      /** {@inheritDoc} */
74      public void setReason(String newReason) {
75          this.reason = prepareForAssignment(this.reason, newReason);
76      }
77  
78      /** {@inheritDoc} */
79      public DateTime getNotOnOrAfter() {
80          return this.notOnOrAfter;
81      }
82  
83      /** {@inheritDoc} */
84      public void setNotOnOrAfter(DateTime newNotOnOrAfter) {
85          this.notOnOrAfter = prepareForAssignment(this.notOnOrAfter, newNotOnOrAfter);
86      }
87  
88      /** {@inheritDoc} */
89      public BaseID getBaseID() {
90          return baseID;
91      }
92  
93      /** {@inheritDoc} */
94      public void setBaseID(BaseID newBaseID) {
95          baseID = prepareForAssignment(baseID, newBaseID);
96      }
97  
98      /** {@inheritDoc} */
99      public NameID getNameID() {
100         return nameID;
101     }
102 
103     /** {@inheritDoc} */
104     public void setNameID(NameID newNameID) {
105         nameID = prepareForAssignment(nameID, newNameID);
106     }
107 
108     /** {@inheritDoc} */
109     public EncryptedID getEncryptedID() {
110         return this.encryptedID;
111     }
112 
113     /** {@inheritDoc} */
114     public void setEncryptedID(EncryptedID newEncryptedID) {
115         this.encryptedID = prepareForAssignment(this.encryptedID, newEncryptedID);
116     }
117 
118     /** {@inheritDoc} */
119     public List<SessionIndex> getSessionIndexes() {
120         return sessionIndexes;
121     }
122 
123     /** {@inheritDoc} */
124     public List<XMLObject> getOrderedChildren() {
125         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
126 
127         if (super.getOrderedChildren() != null) {
128             children.addAll(super.getOrderedChildren());
129         }
130 
131         if (baseID != null) {
132             children.add(baseID);
133         }
134 
135         if (nameID != null) {
136             children.add(nameID);
137         }
138         
139         if (encryptedID != null) {
140             children.add(encryptedID);
141         }
142 
143         children.addAll(sessionIndexes);
144 
145         if (children.size() == 0) {
146             return null;
147         }
148 
149         return Collections.unmodifiableList(children);
150     }
151 }