View Javadoc

1   /*
2    * Copyright [2007] [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 edu.internet2.middleware.shibboleth.common.xmlobject.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.KeyInfo;
25  import org.opensaml.xml.util.AttributeMap;
26  import org.opensaml.xml.util.XMLObjectChildrenList;
27  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
28  
29  import edu.internet2.middleware.shibboleth.common.xmlobject.ShibbolethMetadataKeyAuthority;
30  
31  /**
32   * Implementation of {@link ShibbolethMetadataKeyAuthority}.
33   */
34  public class ShibbolethMetadataKeyAuthorityImpl extends AbstractValidatingXMLObject implements
35          ShibbolethMetadataKeyAuthority {
36      
37      /** The list of KeyInfo child elements. */
38      private final List<KeyInfo> keyInfos;
39      
40      /** The VerifyDepth attribute. */
41      private Integer verifyDepth;
42      
43      /** Wildcard, unknown 'anyAttribute' attributes. */
44      private AttributeMap unknownAttributes;
45  
46      /**
47       * Constructor.
48       *
49       * @param namespaceURI the namespace the element is in
50       * @param elementLocalName the local name of the XML element this Object represents
51       * @param namespacePrefix the prefix for the given namespace
52       */
53      protected ShibbolethMetadataKeyAuthorityImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
54          super(namespaceURI, elementLocalName, namespacePrefix);
55          keyInfos = new XMLObjectChildrenList<KeyInfo>(this);
56          unknownAttributes = new AttributeMap(this);
57      }
58  
59      /** {@inheritDoc} */
60      public List<KeyInfo> getKeyInfos() {
61          return keyInfos;
62      }
63  
64      /** {@inheritDoc} */
65      public Integer getVerifyDepth() {
66          return verifyDepth;
67      }
68  
69      /** {@inheritDoc} */
70      public void setVerifyDepth(Integer newVerifyDepth) {
71          verifyDepth = prepareForAssignment(verifyDepth, newVerifyDepth);
72      }
73  
74      /** {@inheritDoc} */
75      public AttributeMap getUnknownAttributes() {
76          return unknownAttributes;
77      }
78  
79      /** {@inheritDoc} */
80      public List<XMLObject> getOrderedChildren() {
81          if (keyInfos.isEmpty()) {
82              return null;
83          }
84          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
85          children.addAll(keyInfos);
86          return Collections.unmodifiableList(children);
87      }
88  
89  }