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.resourceResolvers;
20
21 import org.apache.xml.security.stax.ext.ResourceResolver;
22 import org.apache.xml.security.stax.ext.XMLSecurityConstants;
23 import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
24 import org.apache.wss4j.stax.ext.WSSConstants;
25
26 import javax.xml.namespace.QName;
27 import javax.xml.stream.events.Attribute;
28
29 public class ResolverSameDocument extends org.apache.xml.security.stax.impl.resourceResolvers.ResolverSameDocument {
30
31 public ResolverSameDocument() {
32 super();
33 }
34
35 public ResolverSameDocument(String uri) {
36 super(uri);
37 }
38
39 @Override
40 public ResourceResolver newInstance(String uri, String baseURI) {
41 return new ResolverSameDocument(uri);
42 }
43
44 @Override
45 public boolean matches(XMLSecStartElement xmlSecStartElement) {
46 return matches(xmlSecStartElement, XMLSecurityConstants.ATT_NULL_Id);
47 }
48
49 public boolean matches(XMLSecStartElement xmlSecStartElement, QName idAttributeNS) {
50 Attribute attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_WSU_ID);
51 if (attribute != null && attribute.getValue().equals(getId())) {
52 return true;
53 }
54
55 attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_ASSERTION_ID);
56 if (attribute != null && attribute.getValue().equals(getId())) {
57 return true;
58 }
59
60 attribute = xmlSecStartElement.getAttributeByName(WSSConstants.ATT_NULL_ID);
61 if (attribute != null && attribute.getValue().equals(getId())) {
62 return true;
63 }
64 return super.matches(xmlSecStartElement, idAttributeNS);
65 }
66
67 }