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.signature.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.signature.Exponent;
25  import org.opensaml.xml.signature.Modulus;
26  import org.opensaml.xml.signature.RSAKeyValue;
27  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
28  
29  /**
30   * Concrete implementation of {@link org.opensaml.xml.signature.RSAKeyValue}
31   */
32  public class RSAKeyValueImpl extends AbstractValidatingXMLObject implements RSAKeyValue {
33      
34      /** Modulus child element value */
35      private Modulus modulus;
36      
37      /** Exponent child element value */
38      private Exponent exponent;
39  
40      /**
41       * Constructor
42       *
43       * @param namespaceURI
44       * @param elementLocalName
45       * @param namespacePrefix
46       */
47      protected RSAKeyValueImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
48          super(namespaceURI, elementLocalName, namespacePrefix);
49      }
50  
51      /** {@inheritDoc} */
52      public Modulus getModulus() {
53          return this.modulus;
54      }
55  
56      /** {@inheritDoc} */
57      public void setModulus(Modulus newModulus) {
58          this.modulus = prepareForAssignment(this.modulus, newModulus);
59      }
60  
61      /** {@inheritDoc} */
62      public Exponent getExponent() {
63          return this.exponent;
64      }
65  
66      /** {@inheritDoc} */
67      public void setExponent(Exponent newExponent) {
68          this.exponent = prepareForAssignment(this.exponent, newExponent);
69  
70      }
71  
72      /** {@inheritDoc} */
73      public List<XMLObject> getOrderedChildren() {
74          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
75          
76          if (modulus != null) {
77              children.add(modulus);
78          }
79          if (exponent != null) {
80              children.add(exponent);
81          }
82          
83          if (children.size() == 0) {
84              return null;
85          }
86          
87          return Collections.unmodifiableList(children);
88      }
89  
90  }