Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
验证签名XADES抛出java.lang.ArrayIndexOutOfBoundsException:0_Java_Xml Signature_Xades4j - Fatal编程技术网

验证签名XADES抛出java.lang.ArrayIndexOutOfBoundsException:0

验证签名XADES抛出java.lang.ArrayIndexOutOfBoundsException:0,java,xml-signature,xades4j,Java,Xml Signature,Xades4j,我需要验证签名xml文件中的签名XADE。我使用xades4jv。1.4.0但当调用方法verify时抛出java.lang.ArrayIndexOutOfBoundsException:0。 有一些档案工作,另一个没有 我在调试模式下尝试了checkForm-XAdESFormChecker类中的异常抛出方法 我的代码: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

我需要验证签名xml文件中的签名XADE。我使用xades4jv。1.4.0但当调用方法verify时抛出java.lang.ArrayIndexOutOfBoundsException:0。 有一些档案工作,另一个没有

我在调试模式下尝试了checkForm-XAdESFormChecker类中的异常抛出方法

我的代码:

                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware(true);
                DocumentBuilder db = dbf.newDocumentBuilder();
                Document doc = db.parse(inputStream);
                DOMHelper.useIdAsXmlId(doc.getDocumentElement());                    
                NodeList nList = doc.getElementsByTagName("ds:Signature");
                Element elem = null;                      
                for (int temp = 0; temp < nList.getLength(); temp++) {
                    Node nNode = nList.item(temp);
                    if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                        elem = (Element) nNode;
                        elem.setIdAttributeNS(null, "Id", true);
                    }
                }
                data = item.getData();               
                CertificateValidationProvider certValidator = new CertificateValidationProviderImpl();
                XadesVerificationProfile p = new XadesVerificationProfile(certValidator);
                XadesVerifier v = p.newVerifier();
                SignatureSpecificVerificationOptions opts = new SignatureSpecificVerificationOptions().useDataForAnonymousReference(data);   
                XAdESVerificationResult result = v.verify(elem, opts);
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db=dbf.newDocumentBuilder();
文档doc=db.parse(inputStream);
useIdAsXmlId(doc.getDocumentElement());
NodeList nList=doc.getElementsByTagName(“ds:签名”);
元素elem=null;
对于(int-temp=0;temp
签名:

你能帮我吗? 错误是什么


编辑堆栈跟踪 *java.lang.ArrayIndexOutOfBoundsException:0 位于xades4j.verification.XAdESFormChecker$XAdESFormDesc.getPrevious(XAdESFormChecker.java:109) 位于xades4j.verification.XAdESFormChecker.checkForm(XAdESFormChecker.java:55) 在xades4j.verification.XadesVerifierImpl.verify(XadesVerifierImpl.java:213) 在it.yyy.kkframework.albo.inserimentoricheestacontroller.listenerUploadDoc(inserimentoricheestacontroller.java:1811) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中 位于java.lang.reflect.Method.invoke(Method.java:597) 位于com.sun.el.parser.AstValue.invoke(AstValue.java:187) 位于com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297) 在com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)上 位于org.richfaces.event.MethodExpressionEventListener.processEvent(MethodExpressionEventListener.java:125) 位于org.richfaces.view.facelets.FileUploadHandler$FileUploadListenerImpl.processFileUpload(FileUploadHandler.java:55)
…xades4j基于ETSI TS 101 903(XAdES 1.4.1)。然而,您的签名包含SigningCertificateV2,这是在最近的XAdES规范中定义的一个属性,xades4j还不支持该属性。这是导致错误的原因,因为SigningCertificate属性不存在


库不应该抛出“array out-bounds”异常(这将被修复,因为它是一个bug),但它将无法验证签名。如果不是因为这个bug,您会看到这一行中抛出了更明显的异常:

您应该添加stacktrace,以便于其他人提供帮助。@BerndBöllert我粘贴了stack trace,提前感谢您的回复。@lgoncalves您能帮我吗?谢谢,那么我如何用java验证这个签名?现在,只使用不同的库。我相信还有其他人;也许有些人支持更新的标准