Tenho um codigo que utiliza a linha acima porem o NetBeans esta recusando a linha com a mensagem : not a statement
not a statement
‘(’ or ‘[’ expected
not a statement
cannot find symbol
symbol: variable Transform
location: class assinador
O codigo é o seguinte:
public static void assinarDocumento(String localDocumento) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document doc = dbf.newDocumentBuilder().parse(new FileInputStream(localDocumento));
System.out.println(“Documento ok!”);
sig = XMLSignatureFactory.getInstance(“DOM”);
ArrayList<Transform> transformList = new ArrayList<Transform>
Transform enveloped = sig.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null);
Transform c14n = sig.newTransform(C14N_TRANSFORM_METHOD, (TransformParameterSpec) null);
transformList.add(enveloped);
transformList.add(c14n);
NodeList elements = doc.getElementsByTagName("infNFe");
org.w3c.dom.Element el = (org.w3c.dom.Element) elements.item(0);
String id = el.getAttribute("Id");
Reference r = sig.newReference("#".concat(id), sig.newDigestMethod(DigestMethod.SHA1, null),
transformList,
null, null);
si = sig.newSignedInfo(
sig.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE,
(C14NMethodParameterSpec) null),
sig.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
Collections.singletonList(r));
KeyInfoFactory kif = sig.getKeyInfoFactory();
List x509Content = new ArrayList();
x509Content.add(cert);
X509Data xd = kif.newX509Data(x509Content);
ki = kif.newKeyInfo(Collections.singletonList(xd));
DOMSignContext dsc = new DOMSignContext(getChavePrivada(), doc.getDocumentElement());
XMLSignature signature = sig.newXMLSignature(si, ki);
signature.sign(dsc);
OutputStream os = new FileOutputStream("Nome do arquivo de saída");
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer();
trans.transform(new DOMSource(doc), new StreamResult(os));
}