View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  You may obtain a copy of the License at
8    *
9    *    http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package edu.internet2.middleware.shibboleth.common.xmlobject.impl;
19  
20  import java.util.ArrayList;
21  import java.util.Collections;
22  import java.util.List;
23  
24  import org.opensaml.xml.XMLObject;
25  import org.opensaml.xml.signature.KeyInfo;
26  import org.opensaml.xml.util.AttributeMap;
27  import org.opensaml.xml.util.XMLObjectChildrenList;
28  import org.opensaml.xml.validation.AbstractValidatingXMLObject;
29  
30  import edu.internet2.middleware.shibboleth.common.xmlobject.ShibbolethMetadataKeyAuthority;
31  
32  /**
33   * Implementation of {@link ShibbolethMetadataKeyAuthority}.
34   */
35  public class ShibbolethMetadataKeyAuthorityImpl extends AbstractValidatingXMLObject implements
36          ShibbolethMetadataKeyAuthority {
37      
38      /** The list of KeyInfo child elements. */
39      private final List<KeyInfo> keyInfos;
40      
41      /** The VerifyDepth attribute. */
42      private Integer verifyDepth;
43      
44      /** Wildcard, unknown 'anyAttribute' attributes. */
45      private AttributeMap unknownAttributes;
46  
47      /**
48       * Constructor.
49       *
50       * @param namespaceURI the namespace the element is in
51       * @param elementLocalName the local name of the XML element this Object represents
52       * @param namespacePrefix the prefix for the given namespace
53       */
54      protected ShibbolethMetadataKeyAuthorityImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
55          super(namespaceURI, elementLocalName, namespacePrefix);
56          keyInfos = new XMLObjectChildrenList<KeyInfo>(this);
57          unknownAttributes = new AttributeMap(this);
58      }
59  
60      /** {@inheritDoc} */
61      public List<KeyInfo> getKeyInfos() {
62          return keyInfos;
63      }
64  
65      /** {@inheritDoc} */
66      public Integer getVerifyDepth() {
67          return verifyDepth;
68      }
69  
70      /** {@inheritDoc} */
71      public void setVerifyDepth(Integer newVerifyDepth) {
72          verifyDepth = prepareForAssignment(verifyDepth, newVerifyDepth);
73      }
74  
75      /** {@inheritDoc} */
76      public AttributeMap getUnknownAttributes() {
77          return unknownAttributes;
78      }
79  
80      /** {@inheritDoc} */
81      public List<XMLObject> getOrderedChildren() {
82          if (keyInfos.isEmpty()) {
83              return null;
84          }
85          ArrayList<XMLObject> children = new ArrayList<XMLObject>();
86          children.addAll(keyInfos);
87          return Collections.unmodifiableList(children);
88      }
89  
90  }