View Javadoc

1   /*
2    * Copyright 2008 Members of the EGEE Collaboration.
3    * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * 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 org.opensaml.ws.wssecurity.impl;
19  
20  import java.util.ArrayList;
21  import java.util.Collections;
22  import java.util.List;
23  
24  import javax.xml.namespace.QName;
25  
26  import org.opensaml.ws.wssecurity.SecurityTokenReference;
27  import org.opensaml.xml.XMLObject;
28  import org.opensaml.xml.util.AttributeMap;
29  import org.opensaml.xml.util.IndexedXMLObjectChildrenList;
30  
31  /**
32   * SecurityTokenReferenceImpl.
33   * 
34   */
35  public class SecurityTokenReferenceImpl extends AbstractWSSecurityObject implements SecurityTokenReference {
36  
37      /** The <wsu:Id> attribute value. */
38      private String id;
39  
40      /** List of <wsse:Usage> attribute values. */
41      private List<String> usages;
42      
43      /** Wildcard attributes. */
44      private AttributeMap unknownAttributes;
45      
46      /** Wildcard child elements. */
47      private IndexedXMLObjectChildrenList<XMLObject> unknownChildren;
48  
49      /**
50       * Constructor.
51       * 
52       * @param namespaceURI namespace of the element
53       * @param elementLocalName name of the element
54       * @param namespacePrefix namespace prefix of the element
55       */
56      public SecurityTokenReferenceImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
57          super(namespaceURI, elementLocalName, namespacePrefix);
58          usages = new ArrayList<String>();
59          unknownAttributes = new AttributeMap(this);
60          unknownChildren = new IndexedXMLObjectChildrenList<XMLObject>(this);
61      }
62      
63  
64      /** {@inheritDoc} */
65      public List<String> getWSSEUsages() {
66          return usages;
67      }
68  
69      /** {@inheritDoc} */
70      public void setWSSEUsages(List<String> newUsages) {
71          usages = prepareForAssignment(usages, newUsages);
72      }
73  
74      /** {@inheritDoc} */
75      public String getWSUId() {
76          return id;
77      }
78  
79      /** {@inheritDoc} */
80      public void setWSUId(String newId) {
81          String oldId = id;
82          id = prepareForAssignment(id, newId);
83          registerOwnID(oldId, id);
84      }
85  
86  
87      /** {@inheritDoc} */
88      public AttributeMap getUnknownAttributes() {
89          return unknownAttributes;
90      }
91  
92      /** {@inheritDoc} */
93      public List<XMLObject> getUnknownXMLObjects() {
94          return unknownChildren;
95      }
96  
97      /** {@inheritDoc} */
98      public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
99          return (List<XMLObject>) unknownChildren.subList(typeOrName);
100     }
101     
102     /** {@inheritDoc} */
103     public List<XMLObject> getOrderedChildren() {
104         List<XMLObject> children = new ArrayList<XMLObject>();
105 
106         if (!getUnknownXMLObjects().isEmpty()) {
107             children.addAll(getUnknownXMLObjects());
108         }
109         return Collections.unmodifiableList(children);
110     }
111 
112 }