WSSDecryption API를 사용하여 SOAP 메시지 복호화
구성의 정책 세트를 사용하지 않고도 WSS API(Web Services Security API)를 사용하여 SOAP 메시지를 보안 설정할 수 있습니다. 응답(클라이언트) 이용자 측에서 복호화를 위해 클라이언트를 구성하려면 WSSDecryption API를 사용하여 SOAP 메시지를 복호화하십시오. WSSDecryption API는 클라이언트를 구성할 때 복호화할 요청 SOAP 메시지 파트를 지정합니다.
시작하기 전에
WSS API를 사용하거나 관리 콘솔에서 정책 세트를 사용하여 복호화를 사용으로 설정하고 SOAP 메시지에서 이용자 보안 토큰을 추가할 수 있습니다. SOAP 메시지를 보안 설정하려면 다음 복호화 태스크를 완료해야 합니다.
- SOAP 메시지를 암호화합니다.
- 복호화 메소드를 선택합니다.
이 태스크 정보
이용자 측의 복호화 정보는 응답 이용자(클라이언트 측) 바인딩에 대해 수신되는 SOAP 메시지를 복호화하는 데 사용됩니다. 클라이언트 이용자 구성은 제공자 생성기의 구성과 일치해야 합니다.
기밀성 설정에서는 생성된 메시지에 기밀성 제한조건이 적용되어야 합니다.
다음 복호화 파트를 구성할 수 있습니다.
복호화 파트 | 설명 |
---|---|
part | WSSDecryptPart 오브젝트를 복호화 파트의 대상으로 추가합니다. |
키워드 | 키워드를 사용하여 복호화 파트를 추가합니다. WebSphere® Application
Server는 다음 키워드를 지원합니다.
|
xpath | XPath 표현식을 사용하여 복호화 파트를 추가합니다. |
verification | WSSVerification 인스턴스를 복호화 파트의 대상으로 추가합니다. |
header | QName이 지정한 SOAP 헤더를 복호화 파트의 대상으로 추가합니다. |
복호화의 경우 특정 기본 동작이 발생합니다. 복호화를 위해 WSS API를 사용하는 가장 간단한 방법은 기본 동작을 사용하는 것입니다(예제 코드 참조). WSSDecryption은 키 암호화 알고리즘, 데이터 암호화 알고리즘 및 복호화 파트(예: SOAP 본문 컨텐츠 및 서명)의 기본값을 제공합니다. 복호화 기본 동작은 다음과 같습니다.
복호화 결정 | 기본 동작 |
---|---|
복호화할 파트 | 기본 복호화 파트는 BODY_CONTENT 및 SIGNATURE입니다. WebSphere Application Server는 다음과 같은 키워드를 지원합니다.
복호화할 메시지 파트를 지정한 후에는 고객 요청 메시지를 복호화할 때 사용할 메소드를 지정해야 합니다. 예를 들어, 서명 및 본문 컨텐츠 둘 다 암호화에 적용되는 경우 복호화되는 SOAP 메시지 파트가 같은 파트를 포함합니다. |
키를 암호화할지 여부(isEncrypt) | 기본값은 키를 암호화하는 것입니다(true). |
선택할 데이터 복호화 알고리즘(메소드) | 기본 데이터 복호화 알고리즘 메소드는 AES128입니다. WebSphere Application Server는 다음 데이터 암호화 메소드를 지원합니다.
|
선택할 키 복호화 메소드(알고리즘) | 기본 키 복호화 알고리즘 메소드는 키 랩 RSA OAEP입니다. WebSphere Application Server는 다음 키 암호화 메소드를 지원합니다.
|
지정할 보안 토큰 | 기본 보안 토큰 유형은 X509 토큰입니다. WebSphere Application Server는 다음 사전 구성된 이용자 토큰 유형을 제공합니다.
|
프로시저
결과
예
다음 예는 SOAP 메시지 본문 컨텐츠를 복호화 샘플 코드를 제공합니다.
// Get the message context
Object msgcontext = getMessageContext();
// Generate the WSSFactory instance (step: a)
WSSFactory factory = WSSFactory.getInstance();
// Generate the WSSConsumingContext instance (step: b)
WSSConsumingContext gencont = factory.newWSSConsumingContext();
// Generate the callback handler (step: c)
X509ConsumeCallbackHandler callbackHandler = new
X509ConsumeCallbackHandler(
"",
"enc-sender.jceks",
"jceks",
"storepass".toCharArray(),
"alice",
"keypass".toCharArray(),
"CN=Alice, O=IBM, C=US");
// Generate the WSSDecryption instance (step: d)
WSSDecryption dec = factory.newWSSDecryption(X509Token.class,
callbackHandler);
// Set the part to be encrypted (step: e)
// DEFAULT: WSSEncryption.BODY_CONTENT and WSSEncryption.SIGNATURE
// Set the part to be encrypted (step: e)
// DEFAULT: WSSEncryption.BODY_CONTENT and WSSEncryption.SIGNATURE
// Set the part specified by the keyword (step: e)
dec.addRequiredDecryptPart(WSSDecryption.BODY_CONTENT);
// Set the part in the SOAP Header specified by QName (step: e)
dec.addRequiredDecryptHeader(new
QName("http://www.w3.org/2005/08/addressing",
"MessageID"));
// Set the part specified by WSSVerification (step: e)
X509ConsumeCallbackHandler verifyCallbackHandler =
getCallbackHandler();
WSSVerification ver = factory.newWSSVerification(X509Token.class,
verifyCallbackHandler);
dec.addRequiredDecryptPart(ver);
// Set the part specified by XPath expression (step: e)
StringBuffer sb = new StringBuffer();
sb.append("/*[namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/'
and local-name()='Envelope']");
sb.append("/*[namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/'
and local-name()='Body']");
sb.append("/*[namespace-uri()='http://xmlsoap.org/Ping'
and local-name()='Ping']");
sb.append("/*[namespace-uri()='http://xmlsoap.org/Ping'
and local-name()='Text']");
dec.addRequiredDecryptPartByXPath(sb.toString());
// Set the part in the SOAP header to be decrypted specified by QName (step: e)
dec.addRequiredDecryptHeader(new
QName("http://www.w3.org/2005/08/addressing",
"MessageID"));
// Set the candidates for the data encryption method (step: f)
// DEFAULT : WSSDecryption.AES128
dec.addAllowedEncryptionMethod(WSSDecryption.AES128);
dec.addAllowedEncryptionMethod(WSSDecryption.AES192);
// Set the candidates for the key encryption method (step: g)
// DEFAULT : WSSDecryption.KW_RSA_OAEP
dec.addAllowedKeyEncryptionMethod(WSSDecryption.KW_TRIPLE_DES);
// Set the candidate security token to used for the decryption (step: h)
X509ConsumeCallbackHandler callbackHandler2 = getCallbackHandler2();
dec.addToken(X509Token.class, callbackHandler2);
// Set whether or not the key should be encrypted in the incoming SOAP message (step: i)
// DEFAULT: true
dec.encryptKey(true);
// Add the WSSDecryption to the WSSConsumingContext (step: j)
concont.add(dec);
// Validate the WS-Security header (step: k)
concont.process(msgcontext);
다음에 수행할 작업
그런 다음 WSSDecryptPart API를 사용하거나 관리 콘솔을 통해 정책 세트를 구성하여 이용자 메시지의 복호화된 파트를 추가하십시오.