73.6. キーの動的指定
Recipient list または同様の EIP を使用する場合、エクスチェンジの受信者は動的に異なる可能性があります。すべての受信者で同じキーを使用すると、現実的でも望ましくない場合もあります。エクスチェンジごとにキーを動的に指定できるのは便利です。その後、交換は、データ形式で処理される前に、ターゲット受信者のキーで動的に強化できます。この DataFormat を容易にするために、以下のメッセージヘッダーを使用してキーを動的に指定できます。
- CryptoDataFormat.KEY "CamelCryptoKey"
CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES", null); /** * Note: the header containing the key should be cleared after * marshalling to stop it from leaking by accident and * potentially being compromised. The processor version below is * arguably better as the key is left in the header when you use * the DSL leaks the fact that camel encryption was used. */ from("direct:key-in-header-encrypt") .marshal(cryptoFormat) .removeHeader(CryptoDataFormat.KEY) .to("mock:encrypted"); from("direct:key-in-header-decrypt").unmarshal(cryptoFormat).process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getIn().getHeaders().remove(CryptoDataFormat.KEY); exchange.getOut().copyFrom(exchange.getIn()); } }).to("mock:unencrypted");
または spring で行います。
<crypto id="nokey" algorithm="DES" />