WSDocInfo wsDocInfo
) throws WSSecurityException {
List<WSDataRef> protectedRefs = new java.util.ArrayList<WSDataRef>();
List<?> referencesList = signedInfo.getReferences();
for (int i = 0; i < referencesList.size(); i++) {
Reference siRef = (Reference)referencesList.get(i);
String uri = siRef.getURI();
if (!"".equals(uri)) {
Element se = null;
List<?> transformsList = siRef.getTransforms();
for (int j = 0; j < transformsList.size(); j++) {
Transform transform = (Transform)transformsList.get(j);
if (STRTransform.TRANSFORM_URI.equals(transform.getAlgorithm())) {
NodeSetData data = (NodeSetData)siRef.getDereferencedData();
if (data != null) {
java.util.Iterator<?> iter = data.iterator();
Node securityTokenReference = null;
while (iter.hasNext()) {
Node node = (Node)iter.next();
if ("SecurityTokenReference".equals(node.getLocalName())) {
securityTokenReference = node;
break;
}
}
if (securityTokenReference != null) {
SecurityTokenReference secTokenRef =
new SecurityTokenReference(
(Element)securityTokenReference,
wssConfig.isWsiBSPCompliant()
);
se = STRTransformUtil.dereferenceSTR(doc, secTokenRef, wsDocInfo);
}
}
}
}
if (se == null) {
CallbackLookup callbackLookup = wsDocInfo.getCallbackLookup();
if (callbackLookup == null) {
callbackLookup = new DOMCallbackLookup(doc);
}
se = callbackLookup.getElement(uri, null, false);
}
if (se == null) {
throw new WSSecurityException(WSSecurityException.FAILED_CHECK);
}
WSDataRef ref = new WSDataRef();
ref.setWsuId(uri);
ref.setProtectedElement(se);
ref.setAlgorithm(signedInfo.getSignatureMethod().getAlgorithm());
ref.setDigestAlgorithm(siRef.getDigestMethod().getAlgorithm());
ref.setXpath(ReferenceListProcessor.getXPath(se));
protectedRefs.add(ref);
}
}
return protectedRefs;