2015-05-22 41 views
0

我想用Bouncy Castle解密一些私钥(.pfx X509Certificate)。 如果我运行的代码独立(JUnit的),它工作正常,但是当我的Arquillian上wildfly运行它部署为war文件,我遇到了一些问题:使用wildfly提供的bouncycastle

org.jboss.arquillian.test.spi.ArquillianProxyException: javax.ejb.EJBException : JBAS014580: Unexpected Error 
[Proxied because : Original exception caused: class java.lang.ClassFormatError: Absent Code attribute in method 
that is not native or abstract in class file javax/ejb/EJBException] 

我认为是的Arquillian封装真正的例外,但日志文件中不会再出现错误。

在我宣布它提供的pom文件中,使用提供的版本。

安装的版本是:

$WILDFLY_HOME\modules\system\layers\base\org\bouncycastle\main\bcmail-jdk15on-1.50.jar 
$WILDFLY_HOME\modules\system\layers\base\org\bouncycastle\main\bcpkix-jdk15on-1.50.jar 
$WILDFLY_HOME\modules\system\layers\base\org\bouncycastle\main\bcprov-jdk15on-1.50.jar 

我还试图用直接与范围,因为编译/运行时POM文件中指定的版本bcprov-jdk16,但它并没有反正工作。

在这一点上特别是出现的错误:

org.bouncycastle.x509.extension.X509ExtensionUtil.getIssuerAlternativeNames(java.security.cert.X509Certificate); 

X509ExtensionUtil.getIssuerAlternativeNames(certificate) = >Unknown type "org.bouncycastle.x509.extension.X509ExtensionUtil"< 

任何人都遇到过这个问题,或者知道我该如何解决?有小费吗?

回答

0

我只使用Java的API 8解决我的问题,为后续:

Collection<?> altNames = certificate.getSubjectAlternativeNames(); 
     for (Object i : altNames) { 
      List<Object> item = (java.util.List) i; 
      Integer type = (Integer) item.get(0); 
      try { 
       if (type > 0) { 
        continue; 
       } 
       String[] arr = StringEscapeUtils.escapeHtml(new String((byte[]) item.get(1))).split(";"); 
       return Arrays.asList(arr) 
         .stream() 
         .map(k -> k.trim()) 
         .filter(u -> isCNPJ(u)) 
         .findFirst().get(); 
      } catch (Exception e) { 
       LOG.error(e.getMessage(), e); 
      } 
     } 
     return null; 

isCNPJ仅仅是一个过滤只有我需要值的方法。 StringEscapeUtils是apache commons lang类

相关问题