View Javadoc

1   /*
2    * Copyright [2006] [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.xml.encryption.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.opensaml.xml.XMLObject;
24  import org.opensaml.xml.encryption.CarriedKeyName;
25  import org.opensaml.xml.encryption.EncryptedKey;
26  import org.opensaml.xml.encryption.ReferenceList;
27  
28  /**
29   * Concrete implementation of {@link org.opensaml.xml.encryption.EncryptedKey}.
30   */
31  public class EncryptedKeyImpl extends EncryptedTypeImpl implements EncryptedKey {
32      
33      /** Recipient value. */
34      private String recipient;
35      
36      /** CarriedKeyName value. */
37      private CarriedKeyName carriedKeyName;
38      
39      /** ReferenceList value. */
40      private ReferenceList referenceList;
41  
42      /**
43       * Constructor.
44       *
45       * @param namespaceURI namespace URI
46       * @param elementLocalName local name
47       * @param namespacePrefix namespace prefix
48       */
49      protected EncryptedKeyImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
50          super(namespaceURI, elementLocalName, namespacePrefix);
51      }
52  
53      /** {@inheritDoc} */
54      public String getRecipient() {
55          return this.recipient;
56      }
57  
58      /** {@inheritDoc} */
59      public void setRecipient(String newRecipient) {
60          this.recipient = prepareForAssignment(this.recipient, newRecipient);
61      }
62  
63      /** {@inheritDoc} */
64      public ReferenceList getReferenceList() {
65          return this.referenceList;
66      }
67  
68      /** {@inheritDoc} */
69      public void setReferenceList(ReferenceList newReferenceList) {
70          this.referenceList = prepareForAssignment(this.referenceList, newReferenceList);
71      }
72  
73      /** {@inheritDoc} */
74      public CarriedKeyName getCarriedKeyName() {
75          return this.carriedKeyName;
76      }
77  
78      /** {@inheritDoc} */
79      public void setCarriedKeyName(CarriedKeyName newCarriedKeyName) {
80          this.carriedKeyName = prepareForAssignment(this.carriedKeyName, newCarriedKeyName);
81      }
82  
83      /** {@inheritDoc} */
84      public List<XMLObject> getOrderedChildren() {
85          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
86          
87          if (super.getOrderedChildren() != null) {
88              children.addAll(super.getOrderedChildren());
89          }
90         
91          if (referenceList != null) {
92              children.add(referenceList);
93          }
94          if (carriedKeyName != null) {
95              children.add(carriedKeyName);
96          }
97          
98          if (children.size() == 0) {
99              return null;
100         }
101         
102         return Collections.unmodifiableList(children);
103     }
104 
105 }