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.opensaml.saml2.core.BaseID;
24  import org.opensaml.saml2.core.EncryptedID;
25  import org.opensaml.saml2.core.NameID;
26  import org.opensaml.saml2.core.NameIDMappingRequest;
27  import org.opensaml.saml2.core.NameIDPolicy;
28  import org.opensaml.xml.XMLObject;
29  
30  /**
31   * A concrete implementation of {@link org.opensaml.saml2.core.NameIDMappingRequest}.
32   */
33  public class NameIDMappingRequestImpl extends RequestAbstractTypeImpl implements NameIDMappingRequest {
34  
35      /** BaseID child element. */
36      private BaseID baseID;
37  
38      /** NameID child element. */
39      private NameID nameID;
40  
41      /** EncryptedID child element. */
42      private EncryptedID encryptedID;
43  
44      /** NameIDPolicy child element. */
45      private NameIDPolicy nameIDPolicy;
46  
47      /**
48       * Constructor.
49       * 
50       * @param namespaceURI the namespace the element is in
51       * @param elementLocalName the local name of the XML element this Object represents
52       * @param namespacePrefix the prefix for the given namespace
53       */
54      protected NameIDMappingRequestImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
55          super(namespaceURI, elementLocalName, namespacePrefix);
56      }
57  
58      /** {@inheritDoc} */
59      public BaseID getBaseID() {
60          return baseID;
61      }
62  
63      /** {@inheritDoc} */
64      public void setBaseID(BaseID newBaseID) {
65          baseID = prepareForAssignment(baseID, newBaseID);
66      }
67  
68      /** {@inheritDoc} */
69      public NameID getNameID() {
70          return nameID;
71      }
72  
73      /** {@inheritDoc} */
74      public void setNameID(NameID newNameID) {
75          nameID = prepareForAssignment(nameID, newNameID);
76      }
77  
78      /** {@inheritDoc} */
79      public EncryptedID getEncryptedID() {
80          return this.encryptedID;
81      }
82  
83      /** {@inheritDoc} */
84      public void setEncryptedID(EncryptedID newEncryptedID) {
85          this.encryptedID = prepareForAssignment(this.encryptedID, newEncryptedID);
86      }
87  
88      /** {@inheritDoc} */
89      public NameIDPolicy getNameIDPolicy() {
90          return this.nameIDPolicy;
91      }
92  
93      /** {@inheritDoc} */
94      public void setNameIDPolicy(NameIDPolicy newNameIDPolicy) {
95          this.nameIDPolicy = prepareForAssignment(this.nameIDPolicy, newNameIDPolicy);
96      }
97  
98      /** {@inheritDoc} */
99      public List<XMLObject> getOrderedChildren() {
100         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
101 
102         if (super.getOrderedChildren() != null) {
103             children.addAll(super.getOrderedChildren());
104         }
105 
106         if (baseID != null) {
107             children.add(baseID);
108         }
109 
110         if (nameID != null) {
111             children.add(nameID);
112         }
113         
114         if (encryptedID != null) {
115             children.add(encryptedID);
116         }
117 
118         if (nameIDPolicy != null) {
119             children.add(nameIDPolicy);
120         }
121 
122         if (children.size() == 0) {
123             return null;
124         }
125 
126         return Collections.unmodifiableList(children);
127     }
128 }