Error in bouncycastle readObject () - Demoiselle-certificate

2

I have been using the Demoiselle-certificate (2.0.0) for some time and today I came across the following error when calling the CertificateManager class the certificateManager.load (class) method:

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 for 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 someone has gone through this, is passing or have some idea of what can be, please kindly appreciate the 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);

Application with file:

        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);
    
asked by anonymous 31.07.2015 / 15:56

2 answers

0

Testing with the 2.0.1-SNAPSHOT version has verified that the same error continues to occur.

When you perform a more accurate debug, comparing 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 is the details:

In a class of its own implementation, an instance of the CertificateManager class is performed and the load method is called.

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

After this, the CertificateManager load method is executed.

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 CertificateManager class made a call to the load method of the IOIDExtensionLoader class, as follows:

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

The ICPBrasilExtensionLoader class then loads the action into the load method of the IOIDExtensionLoader class. When doing the debug, it was verified that before entering the switch (annotation.type()) { , an instance of the BasicCertificate class is created, 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, but in version 2.0.0 it is created but it shows a notification that an exception was thrown, as can be seen below:

Version 1.0.9



Version2.0.0



In this way, when reading the line if (cert.hasCertificatePF()) { , exception occurs.

    
12.08.2015 / 15:38
0

The impression is that 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 lib bcprov-jdk51on is in / src / main / webapp / and that it is signed properly.

    
05.08.2015 / 19:50