Camel PGPKeyAccessDataFormat CompressionAlgorithmTags.UNCOMPRESSED抛出异常

时间:2014-06-24 09:47:57

标签: java apache-camel

使用PGPDataFormat进行无压缩签名和加密时

encryptHeaders.put(PGPDataFormat.COMPRESSION_ALGORITHM, CompressionAlgorithmTags.UNCOMPRESSED);

我收到以下错误。

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: [Body is file based: C:\Users\GELBES~1\AppData\Local\Temp\encrypted802002743222132830]]
    at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1379) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:622) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:463) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:243) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:375) [camel-core-2.13.1.jar:2.13.1]
    at camel.EncryptDecryptRouteBuilderTest.onEncrypted(EncryptDecryptRouteBuilderTest.java:55) [test-classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_55]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_55]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_55]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_55]
    at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:407) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:278) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:251) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:113) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:73) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:378) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:184) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:233) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:375) [camel-core-2.13.1.jar:2.13.1]
    at camel.EncryptDecryptRouteBuilderTest.TestEncryption(EncryptDecryptRouteBuilderTest.java:134) [test-classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_55]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_55]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_55]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_55]
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) [testng-6.8.8.jar:na]
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) [testng-6.8.8.jar:na]
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) [testng-6.8.8.jar:na]
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) [testng-6.8.8.jar:na]
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) [testng-6.8.8.jar:na]
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) [testng-6.8.8.jar:na]
    at org.testng.TestRunner.privateRun(TestRunner.java:767) [testng-6.8.8.jar:na]
    at org.testng.TestRunner.run(TestRunner.java:617) [testng-6.8.8.jar:na]
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:348) [testng-6.8.8.jar:na]
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343) [testng-6.8.8.jar:na]
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305) [testng-6.8.8.jar:na]
    at org.testng.SuiteRunner.run(SuiteRunner.java:254) [testng-6.8.8.jar:na]
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) [testng-6.8.8.jar:na]
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) [testng-6.8.8.jar:na]
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) [testng-6.8.8.jar:na]
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) [testng-6.8.8.jar:na]
    at org.testng.TestNG.run(TestNG.java:1057) [testng-6.8.8.jar:na]
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) [testng-6.8.8.jar:na]
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) [testng-6.8.8.jar:na]
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) [testng-6.8.8.jar:na]
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125) [testng-plugin.jar:na]
Caused by: java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162) ~[na:1.7.0_55]
    at java.io.BufferedInputStream.read(BufferedInputStream.java:325) ~[na:1.7.0_55]
    at org.bouncycastle.bcpg.BCPGInputStream.read(BCPGInputStream.java:79) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream$PartialInputStream.read(BCPGInputStream.java:376) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream.read(BCPGInputStream.java:79) ~[classes/:na]
    at java.io.InputStream.read(InputStream.java:101) ~[na:1.7.0_55]
    at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:103) ~[na:1.7.0_51]
    at javax.crypto.CipherInputStream.read(CipherInputStream.java:177) ~[na:1.7.0_51]
    at org.bouncycastle.bcpg.BCPGInputStream.read(BCPGInputStream.java:42) ~[classes/:na]
    at org.bouncycastle.openpgp.PGPEncryptedData$TruncatedStream.read(PGPEncryptedData.java:42) ~[classes/:na]
    at java.io.InputStream.read(InputStream.java:170) ~[na:1.7.0_55]
    at org.bouncycastle.util.io.TeeInputStream.read(Unknown Source) ~[bcprov-jdk15on-1.49.jar:1.49.0]
    at org.bouncycastle.bcpg.BCPGInputStream.read(BCPGInputStream.java:79) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream.read(BCPGInputStream.java:79) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream$PartialInputStream.read(BCPGInputStream.java:376) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream.read(BCPGInputStream.java:79) ~[classes/:na]
    at org.bouncycastle.util.io.Streams.readFully(Unknown Source) ~[bcprov-jdk15on-1.49.jar:1.49.0]
    at org.bouncycastle.bcpg.BCPGInputStream.readFully(BCPGInputStream.java:101) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream.readFully(BCPGInputStream.java:117) ~[classes/:na]
    at org.bouncycastle.bcpg.MPInteger.<init>(MPInteger.java:21) ~[classes/:na]
    at org.bouncycastle.bcpg.SignaturePacket.<init>(SignaturePacket.java:133) ~[classes/:na]
    at org.bouncycastle.bcpg.BCPGInputStream.readPacket(BCPGInputStream.java:248) ~[classes/:na]
    at org.bouncycastle.openpgp.PGPSignature.<init>(PGPSignature.java:61) ~[classes/:na]
    at org.bouncycastle.openpgp.PGPObjectFactory.nextObject(PGPObjectFactory.java:88) ~[classes/:na]
    at camel.SimstatPGPKeyAccessDataFormat.verifySignature(SimstatPGPKeyAccessDataFormat.java:442) ~[classes/:na]
    at camel.SimstatPGPKeyAccessDataFormat.unmarshal(SimstatPGPKeyAccessDataFormat.java:372) ~[classes/:na]
    at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) ~[camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:73) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:378) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:184) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124) [camel-core-2.13.1.jar:2.13.1]
    at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:233) [camel-core-2.13.1.jar:2.13.1]

似乎它实际上不是骆驼问题,而是一个充气城堡。 而且最重要的是,仅在某些测试中发生异常。 例如。当我尝试解密原始大小为105字节的ectypted文件时,测试成功运行,但是当我在106字节的原始文件上运行测试时,测试在解密加密文件时失败。 使用选项CompressionAlgorithmTags.UNCOMPRESSED进行所有测试。 我试图调试源类但没有成功。

Camel版本2.13.1

谢谢

0 个答案:

没有答案