296.4. 예
다음은 Document, Element 및 Content 수준에서 마샬링을 수행하는 방법에 대한 몇 가지 예입니다.
296.4.1. 전체 페이로드 암호화/암호화 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
from("direct:start")
.marshal().secureXML()
.unmarshal().secureXML()
.to("direct:end");
296.4.2. 부분 페이로드 콘텐츠만 암호화/암호 해독 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
String tagXPATH = "//cheesesites/italy/cheese";
boolean secureTagContent = true;
...
from("direct:start")
.marshal().secureXML(tagXPATH, secureTagContent)
.unmarshal().secureXML(tagXPATH, secureTagContent)
.to("direct:end");
296.4.3. 부분적인 멀티 노드 페이로드 콘텐츠만 암호화/암호 해독 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
String tagXPATH = "//cheesesites/*/cheese";
boolean secureTagContent = true;
...
from("direct:start")
.marshal().secureXML(tagXPATH, secureTagContent)
.unmarshal().secureXML(tagXPATH, secureTagContent)
.to("direct:end");
296.4.4. partial Payload Content only encryption/decryption with passPhrase(password) 선택 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
String tagXPATH = "//cheesesites/italy/cheese";
boolean secureTagContent = true;
...
String passPhrase = "Just another 24 Byte key";
from("direct:start")
.marshal().secureXML(tagXPATH, secureTagContent, passPhrase)
.unmarshal().secureXML(tagXPATH, secureTagContent, passPhrase)
.to("direct:end");
import org.apache.xml.security.encryption.XMLCipher;
....
String tagXPATH = "//cheesesites/italy/cheese";
boolean secureTagContent = true;
String passPhrase = "Just another 24 Byte key";
String algorithm= XMLCipher.TRIPLEDES;
from("direct:start")
.marshal().secureXML(tagXPATH, secureTagContent, passPhrase, algorithm)
.unmarshal().secureXML(tagXPATH, secureTagContent, passPhrase, algorithm)
.to("direct:end");
296.4.6. 네임스페이스 지원이 포함된 부분 페이로드 콘텐츠 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Java DSL
final Map<String, String> namespaces = new HashMap<String, String>();
namespaces.put("cust", "http://cheese.xmlsecurity.camel.apache.org/");
final KeyStoreParameters tsParameters = new KeyStoreParameters();
tsParameters.setPassword("password");
tsParameters.setResource("sender.ts");
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start")
.marshal().secureXML("//cust:cheesesites/italy", namespaces, true, "recipient",
testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters)
.to("mock:encrypted");
}
}
Spring XML
camelContext 정의의 일부로 정의된 네임스페이스 접두사는 secure XML 요소의 데이터 형식 secureTag 속성 내에서 컨텍스트에서 다시 사용할 수 있습니다.
<camelContext id="springXmlSecurityDataFormatTestCamelContext"
xmlns="http://camel.apache.org/schema/spring"
xmlns:cheese="http://cheese.xmlsecurity.camel.apache.org/">
<route>
<from uri="direct://start"/>
<marshal>
<secureXML secureTag="//cheese:cheesesites/italy"
secureTagContents="true"/>
</marshal>
...
296.4.7. 비대칭 키 암호화 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Spring XML Sender
<!-- trust store configuration -->
<camel:keyStoreParameters id="trustStoreParams" resource="./sender.ts" password="password"/>
<camelContext id="springXmlSecurityDataFormatTestCamelContext"
xmlns="http://camel.apache.org/schema/spring"
xmlns:cheese="http://cheese.xmlsecurity.camel.apache.org/">
<route>
<from uri="direct://start"/>
<marshal>
<secureXML secureTag="//cheese:cheesesites/italy"
secureTagContents="true"
xmlCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"
keyCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"
recipientKeyAlias="recipient"
keyOrTrustStoreParametersId="trustStoreParams"/>
</marshal>
...
Spring XML Recipient
<!-- key store configuration -->
<camel:keyStoreParameters id="keyStoreParams" resource="./recipient.ks" password="password" />
<camelContext id="springXmlSecurityDataFormatTestCamelContext"
xmlns="http://camel.apache.org/schema/spring"
xmlns:cheese="http://cheese.xmlsecurity.camel.apache.org/">
<route>
<from uri="direct://encrypted"/>
<unmarshal>
<secureXML secureTag="//cheese:cheesesites/italy"
secureTagContents="true"
xmlCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"
keyCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"
recipientKeyAlias="recipient"
keyOrTrustStoreParametersId="keyStoreParams"
keyPassword="privateKeyPassword" />
</unmarshal>
...