Error in bouncycastle readObject() - Demoiselle-Certificate

Asked

Viewed 362 times

2

I have been using the Demoiselle-Certification(2.0.0) for some time and today I came across the following error when called the Certificatemanager class the certificateManager.load(class):

10:35:07,632 GRAVE [javax.enterprise.resource.webcontainer.jsf.context] (http--127.0.0.1-8080-5) org.jboss.interceptor.proxy.InterceptorException: java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/ASN1Primitive;: javax.faces.event.AbortProcessingException: org.jboss.interceptor.proxy.InterceptorException: java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/ASN1Primitive;

The error is by not finding the method org.bouncycastle.asn1.ASN1InputStream.readObject()

        Caused by: org.jboss.interceptor.proxy.InterceptorException: java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/ASN1Primitive;
                at org.jboss.interceptor.proxy.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:151) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                at br.gov.frameworkdemoiselle.exception.ExceptionHandlerInterceptor.manage(ExceptionHandlerInterceptor.java:239) [demoiselle-core-2.5.0.jar:]
                at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source) [:1.7.0_79]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79]
                at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79]
                at org.jboss.interceptor.proxy.InterceptorInvocation$InterceptorMethodInvocation.invoke(InterceptorInvocation.java:72) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                at org.jboss.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:82) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                at org.jboss.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:133) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                at org.jboss.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:112) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:53) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at br.com.djcloud.view.EmpresaManutencaoEditMB$Proxy$_$$_WeldSubclass.validarCertificado(EmpresaManutencaoEditMB$Proxy$_$$_WeldSubclass.java) [classes:]
                at br.com.djcloud.view.EmpresaManutencaoEditMB$Proxy$_$$_WeldClientProxy.validarCertificado(EmpresaManutencaoEditMB$Proxy$_$$_WeldClientProxy.java) [classes:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79]
                at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79]
                at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
                at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
                at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
                ... 36 more
        Caused by: java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/ASN1Primitive;
                at br.gov.frameworkdemoiselle.certificate.oid.OIDGeneric.getInstance(OIDGeneric.java:80) [demoiselle-certificate-core-2.0.0.jar:]
                at br.gov.frameworkdemoiselle.certificate.extension.CertificateExtra.<init>(CertificateExtra.java:98) [demoiselle-certificate-core-2.0.0.jar:]
                at br.gov.frameworkdemoiselle.certificate.extension.ICPBRSubjectAlternativeNames.<init>(ICPBRSubjectAlternativeNames.java:56) [demoiselle-certificate-core-2.0.0.jar:]
                at br.gov.frameworkdemoiselle.certificate.extension.BasicCertificate.getICPBRSubjectAlternativeNames(BasicCertificate.java:286) [demoiselle-certificate-core-2.0.0.jar:]
                at br.gov.frameworkdemoiselle.certificate.extension.BasicCertificate.hasCertificatePF(BasicCertificate.java:313) [demoiselle-certificate-core-2.0.0.jar:]
                at br.gov.frameworkdemoiselle.certificate.extension.ICPBrasilExtensionLoader.load(ICPBrasilExtensionLoader.java:58) [demoiselle-certificate-core-2.0.0.jar:]
                at br.gov.frameworkdemoiselle.certificate.CertificateManager.load(CertificateManager.java:110) [demoiselle-certificate-core-2.0.0.jar:]
                at br.com.djsystem.seguranca.util.DJCertImpl.lerArquivo(DJCertImpl.java:195) [classes:]
                at br.com.djcloud.view.EmpresaManutencaoEditMB.validarCertificado(EmpresaManutencaoEditMB.java:335) [classes:]
                at br.com.djcloud.view.EmpresaManutencaoEditMB$Proxy$_$$_WeldSubclass.validarCertificado(EmpresaManutencaoEditMB$Proxy$_$$_WeldSubclass.java) [classes:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79]
                at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79]
                at org.jboss.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:114) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                at org.jboss.interceptor.proxy.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:143) [jboss-interceptor-core-2.0.0.Final.jar:2.0.0.Final]
                ... 56 more

If anyone has ever been through this, is going through or has any idea what it might be, please, thank you for your attention.

