8049244: XML Signature performance issue caused by unbuffered signature data

Reviewed-by: xuelei
This commit is contained in:
Sean Mullan 2014-07-08 14:35:05 -04:00
parent 723bfa2b58
commit f5e233d84b

View File

@ -221,8 +221,17 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
}
OutputStream os = new UnsyncBufferedOutputStream(bos);
DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true);
try {
os.close();
((DOMCanonicalizationMethod)
canonicalizationMethod).canonicalize(subTree, context, os);
} catch (TransformException te) {
throw new XMLSignatureException(te);
}
try {
os.flush();
} catch (IOException e) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, e.getMessage(), e);
@ -230,15 +239,6 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
// Impossible
}
DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true);
try {
((DOMCanonicalizationMethod)
canonicalizationMethod).canonicalize(subTree, context, bos);
} catch (TransformException te) {
throw new XMLSignatureException(te);
}
byte[] signedInfoBytes = bos.toByteArray();
// this whole block should only be done if logging is enabled
@ -253,6 +253,15 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
}
this.canonData = new ByteArrayInputStream(signedInfoBytes);
try {
os.close();
} catch (IOException e) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, e.getMessage(), e);
}
// Impossible
}
}
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)