为xml文件实施mule pgp加密解密。解密时会引发错误
ERROR 2015-06-05 12:06:34,192 [Thread-8] org.mule.module.pgp.AbstractTransformPolicy: Invalid PGP message
java.lang.IllegalArgumentException: Invalid PGP message
at org.mule.module.pgp.DecryptStreamTransformer.initialize(DecryptStreamTransformer.java:79)
at org.mule.module.pgp.TransformContinuouslyPolicy$ContinuousWork.execute(TransformContinuouslyPolicy.java:60)
at org.mule.module.pgp.AbstractTransformPolicy$TransformerWork.run(AbstractTransformPolicy.java:109)
我调试了mule pgp包和DecryptStreamTransformer
public void initialize(OutputStream out) throws Exception
{
InputStream decodedInputStream = PGPUtil.getDecoderStream(this.toBeDecrypted);
PGPObjectFactory pgpF = new PGPObjectFactory(decodedInputStream);
Object o = pgpF.nextObject();
if (o == null)
{
throw new IllegalArgumentException("Invalid PGP message");
}
PGPObjectFactory将nextObject作为null返回的原因可能是什么。还在流元素
之后记录消息有效负载 <decrypt-transformer name="decryptTransformer" strategy-ref="pgpEncryptionStrategy"/>
<logger level="INFO" doc:name=" Message Logger" message="#[payload]"/>
<mulexml:jaxb-xml-to-object-transformer
jaxbContext-ref="jaxb" doc:name="JAXB-Unmarshaller"
returnClass="com.generated.Communication" />
有效负载显示为 org.mule.module.pgp.LazyTransformedInputStream@17d80e9。
如何将此实例修改为xml,以便mulexml jaxb元素可以将其编组为所需对象。
答案 0 :(得分:0)
如its source code中所示:
registerSourceType(DataTypeFactory.INPUT_STREAM);
jaxb-xml-to-object-transformer
接受任何输入流作为有效来源,因此问题不存在。