If XMLSignatureInput is constructed by using the FileInputStream as octets source then the octet payload file can't be deleted on Windows platforms after usage.
Following test case illustrates this case:
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class DeletePayloadFile {
private static final String filename = "XmlSigInput_payload.txt";
private static final String content = "123456";
public static void main(String [] args) throws Exception {
//Create payload file inside scratch
Path payload = Paths.get(System.getProperty("user.dir", "."))
.resolve(filename);
Files.write(payload, content.getBytes());
File pf = payload.toFile();
FileInputStream fis = new FileInputStream(pf);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLSignatureInput sigInput = new XMLSignatureInput(fis);
sigInput.updateOutputStream(baos);
System.out.println("baos="+baos.toString()+" result="+baos.toString().equals(content));
if (!pf.delete()) {
throw new RuntimeException("Can't delete XMLSignatureInput payload file:"+filename);
}
}
}