295.4. 예
아래에서는 문서, 요소 및 콘텐츠 수준에서 마샬링을 수행하는 방법에 대한 몇 가지 예가 있습니다.
295.4.1. 전체 페이로드 암호화/암호화 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
from("direct:start")
.marshal().secureXML()
.unmarshal().secureXML()
.to("direct:end");
295.4.2. 부분적인 페이로드 콘텐츠만 암호화/암호화 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
String tagXPATH = "//cheesesites/italy/cheese";
boolean secureTagContent = true;
...
from("direct:start")
.marshal().secureXML(tagXPATH, secureTagContent)
.unmarshal().secureXML(tagXPATH, secureTagContent)
.to("direct:end");
295.4.3. 부분적인 멀티 노드 페이로드 콘텐츠만 암호화/암호화 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
String tagXPATH = "//cheesesites/*/cheese";
boolean secureTagContent = true;
...
from("direct:start")
.marshal().secureXML(tagXPATH, secureTagContent)
.unmarshal().secureXML(tagXPATH, secureTagContent)
.to("direct:end");
295.4.4. 부분 페이로드 콘텐츠 passPhrase(암호)를 사용하여 암호화/암호화만 가능 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
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");
295.4.5. 부분 페이로드 콘텐츠 passPhrase(암호) 및 알고리즘을 사용하여 암호화/암호화만 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
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");
295.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 정의의 일부로 정의된 네임스페이스 접두사는 secureXML 요소의 데이터 형식 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>
...
295.4.7. DestinationRule 키 암호화 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
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>
...