Pessoal eu gerei um xml assinado até ai funcionou, quando eu vou recurepar o xml ele não acha a tag Signature.
Código java
[code]NodeList nl = xml.getElementsByTagNameNS(XMLSignature.XMLNS, “Signature”);
if (nl.getLength() == 0) {
throw new Exception(“Não foi possivel achar o elemente de assinatura”);
}[/code]
Segue o xml
[code]
<?xml version="1.0" encoding="UTF-8"?>
Video Game
10.29
My Name
One Network Drive
Burlington
MA
United States
01803
tVicGh6V+8c.....
ewqy0rhVPeFrqeimvHRhT5ASeEb....
CN=LAROD:11111111111,OU=teste,OU=teste,O=teste,C=BR
MIIFIjCCBAqgAwIBAgIQIT...
[/code]
Alguém pode me ajudar ??? Vlw
Consegui nextuser, agora está dando outro erro quando eu vou gerar um XMLSignature ele da uma excpetion.
Código Java
DOMValidateContext valContext = new DOMValidateContext (new X509KeySelector(), nl.item(0));
XMLSignature signature = fac.unmarshalXMLSignature(valContext);
Exception
Exception in thread "main" javax.xml.crypto.MarshalException: Document implementation must support DOM Level 2 and be namespace aware
at org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory.unmarshal(DOMXMLSignatureFactory.java:157)
at org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory.unmarshalXMLSignature(DOMXMLSignatureFactory.java:125)
Andei pesquisando no google mas ainda não encontrei nada.
o erro da em qual das duas linhas?
Eu esqueci de colocar kkkk, é na linha 2.
é isso que vc ta tentando fazer…
[code] NodeList signedDataList = data.getElementsByTagNameNS(“http://www.w3.org/2000/09/xmldsig#”, “Signature”);
int sizeList = signedDataList.getLength();
if (sizeList == 0) {
Exception ex = new Exception(“No XML signature provided”);
throw ex;
} else {
Element envelopedSig = (Element) signedDataList.item(sizeList - 1);
X509Certificate cert = null;
XMLSignature sig;
try {
sig = new XMLSignature(envelopedSig, null);
} catch (Exception e) {
Exception ex = new Exception("No XML signature provided");
throw ex;
}
// Recupera o keyinfo.
KeyInfo ki = sig.getKeyInfo();
if (ki == null || !ki.containsX509Data()) {
return Boolean.FALSE;
}
try {
cert = sig.getKeyInfo().getX509Certificate();
cert.checkValidity();
} catch (Exception e) {
return Boolean.FALSE;
}
if (cert == null) {
return Boolean.FALSE;
}
boolean isValid;
try {
isValid = sig.checkSignatureValue(cert);
} catch (XMLSignatureException e) {
return Boolean.FALSE;
}
return Boolean.valueOf(isValid);
}[/code]
Acho que descobri o problema é quando eu dou um getElementByTagName ele não ta trazendo o localName do node.