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.opensaml.saml2.core.EncryptedID;
28  import org.opensaml.saml2.core.ManageNameIDRequest;
29  import org.opensaml.saml2.core.NameID;
30  import org.opensaml.saml2.core.NewEncryptedID;
31  import org.opensaml.saml2.core.NewID;
32  import org.opensaml.saml2.core.Terminate;
33  import org.opensaml.xml.XMLObject;
34  
35  /**
36   * A concrete implementation of {@link org.opensaml.saml2.core.ManageNameIDRequest}.
37   */
38  public class ManageNameIDRequestImpl extends RequestAbstractTypeImpl implements ManageNameIDRequest {
39  
40      /** NameID child element. */
41      private NameID nameID;
42  
43      /** EncryptedID child element. */
44      private EncryptedID encryptedID;
45  
46      /** NewID child element. */
47      private NewID newID;
48  
49      /** NameID child element. */
50      private NewEncryptedID newEncryptedID;
51  
52      /** Terminate child element. */
53      private Terminate terminate;
54  
55      /**
56       * Constructor.
57       * 
58       * @param namespaceURI the namespace the element is in
59       * @param elementLocalName the local name of the XML element this Object represents
60       * @param namespacePrefix the prefix for the given namespace
61       */
62      protected ManageNameIDRequestImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
63          super(namespaceURI, elementLocalName, namespacePrefix);
64      }
65  
66      /** {@inheritDoc} */
67      public NameID getNameID() {
68          return this.nameID;
69      }
70  
71      /** {@inheritDoc} */
72      public void setNameID(NameID newNameID) {
73          this.nameID = prepareForAssignment(this.nameID, newNameID);
74      }
75  
76      /** {@inheritDoc} */
77      public EncryptedID getEncryptedID() {
78          return this.encryptedID;
79      }
80  
81      /** {@inheritDoc} */
82      public void setEncryptedID(EncryptedID newEncID) {
83          this.encryptedID = prepareForAssignment(this.encryptedID, newEncID);
84      }
85  
86      /** {@inheritDoc} */
87      public NewID getNewID() {
88          return this.newID;
89      }
90  
91      /** {@inheritDoc} */
92      public void setNewID(NewID newNewID) {
93          this.newID = prepareForAssignment(this.newID, newNewID);
94      }
95  
96      /** {@inheritDoc} */
97      public NewEncryptedID getNewEncryptedID() {
98          return this.newEncryptedID;
99      }
100 
101     /** {@inheritDoc} */
102     public void setNewEncryptedID(NewEncryptedID newNewEncryptedID) {
103         this.newEncryptedID = prepareForAssignment(this.newEncryptedID, newNewEncryptedID);
104     }
105 
106     /** {@inheritDoc} */
107     public Terminate getTerminate() {
108         return this.terminate;
109     }
110 
111     /** {@inheritDoc} */
112     public void setTerminate(Terminate newTerminate) {
113         this.terminate = prepareForAssignment(this.terminate, newTerminate);
114     }
115 
116     /** {@inheritDoc} */
117     public List<XMLObject> getOrderedChildren() {
118         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
119 
120         if (super.getOrderedChildren() != null) {
121             children.addAll(super.getOrderedChildren());
122         }
123         if (nameID != null) {
124             children.add(nameID);
125         }
126         if (encryptedID != null) {
127             children.add(encryptedID);
128         }
129         if (newID != null) {
130             children.add(newID);
131         }
132         if (newEncryptedID != null) {
133             children.add(newEncryptedID);
134         }
135         if (terminate != null) {
136             children.add(terminate);
137         }
138 
139         if (children.size() == 0) {
140             return null;
141         }
142 
143         return Collections.unmodifiableList(children);
144     }
145 }