Escolar Documentos
Profissional Documentos
Cultura Documentos
bo
SISTEMA DE FACTURACIÓN
ELECTRÓNICA
1
FIRMADO DE DOCUMENTO
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xml.security.algorithms.MessageDigestAlgorithm;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.ElementProxy;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
ElementProxy.setDefaultPrefix(Constants.SignatureSpecNS, “”);
SISTEMA DE FACTURACIÓN
ELECTRÓNICA
2
root.appendChild(signature.getElement());
return baos.toString().getBytes();
}
private Document leerXML(byte datos[]) throws
ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory factory = DocumentBuilderFactory.
newInstance();
DocumentBuilder builder;
factory.setNamespaceAware(true);
builder = factory.newDocumentBuilder();