View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.ws.security;
21  
22  /**
23   * WSDataRef stores information about decrypted/signed elements
24   * 
25   * When a processor decrypts/verifies an element it stores information 
26   * about that element in a WSDataRef so this information can 
27   * be used for validation. 
28   */
29  
30  import java.util.List;
31  
32  import javax.xml.namespace.QName;
33  import org.w3c.dom.Element;
34  
35  public class WSDataRef {
36      
37      /**
38       * wsu:Id of the protected element
39       */
40      private String wsuId;
41      
42      /**
43       * QName of the protected element
44       */
45      private QName name;
46      
47      /**
48       * An xpath expression pointing to the data element
49       */
50      private String xpath;
51      
52      /**
53       * Algorithm used to encrypt/sign the element
54       */
55      private String algorithm;
56      
57      /**
58       * A list of algorithms used to transform the element before digest
59       */
60      private List<String> transformAlgorithms;
61      
62      /**
63       * If this reference represents signed content, this field
64       * represents the digest algorithm applied to the content.
65       */
66      private String digestAlgorithm;
67      
68      private boolean content;
69      
70      /**
71       * The protected DOM element
72       */
73      private Element protectedElement;
74  
75      /**
76       * @return Id of the protected element
77       */
78      public String getWsuId() {
79          return wsuId;
80      }
81  
82      /**
83       * @param wsuId Id of the protected element
84       */
85      public void setWsuId(String wsuId) {
86          this.wsuId = wsuId;
87      }
88  
89      /**
90       * @return QName of the protected element
91       */
92      public QName getName() {
93          return name;
94      }
95  
96      /**
97       * @param name QName of the protected element
98       */
99      public void setName(QName name) {
100         this.name = name;
101     }
102     
103     /**
104      * @param element The protected DOM element to set
105      */
106     public void setProtectedElement(Element element) {
107         protectedElement = element;
108         String prefix = element.getPrefix();
109         if (prefix == null) {
110             name = 
111                 new QName(
112                     element.getNamespaceURI(), element.getLocalName()
113                 );
114         } else {
115             name = 
116                 new QName(
117                     element.getNamespaceURI(), element.getLocalName(), prefix
118                 );
119         }
120     }
121     
122     /**
123      * @return the protected DOM element
124      */
125     public Element getProtectedElement() {
126         return protectedElement;
127     }
128 
129     /**
130      * @return the xpath
131      */
132     public String getXpath() {
133         return xpath;
134     }
135 
136     /**
137      * @param xpath the xpath to set
138      */
139     public void setXpath(String xpath) {
140         this.xpath = xpath;
141     }
142 
143     /**
144      * @return the content
145      */
146     public boolean isContent() {
147         return content;
148     }
149 
150     /**
151      * @param content the content to set
152      */
153     public void setContent(boolean content) {
154         this.content = content;
155     }
156     
157     /**
158      * @return the algorithm used for encryption/signature
159      */
160     public String getAlgorithm() {
161         return algorithm;
162     }
163 
164     /**
165      * @param algo algorithm used for encryption
166      */
167     public void setAlgorithm(String algo) {
168         algorithm = algo;
169     }
170     
171     /**
172      * @return if this reference represents signed content, 
173      * the digest algorithm applied to the content.
174      */
175     public String getDigestAlgorithm() {
176         return this.digestAlgorithm;
177     }
178 
179     /**
180      * @param digestAlgorithm if this reference represents 
181      * signed content, the digest algorithm applied to the content.
182      */
183     public void setDigestAlgorithm(String digestAlgorithm) {
184         this.digestAlgorithm = digestAlgorithm;
185     }
186     
187     /**
188      * Set the Transform algorithm URIs used to transform the element before digest
189      */
190     public void setTransformAlgorithms(List<String> transformAlgorithms) {
191         this.transformAlgorithms = transformAlgorithms;
192     }
193     
194     /**
195      * Get the Transform algorithm URIs used to transform the element before digest
196      */
197     public List<String> getTransformAlgorithms() {
198         return transformAlgorithms;
199     }
200 
201 }