1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.wss4j.stax.impl.transformer;
20
21 import org.apache.wss4j.common.ext.WSSecurityException;
22 import org.apache.xml.security.exceptions.XMLSecurityException;
23 import org.apache.xml.security.stax.ext.Transformer;
24 import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
25 import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32 public class STRTransformer extends TransformIdentity {
33
34 @Override
35 public void setTransformer(Transformer transformer) throws XMLSecurityException {
36 if (!(transformer instanceof Canonicalizer20010315_Excl)) {
37 throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
38 }
39 List<String> inclusiveNamespacesPrefixList = new ArrayList<>();
40 inclusiveNamespacesPrefixList.add("#default");
41 Map<String, Object> transformerProperties = new HashMap<>();
42 transformerProperties.put(
43 Canonicalizer20010315_Excl.INCLUSIVE_NAMESPACES_PREFIX_LIST, inclusiveNamespacesPrefixList);
44 transformerProperties.put(Canonicalizer20010315_Excl.PROPAGATE_DEFAULT_NAMESPACE, Boolean.TRUE);
45 transformer.setProperties(transformerProperties);
46 super.setTransformer(transformer);
47 }
48
49 }