public void mangleAndTwingleTwoSignaturesAdLibitumApacheStyle(Element signatureElement, SignatureImpl signature) throws XMLSecurityException, UnmarshallingException {
XMLSignature xmlSignature = new XMLSignature(signatureElement, "");
SignedInfo signedInfo = xmlSignature.getSignedInfo();
log.debug("Adding canonicalization and signing algorithms, and HMAC output length to Signature");
signature.setCanonicalizationAlgorithm(signedInfo.getCanonicalizationMethodURI());
signature.setSignatureAlgorithm(signedInfo.getSignatureMethodURI());
signature.setHMACOutputLength(getHMACOutputLengthValue(signedInfo.getSignatureMethodElement()));
org.apache.xml.security.keys.KeyInfo xmlSecKeyInfo = xmlSignature.getKeyInfo();
if (xmlSecKeyInfo != null) {
log.debug("Adding KeyInfo to Signature");
Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(
xmlSecKeyInfo.getElement());
KeyInfo keyInfo = (KeyInfo) unmarshaller.unmarshall(xmlSecKeyInfo.getElement());
signature.setKeyInfo(keyInfo);
}
signature.setXMLSignature(xmlSignature);
}