它最基本的是加密/解密交换所需的全部是共享密钥。如果一个或多个 Crypto 数据格式实例配置了这个密钥,则格式可用于加密一个路由(或部分)中的有效负载,并在另一个路由中解密。例如,使用 Java DSL,如下所示:
KeyGenerator generator = KeyGenerator.getInstance("DES");
CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
from("direct:basic-encryption")
.marshal(cryptoFormat)
.to("mock:encrypted")
.unmarshal(cryptoFormat)
.to("mock:unencrypted");
KeyGenerator generator = KeyGenerator.getInstance("DES");
CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", generator.generateKey());
from("direct:basic-encryption")
.marshal(cryptoFormat)
.to("mock:encrypted")
.unmarshal(cryptoFormat)
.to("mock:unencrypted");
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<crypto id="basic" algorithm="DES" keyRef="desKey" />
</dataFormats>
...
<route>
<from uri="direct:basic-encryption" />
<marshal ref="basic" />
<to uri="mock:encrypted" />
<unmarshal ref="basic" />
<to uri="mock:unencrypted" />
</route>
</camelContext>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<crypto id="basic" algorithm="DES" keyRef="desKey" />
</dataFormats>
...
<route>
<from uri="direct:basic-encryption" />
<marshal ref="basic" />
<to uri="mock:encrypted" />
<unmarshal ref="basic" />
<to uri="mock:unencrypted" />
</route>
</camelContext>
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow