View Javadoc

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