WSDocInfo wsDocInfo
) throws WSSecurityException {
List<WSDataRef> protectedRefs = new 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 = dereferenceSTR(doc, siRef, requestData, wsDocInfo);
// If an STR Transform is not used then just find the cached element
boolean attachment = false;
if (se == null) {
Data dereferencedData = siRef.getDereferencedData();
if (dereferencedData instanceof NodeSetData) {
NodeSetData data = (NodeSetData)dereferencedData;
java.util.Iterator<?> iter = data.iterator();
while (iter.hasNext()) {
Node n = (Node)iter.next();
if (n instanceof Element) {
se = (Element)n;
break;
}
}
} else if (dereferencedData instanceof OctetStreamData) {
se = doc.createElementNS("http://docs.oasis-open.org/wss/oasis-wss-SwAProfile-1.1", "attachment");
attachment = true;
}
}
if (se == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_CHECK);
}
WSDataRef ref = new WSDataRef();
ref.setWsuId(uri);
ref.setProtectedElement(se);
ref.setAlgorithm(signedInfo.getSignatureMethod().getAlgorithm());
ref.setDigestAlgorithm(siRef.getDigestMethod().getAlgorithm());
ref.setAttachment(attachment);
// Set the Transform algorithms as well
@SuppressWarnings("unchecked")
List<Transform> transforms = (List<Transform>)siRef.getTransforms();
List<String> transformAlgorithms = new ArrayList<String>(transforms.size());
for (Transform transform : transforms) {
transformAlgorithms.add(transform.getAlgorithm());
}
ref.setTransformAlgorithms(transformAlgorithms);