WSSVerifyPart API를 사용하여 서명 파트 검증
이용자 측에서 SOAP 메시지를 보안 설정하려면 WSS API(Web Services Security API)를 사용하여 응답 이용자(클라이언트 측)에서 이용자 바인딩에 대해 검증 파트 정보를 구성하십시오. 검증할 알고리즘 메소드 및 SOAP 메시지 파트를 지정할 수 있습니다. WSSVerifyPart API를 사용하여 요약 메소드 또는 변환 메소드를 변경하십시오. WSSVerifyPart API는 com.ibm.websphere.wssecurity.wssapi.verification 패키지의 파트입니다.
시작하기 전에
서명 검증 정보를 사용하여 SOAP 메시지를 보안 설정하려면 다음 태스크 중 하나를 완료해야 합니다.
- WSSVerification API를 사용하여 서명 검증 정보를 구성합니다.
- 필요에 따라 WSSVerifyPart API를 사용하여 검증 파트를 구성합니다.
이 태스크 정보
WebSphere® Application Server는 기본 이용자의 서명 정보를 사용하여 메시지의 서명 파트를 검증합니다. WSSVerifyPart API는 응답 이용자(요청자)에서만 지원됩니다.
다음 테이블은 디지털 서명 보안 제한조건(무결성)이 정의되는 경우의 필수 검증 파트를 표시합니다.
파트 정보 검증 | 설명 |
---|---|
키워드 | 다음 키워드를 사용하여 검증 파트를 설정합니다.
WS-Addressing 헤더는 복호화되지 않지만 서명 및 검증할 수 있습니다. |
xpath | XPath 표현식을 사용하여 검증 파트를 설정합니다. |
header | QName이 지정한 헤더를 필수 검증 파트로 설정합니다. |
서명 검증의 경우 특정 기본 동작이 발생합니다. WSSVerification API를 사용하는 가장 단순한 방법은 기본 동작을 사용하는 것입니다(예제 코드 참조). 서명 알고리즘 및 정규화 알고리즘과 검증 파트에 대한 기본값은 WSS API에 의해 정의됩니다.
검증 파트 결정 | 기본 동작 |
---|---|
지정할 키워드 | 메시지 보호를 위해 서명하고 사용할 여러 SOAP 메시지 파트입니다. WebSphere Application Server는 다음 키워드를 지원합니다.
|
사용할 변환 메소드(알고리즘) | 변환 메소드를 추가합니다. 변환 알고리즘은
<Transform> 요소 내에서 지정되고 서명에 대한 변환 알고리즘을 지정합니다. 기본 변환 방법은 TRANSFORM_EXC_C14N입니다.
WebSphere Application Server는 다음 사전 구성된 변환 알고리즘을 지원합니다.
|
사용할 요약 메소드(알고리즘) | 요약 알고리즘 메소드를 설정합니다. <DigestMethod>
요소 내에 지정되는 요약 메소드 알고리즘은 <SigningInfo> 요소에서 사용됩니다. 기본 다이제스트 메소드는
SHA1입니다. WebSphere Application Server는 다음 요약 메소드 알고리즘을 지원합니다.
|
프로시저
결과
예
다음 예제는 SOAP 메시지의 서명 정보를 검증하기 위한 WSSVerification API 프로세스의 샘플 코드를 제공합니다.
// Get the message context
Object msgcontext = getMessageContext();
// Generate the WSSFactory instance (step: a)
WSSFactory factory = WSSFactory.getInstance();
// Generate the WSSConsumingContext instance (step: b)
WSSConsumingContext concont = factory.newWSSConsumingContext();
// Generate the certificate list
String certpath =
"c:/WebSphere/AppServer/etc/ws-security/samples/intca2.cer";
// The location of the X509 certificate file
X509Certificate x509cert = null;
try {
InputStream is = new FileInputStream(certpath);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
x509cert = (X509Certificate)cf.generateCertificate(is);
} catch(FileNotFoundException e1){
throw new WSSException(e1);
} catch (CertificateException e2) {
throw new WSSException(e2);
}
Set<Object> eeCerts = new HashSet<Object>();
eeCerts.add(x509cert);
// create certStore
java.util.List<CertStore> certList = new
java.util.ArrayList<CertStore>();
CollectionCertStoreParameters certparam = new
CollectionCertStoreParameters(eeCerts);
CertStore cert = null;
try {
cert = CertStore.getInstance("Collection",
certparam, "IBMCertPath");
} catch (NoSuchProviderException e1) {
throw new WSSException(e1);
} catch (InvalidAlgorithmParameterException e2) {
throw new WSSException(e2);
} catch (NoSuchAlgorithmException e3) {
throw new WSSException (e3);
}
if(certList != null ){
certList.add(cert);
}
// generate callback handler (step: c)
X509ConsumeCallbackHandler callbackHandler = new
X509ConsumeCallbackHandler(
"dsig-receiver.ks",
"jks",
"server".toCharArray(),
certList,
java.security.Security.getProvider("IBMCertPath")
);
// Generate the WSSVerification instance (step: d)
WSSVerification ver = factory.newWSSVerification(X509Token.class,
callbackHandler);
// Set the part to be specified by WSSVerifyPart (step: e)
WSSVerifyPart verPart = factory.newWSSVerifyPart();
// Set the part to be specified by the keyword (step: f)
verPart.setRequiredVerifyPart(WSSVerification.BODY);
// Set the candidates for the digest method for verification (step: g)
// DEFAULT : WSSVerifyPart.SHA1
verPart.addAllowedDigestMethod(WSSVerifyPart.SHA256);
// Set the candidates for the transform method for verification (step: h)
// DEFAULT : WSSVerifypart.TRANSFORM_EXC_C14N : String
verPart.addAllowedTransform(WSSVerifyPart.TRANSFORM_STRT10);
// Set WSSVerifyPart to WSSVerification (step: i)
ver.addRequiredVerifyPart(verPart);
// Add WSSVerification to WSSConsumingContext (step: j)
concont.add(ver);
//Validate the WS-Security header (step: k)
concont.process(msgcontext);