Edit: application using certificate installed:

 FacesContext context = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    setCert((java.security.cert.X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"));
    CertificateManager cm = new CertificateManager(getCert()[0], isValidarCert());
    setCertificadoString(getCert()[0].toString());
    cm.load(this);

File application:

        KeyStore keyStore = (new FileSystemKeyStoreLoader(file)).getKeyStore(senhaCertificado.trim());

        Enumeration<?> enumeration = keyStore.aliases();
        String alias = (String) enumeration.nextElement();

        x509Certificate = (X509Certificate) keyStore.getCertificate(alias);
    CertificateManager cm = new CertificateManager(x509Certificate , false);
    cm.load(this);
  • Hi Michel, sorry it took me so long to reply, but I’ve been having some problems solving these days. Is there any way to include POM.XML as well? Or even who knows how to share (github) the project or part of it that is generating the error?

2 answers

0

The impression is that the lib bcprov-jdk15on is missing or that it may be corrupted. Is the error when you run the applet? If it is, in this case you need to check if the lib bcprov-jdk51on is in /src/main/webapp/ and is signed correctly.

  • Until a few days it worked, it processed the certificate, it extracted the data in a class, according to Demoiselle’s documentation, but suddenly it didn’t work anymore... The error occurs when the certificateManager.load(class) method is called. I will attach the pom, or load part of the project... Thanks for your attention.

  • Insert as directed the dependency, but the error persists, who reads the certificate, is the Demoiselle-Certificate, use version 2.0.0... I noticed that the error occurred after the sourceforge problems....

  • It may be that after the sourceforge problem, some problem has happened and has corrupted your lib. But you still haven’t confirmed if the problem is occurring when running an Applet? With a part of the code it is possible to try to reproduce the error.

  • Yes the same problem occurs in Applet... I also tested using a new web project from Demoiselle, in our application we used the method in two ways, one of them loading the file by uploading the first faces, opening it with the password and then reading itwith certificateManager and other use is receiving the certificate installed in the client’s browser, through Httpservletrequest, and both return the same error. I’m going to ask the question trexos of the code how we use the methods.

  • Thanks again for your attention, Saito!

  • Have you ever deleted the libs from the local repository? And POM.XML was still missing, but anyway try using version 2.0.0-SNAPSHOT of the component. So you can check if the problem is from the version For this you need to configure the repository: <Repository> <id>Demoiselle.sourceforge.net-snapshot</id> <url>http://demoiselle.sourceforge.net/repository/snapshot</url> </Repository>

  • Hello Saito, I made a test application using the parking example so you can check what happens. It is only necessary to log in, because I put the reading of the certificate on the main screen. There it is necessary to select the certificate, to load. After that enter the password and click the validate button. This way the error will occur. I realized that apart from the jasperReport dependency the error no longer occurs, so I don’t know what might be happening. Here is the link to download the sample application: https://www.dropbox.com/s/8h80qc6y1go5wv0/%40Certificado.zip? dl=0 . Thank you.

Show 2 more comments

0


When testing with the version 2.0.1-SNAPSHOT has been verified that the same error keeps happening.

When performing a more accurate debug, comparing the versions 1.0.9 (Version that does not occur the problem) and the latest versions (2.0.0 and 2.0.1-SNAPSHOT), it was identified where the error occurs. Below follows the details:

In a proper implementation class, an instance of the class is performed Certificatemanager and is called the load method.

CertificateManager cm = new CertificateManager(arqx509, false);
cm.load(this);

After that, the load method of the Certificatemanager

public void load(Object object) {
    Field[] fields = object.getClass().getDeclaredFields();
    for (Field field : fields) {
        for (Annotation annotation : field.getAnnotations()) {
            if (annotation.annotationType().isAnnotationPresent(OIDExtension.class)) {
                OIDExtension oid = annotation.annotationType().getAnnotation(OIDExtension.class);

                Class<? extends IOIDExtensionLoader> loaderClass = oid.loader();
                try {
                    IOIDExtensionLoader loader = loaderClass.newInstance();
                    loader.load(object, field, x509);
                } catch (IllegalAccessException | InstantiationException e) {
                    throw new CertificateCoreException("Error: Could not initialize atribute \"" + field.getName() + "\"", e);
                }
            }
        }
    }
}

Then the class Certificatemanager called the load method for the class Ioidextensionloader, as below:

IOIDExtensionLoader loader = loaderClass.newInstance();
loader.load(object, field, x509);

Then the action is forwarded to the class load method Icpbrasilextensionloader, that is who makes the implementation of Ioidextensionloader. When debugging, it was checked that before entering the switch (annotation.type()) {, an instance of the class is created Basiccertificate, passing as parameter the file X509, as below:

 @Override
public void load(Object object, Field field, X509Certificate x509) {
    if (field.isAnnotationPresent(ICPBrasilExtension.class)) {
        ICPBrasilExtension annotation = field.getAnnotation(ICPBrasilExtension.class);

        Object keyValue;
        try {

            BasicCertificate cert = new BasicCertificate(x509); <-- AQUI

            switch (annotation.type()) {
                case CPF:
                    if (cert.hasCertificatePF()) {
                        keyValue = cert.getICPBRCertificatePF().getCPF();
                    } else {
                        keyValue = "";
                    }

Since in version 1.0.9 this instance is created without problems, however in version 2.0.0 it is created but shows a notification that an Exception has been launched, as can be seen below:

Version 1.0.9

inserir a descrição da imagem aqui

Version 2.0.0

inserir a descrição da imagem aqui

Thus while reading the line if (cert.hasCertificatePF()) { occurs to Exception.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.