160 throw new MarshalException(error);
161 }
162 transformElem = DOMUtils.getNextSiblingElement(transformElem);
163 }
164 }
165 if (transforms.isEmpty()) {
166 this.transforms = Collections.emptyList();
167 } else {
168 this.transforms = Collections.unmodifiableList(transforms);
169 }
170 }
171
172 public String getURI() {
173 return uri;
174 }
175
176 public String getType() {
177 return type;
178 }
179
180 public List getTransforms() {
181 return transforms;
182 }
183
184 public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
185 throws MarshalException
186 {
187 Document ownerDoc = DOMUtils.getOwnerDocument(parent);
188 Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod",
189 XMLSignature.XMLNS, dsPrefix);
190
191 // add URI and Type attributes
192 DOMUtils.setAttribute(rmElem, "URI", uri);
193 DOMUtils.setAttribute(rmElem, "Type", type);
194
195 // add Transforms elements
196 if (!transforms.isEmpty()) {
197 Element transformsElem = DOMUtils.createElement(ownerDoc,
198 "Transforms",
199 XMLSignature.XMLNS,
200 dsPrefix);
228 */
229 URIDereferencer deref = context.getURIDereferencer();
230 if (deref == null) {
231 deref = DOMURIDereferencer.INSTANCE;
232 }
233
234 Data data = deref.dereference(this, context);
235
236 // pass dereferenced data through Transforms
237 try {
238 for (Transform transform : transforms) {
239 data = ((DOMTransform)transform).transform(data, context);
240 }
241 } catch (Exception e) {
242 throw new URIReferenceException(e);
243 }
244
245 // guard against RetrievalMethod loops
246 if ((data instanceof NodeSetData) && Utils.secureValidation(context)) {
247 NodeSetData nsd = (NodeSetData)data;
248 Iterator i = nsd.iterator();
249 if (i.hasNext()) {
250 Node root = (Node)i.next();
251 if ("RetrievalMethod".equals(root.getLocalName())) {
252 throw new URIReferenceException(
253 "It is forbidden to have one RetrievalMethod point " +
254 "to another when secure validation is enabled");
255 }
256 }
257 }
258
259 return data;
260 }
261
262 public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context)
263 throws URIReferenceException
264 {
265 try {
266 ApacheData data = (ApacheData)dereference(context);
267 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
268 dbf.setNamespaceAware(true);
|
160 throw new MarshalException(error);
161 }
162 transformElem = DOMUtils.getNextSiblingElement(transformElem);
163 }
164 }
165 if (transforms.isEmpty()) {
166 this.transforms = Collections.emptyList();
167 } else {
168 this.transforms = Collections.unmodifiableList(transforms);
169 }
170 }
171
172 public String getURI() {
173 return uri;
174 }
175
176 public String getType() {
177 return type;
178 }
179
180 public List<Transform> getTransforms() {
181 return transforms;
182 }
183
184 public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
185 throws MarshalException
186 {
187 Document ownerDoc = DOMUtils.getOwnerDocument(parent);
188 Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod",
189 XMLSignature.XMLNS, dsPrefix);
190
191 // add URI and Type attributes
192 DOMUtils.setAttribute(rmElem, "URI", uri);
193 DOMUtils.setAttribute(rmElem, "Type", type);
194
195 // add Transforms elements
196 if (!transforms.isEmpty()) {
197 Element transformsElem = DOMUtils.createElement(ownerDoc,
198 "Transforms",
199 XMLSignature.XMLNS,
200 dsPrefix);
228 */
229 URIDereferencer deref = context.getURIDereferencer();
230 if (deref == null) {
231 deref = DOMURIDereferencer.INSTANCE;
232 }
233
234 Data data = deref.dereference(this, context);
235
236 // pass dereferenced data through Transforms
237 try {
238 for (Transform transform : transforms) {
239 data = ((DOMTransform)transform).transform(data, context);
240 }
241 } catch (Exception e) {
242 throw new URIReferenceException(e);
243 }
244
245 // guard against RetrievalMethod loops
246 if ((data instanceof NodeSetData) && Utils.secureValidation(context)) {
247 NodeSetData nsd = (NodeSetData)data;
248 Iterator<?> i = nsd.iterator();
249 if (i.hasNext()) {
250 Node root = (Node)i.next();
251 if ("RetrievalMethod".equals(root.getLocalName())) {
252 throw new URIReferenceException(
253 "It is forbidden to have one RetrievalMethod point " +
254 "to another when secure validation is enabled");
255 }
256 }
257 }
258
259 return data;
260 }
261
262 public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context)
263 throws URIReferenceException
264 {
265 try {
266 ApacheData data = (ApacheData)dereference(context);
267 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
268 dbf.setNamespaceAware(true);
|