クライアントの応答署名検査方式の構成
WSSVerification API と WSSVerifyPart API を使用して署名検査方式を選択します。 要求署名検査方式には、ダイジェスト・アルゴリズム方式とトランスポート方式が含まれます。
始める前に
- 正規化方式およびシグニチャー方式を構成するには、 WSSVerification API を使用します。
- ダイジェスト方式および変換方式を構成するには、 WSSVerifyPart API を使用します。
このタスクについて
以下の表で、この情報の目的を説明しています。これらの定義の一部は、XML-Signature 仕様 (Web サイト http://www.w3.org/TR/xmldsig-core にあります) を基にしています。
方式の名前 | 目的 |
---|---|
ダイジェスト・アルゴリズム | <DigestValue> エレメントを生成するために、 変換の適用後にデータに適用されます (指定されている場合)。 <DigestValue> エレメントの署名は、 リソース・コンテンツを署名者鍵に結合します。クライアント要求送信側の構成用に選択したアルゴリズムは、クライアント要求受信側の構成で選択したアルゴリズムと一致している必要があります。 |
変換アルゴリズム | <Transform> エレメントに適用します。 |
署名アルゴリズム | シグニチャー検査方式の URI (Uniform Resource Identifiers) を指定します。 |
正規化アルゴリズム | 正規化方式の URI (Uniform Resource Identifiers) を指定します。 |
メッセージをデジタル署名するようにクライアントを構成した後、 デジタル署名を検査するようにクライアントを構成する必要があります。 WSS API を使用するか、または管理コンソールでポリシー・セットを構成するかして、 デジタル署名を検査し、検査を選択してパーツのアルゴリズムを確認できます。 WSS API を引き続き使用する場合は、 WSSVerification API と WSSVerifyPart API を使用して、検査するデジタル署名済みメッセージ・パーツを指定し、 クライアントを要求署名用に構成するときに使用するアルゴリズム方式を指定します。
WSSVerification API と WSSVerifyPart API では、以下のステップを実行して、 シグニチャー検査を構成し、パーツ・アルゴリズム方式を検査します。
手順
タスクの結果
例
以下の例は、WSS API のサンプル・コードです。検査情報、検査対象パーツとして本体、シグニチャー方式として HMAC_SHA1、 正規化方式の候補として C14N および EXC_C14N、変換方式として TRANSFORM_STRT10、およびダイジェスト方式として SHA256 を指定しています。
// 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);
次のタスク
署名検証アルゴリズムの構成を完了しました。 暗号化または暗号化解除アルゴリズムの構成がまだであれば、次に構成してください。 または必要に応じて、セキュリティー・トークンの情報を構成してください。