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.DHKeyValue;
25  import org.opensaml.xml.encryption.Generator;
26  import org.opensaml.xml.encryption.P;
27  import org.opensaml.xml.encryption.PgenCounter;
28  import org.opensaml.xml.encryption.Public;
29  import org.opensaml.xml.encryption.Q;
30  import org.opensaml.xml.encryption.Seed;
31  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
32  
33  /**
34   * Concrete implementation of {@link org.opensaml.xml.encryption.DHKeyValue}.
35   */
36  public class DHKeyValueImpl extends AbstractValidatingXMLObject implements DHKeyValue {
37      
38      /** P child element. */
39      private P p;
40      
41      /** Q child element. */
42      private Q q;
43      
44      /** Generator child element. */
45      private Generator generator;
46      
47      /** Public element. */
48      private Public publicChild;
49      
50      /** seed child element. */
51      private Seed seed;
52      
53      /** pgenCounter child element. */
54      private PgenCounter pgenCounter;
55  
56      /**
57       * Constructor.
58       *
59       * @param namespaceURI namespace URI
60       * @param elementLocalName local name
61       * @param namespacePrefix namespace prefix
62       */
63      protected DHKeyValueImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
64          super(namespaceURI, elementLocalName, namespacePrefix);
65      }
66  
67      /** {@inheritDoc} */
68      public P getP() {
69          return this.p;
70      }
71  
72      /** {@inheritDoc} */
73      public void setP(P newP) {
74          this.p = prepareForAssignment(this.p, newP);
75      }
76  
77      /** {@inheritDoc} */
78      public Q getQ() {
79          return this.q;
80      }
81  
82      /** {@inheritDoc} */
83      public void setQ(Q newQ) {
84          this.q = prepareForAssignment(this.q, newQ);
85      }
86  
87      /** {@inheritDoc} */
88      public Generator getGenerator() {
89          return this.generator;
90      }
91  
92      /** {@inheritDoc} */
93      public void setGenerator(Generator newGenerator) {
94          this.generator = prepareForAssignment(this.generator, newGenerator);
95      }
96  
97      /** {@inheritDoc} */
98      public Public getPublic() {
99          return this.publicChild;
100     }
101 
102     /** {@inheritDoc} */
103     public void setPublic(Public newPublic) {
104         this.publicChild = prepareForAssignment(this.publicChild, newPublic);
105     }
106 
107     /** {@inheritDoc} */
108     public Seed getSeed() {
109         return this.seed;
110     }
111 
112     /** {@inheritDoc} */
113     public void setSeed(Seed newSeed) {
114         this.seed = prepareForAssignment(this.seed, newSeed);
115     }
116 
117     /** {@inheritDoc} */
118     public PgenCounter getPgenCounter() {
119         return this.pgenCounter;
120     }
121 
122     /** {@inheritDoc} */
123     public void setPgenCounter(PgenCounter newPgenCounter) {
124         this.pgenCounter = prepareForAssignment(this.pgenCounter, newPgenCounter);
125     }
126 
127     /** {@inheritDoc} */
128     public List<XMLObject> getOrderedChildren() {
129         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
130         
131         if (p != null) {
132             children.add(p);
133         }
134         if (q!= null) {
135             children.add(q);
136         }
137         if (generator != null) {
138             children.add(generator);
139         }
140         if (publicChild != null) {
141             children.add(publicChild);
142         }
143         if (seed != null) {
144             children.add(seed);
145         }
146         if (pgenCounter != null) {
147             children.add(pgenCounter);
148         }
149         
150         if (children.size() == 0) {
151             return null;
152         }
153         
154         return Collections.unmodifiableList(children);
155     }
156 
157 }