WebSphere Application Server Version 6.1 Feature Pack for Web Services   
             オペレーティング・システム: AIX , HP-UX, i5/OS, Linux, Solaris, Windows, Windows Vista, z/OS

             目次と検索結果のパーソナライズ化
             New or updated topic for this feature pack

WSSVerifyPart API を使用した署名済みパーツの検証

コンシューマー側で SOAP メッセージを保護するには、 Web サービス・セキュリティー API (WSS API) を使用して、応答コンシューマー (クライアント・サイド) で 検証パーツ情報を構成します。確認するアルゴリズム方式と SOAP メッセージのパーツを 指定することができます。ダイジェスト方式または変換方式を変更するには、WSSVerifyPart API を使用します。 WSSVerifyPart API は、com.ibm.websphere.wssecurity.wssapi.verification パッケージに 含まれています。

始める前に

署名検証情報を使用して SOAP メッセージを保護するには、 以下のタスクのいずれかを実行する必要があります。

WSSVerifyPart は、検証に変換方式またはダイジェスト方式を指定する場合に 使用されます。WSSVerifyPart API を使用するか、 管理コンソールからポリシー・セットを構成します。

このタスクについて

WebSphere Application Server では、デフォルト・コンシューマー用の 署名情報を使用してメッセージの署名済みパーツを検証します。WSSVerifyPart API は、 応答コンシューマー (要求側) でしかサポートされていません。

以下の表に、 デジタル・シグニチャー・セキュリティー制約 (保全性) が定義される場合に 必須の検証パーツを示します。

表 1. 検証パーツ情報
検証パーツ情報 説明
keyword 以下のキーワードで検証パーツを設定します。
  • BODY
  • ADDRESSING_HEADERS
  • TIMESTAMP

WS-Addressing ヘッダーは暗号化解除されませんが、 署名したり検証したりすることはできます。

xpath XPath 式で検証パーツを設定します。
header ヘッダー (QName で指定) を必須の検証パーツとして 設定します。

シグニチャー検証では、特定のデフォルトの動作が発生します。WSSVerification API を 使用する最も簡単な方法は、デフォルトの動作を使用することです (コード例を 参照してください)。署名アルゴリズムと正規化アルゴリズム、 および検証パーツでは、デフォルト値は WSS API によって定義されます。

表 2. 検証パーツのデフォルトの動作
検証パーツの決定項目 デフォルトの動作
指定するキーワード

署名してメッセージ保護に使用する SOAP メッセージの 各種パーツ。WebSphere Application Server は以下のキーワードをサポートします。

  • WSSVerification.BODY
  • WSSVerification.ADDRESSING_HEADERS
  • WSSVerification.TIMESTAMP
使用する変換方式 (アルゴリズム) 変換方式を追加します。変換アルゴリズムは、 <Transform> エレメント内で指定され、シグニチャーの変換アルゴリズムを 指定します。デフォルトの変換方式は TRANSFORM_EXC_C14N です。

WebSphere Application Server は、 以下の事前構成済み変換アルゴリズムをサポートします。

  • WSSVerifyPart.TRANSFORM_EXC_C14N (the default value): http://www.w3.org/2001/10/xml-exc-c14n#
  • WSSVerifyPart.TRANSFORM_XPATH2_FILTER: http://www.w3.org/2002/06/xmldsig-filter2

    この変換方式を使用すると、Basic Security Profile (BSP) への準拠が保証されます。

  • WSSVerifyPart.TRANSFORM_STRT10: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform
  • WSSVerifyPart.TRANSFORM_ENVELOPED_SIGNATURE: http://www.w3.org/2000/09/xmldsig#enveloped-signature
使用するダイジェスト方式 (アルゴリズム) ダイジェスト・アルゴリズム方式を設定します。 <DigestMethod> エレメント内で指定されるダイジェスト方式アルゴリズムは、 <SigningInfo> エレメントで使用されます。 デフォルトのダイジェスト方式は SHA1 です。
WebSphere Application Server は、以下のダイジェスト・メソッド・アルゴリズムをサポートします。
  • WSSVerifyPart.SHA1: http://www.w3.org/2000/09/xmldsig#sha1
  • WSSVerifyPart.SHA256: http://www.w3.org/2001/04/xmlenc#sha256
  • WSSVerifyPart.SHA512: http://www.w3.org/2001/04/xmlenc#sha512

プロシージャー

  1. WSSVerifyPart API で署名済みパーツを検証するには、まず、 WebSphere Application Server Feature Pack がインストールされていることを確認します。
  2. Web サービス・セキュリティー API を使用して、SOAP メッセージ内の 検証を確認します。 シグニチャー検証の WSS API プロセスは、 以下の手順のとおりです。
    1. WSSFactory.getInstance() を使用して WSS API 実装インスタンスを取得します。
    2. WSSFactory インスタンスから WSSConsumingContext インスタンスを 作成します。 WSSConsumingContext が JAX-WS プロバイダー実装クラスで呼び出されることを 確認します。JAX-WS プログラミング・モデルの 性質上、JAX-WS プロバイダーを実装する必要があります。また、SOAP メッセージ・シグニチャーの検証には、 このプロバイダーが WSSConsumingContext を呼び出す必要があります。
    3. 検証に使用する CallbackHandler を作成します。
    4. WSSFactory インスタンスから WSSVerification オブジェクトを作成します。
    5. WSSFactory インスタンスから WSSVerifyPart を作成します。
    6. デフォルトが適切でない場合は、検証するパーツを設定します。
    7. ダイジェスト方式の候補を設定します (デフォルトが 適切でない場合)。
    8. 変換方式の候補を設定します (デフォルトが 適切でない場合)。
    9. WSSVerifyPart を WSSVerification に追加します。
    10. WSSVerification を WSSConsumingContext に追加します。
    11. SOAPMessageContext を使用して WSSConsumingContext.process() を呼び出します。

結果

これで、コンシューマー側で署名済みパーツを検証するためのステップが 完了しました。署名情報の検証時にエラー条件が生じると、 WSSException が提供されます。正常に完了した場合は WSSConsumingContext.process() が呼び出され、 SOAP メッセージに関する Web サービス・セキュリティーが検証されます。

次の例は、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);

次の作業

これで、検証する署名済みパーツの構成が完了しました。



関連タスク
WSS API を使用したコンシューマー・セキュリティー・トークンの構成
WSSVerification API によるシグニチャーの検証
ポリシー・セットを使用したメッセージ・パーツの署名と暗号化
WSSSignPart API を使用した署名済みパーツの追加
WSS API を使用した応答コンシューマーでのメッセージの保護
関連資料
WSSVerifyPart API を使用した検査パーツ方式の選択
タスク・トピック    

ご利用条件 | フィードバック

最終更新: Jan 21, 2008 4:10:06 PM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/twbs_confsignaturepartcon.html