2015-05-22 42 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類

相關問題