클라이언트에 대한 응답 서명 검증 메소드 구성
WSSVerification 및 WSSVerifyPart API를 사용하여 서명 검증 메소드를 선택할 수 있습니다. 요청 서명 검증 메소드에는 요약 알고리즘 및 전송 메소드가 있습니다.
시작하기 전에
- WSSVerification API를 사용하여 정규화 및 서명 메소드를 구성하십시오.
- 요청 서명을 위해 클라이언트를 구성할 때 사용할 알고리즘 메소드를 구성하려면
이 태스크 정보
다음 테이블에서는 이 정보의 목적에 대해 설명합니다. 이러한 정의 중 일부는 XML-Signature 명세를 기반으로 하며, 다음 웹 주소에 위치합니다.http://www.w3.org/TR/xmldsig-core
메소드 이름 | 목적 |
---|---|
요약 알고리즘 | 지정된 경우 <DigestValue> 요소를 생성하도록 변환을 적용한 후에 데이터에 적용합니다. <DigestValue> 요소에 서명하면 자원 컨텐츠가 서명자 키에 바인드됩니다. 클라이언트 요청 전송자 구성을 위해 선택한 알고리즘이 클라이언트 요청 수신자 요청에서 선택한 알고리즘과 일치해야 합니다. |
변환 알고리즘 | <Transform> 요소에 적용합니다. |
서명 알고리즘 | 서명 검증 메소드의 URI(Uniform Resource Identifier)를 지정합니다. |
정형화 알고리즘 | 정규화 메소드의 URI(Uniform Resource Identifier)를 지정합니다. |
메시지에 디지털로 서명하도록 클라이언트를 구성한 후 디지털 서명을 검증하도록 클라이언트를 구성해야 합니다. WSS API를 사용하거나 관리 콘솔을 통해 정책 세트를 구성하여 디지털 서명을 검증하고 검증을 선택하고 파트 알고리즘을 검증할 수 있습니다. 구성에 WSS API를 사용하는 경우 WSSVerification 및 WSSVerifyPart API를 사용하여 검증할 디지털 서명 메시지 파트를 지정하고 요청 서명을 위해 클라이언트를 구성할 때 사용할 알고리즘 메소드를 지정하십시오.
WSSVerification 및 WSSVerifyPart API는 다음 단계를 수행하여 서명 검증 및 검증 알고리즘 메소드를 구성합니다.
프로시저
결과
예
다음 예제는 본문을 검증할 파트로, HMAC_SHA1을 서명 메소드로, C14N 및 EXC_C14N을 정규화 메소드의 후보로, TRANSFORM_STRT10을 변환 메소드로, SHA256을 요약 메소드로 검증 정보를 지정하는 샘플 WSS API 코드를 제공합니다.
// Get the message context
Object msgcontext = getMessageContext();
// Generate the WSSFactory instance
WSSFactory factory = WSSFactory.getInstance();
// Generate the WSSConsumingContext instance
WSSConsumingContext concont = factory.newWSSConsumingContext();
// Generate the certificate list
String certpath = "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 the 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 the callback handler
X509ConsumeCallbackHandler callbackHandler = new
X509ConsumeCallbackHandler(
"dsig-receiver.ks",
"jks",
"server".toCharArray(),
certList,
java.security.Security.getProvider(
"IBMCertPath")
);
// Generate the WSSVerification instance
WSSVerification ver = factory.newWSSVerification(X509Token.class,
callbackHandler);
// Set one or more candidates of the signature method used for
// verification (step. 1)
// DEFAULT : WSSVerification.RSA_SHA1
ver.addAllowedSignatureMethod(WSSVerification.HMAC_SHA1);
// Set one or more candidates of the canonicalization method used for
// verification (step. 2)
// DEFAULT : WSSVerification.EXC_C14N
ver.addAllowedCanonicalizationMethod(WSSVerification.C14N);
ver.addAllowedCanonicalizationMethod(WSSVerification.EXC_C14N);
// Set the part to be specified by WSSVerifyPart
WSSVerifyPart verPart = factory.newWSSVerifyPart();
// Set the part to be specified by the keyword
verPart.setRequiredVerifyPart(WSSVerification.BODY);
// Set the candidates of digest methods to use for verification (step. 3)
// DEFAULT : WSSVerifypart.TRANSFORM_EXC_C14N : String
verPart.addAllowedTransform(WSSVerifyPart.TRANSFORM_STRT10);
// Set the candidates of digest methods to use for verification (step. 4)
// DEFAULT : WSSVerifyPart.SHA1
verPart.addAllowedDigestMethod(WSSVerifyPart.SHA256);
// Set WSSVerifyPart to WSSVerification
ver.addRequiredVerifyPart(verPart);
// Add the WSSVerification to the WSSConsumingContext
concont.add(ver);
// Validate the WS-Security header
concont.process(msgcontext);
다음에 수행할 작업
서명 검증 알고리즘 구성을 완료했습니다. 아직 구성하지 않은 경우 암호화 또는 복호화 알고리즘을 구성하십시오. 또는 필요에 따라 보안 토큰 정보를 구성하십시오.