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 を使用した検査パーツ方式の選択

WSS API を使用して、コンシューマー・バインディングの署名検査情報を構成できます。 変換アルゴリズム方式とダイジェスト方式がコンシューマー・バインディングで使用されます。 アルゴリズム方式を構成するには、WSSVerifyPart API を使用します。 WSSVerifyPart API は、com.ibm.websphere.wssecurity.wssapi.verification パッケージに同梱されています。

コンシューマー検査パーツ情報を構成してメッセージの保全性を保護するには、最初にデジタルで署名してから SOAP メッセージのシグニチャーと署名済みパーツを検査してください。 機密性が暗号化を意味するのに対して、「保全性」はデジタル・シグニチャーを意味します。 保全性によって、データがネットワーク内を伝送されている間に変更されるリスクが減少します。

方式

署名情報で使用する方式には以下のようなものがあります。
ダイジェスト方式
ダイジェスト方式を設定します。
変換方式
変換アルゴリズム方式を設定します。

ダイジェスト・アルゴリズム

ダイジェスト方式アルゴリズムはエレメント内で指定され、<Digest> エレメントで使用されます。WebSphere Application Server は次の事前構成済みダイジェスト・アルゴリズムをサポートしています。

表 1. パーツ・ダイジェスト方式の検査
ダイジェスト方式 説明
WSSVerifyPart.SHA1 (デフォルト値) ダイジェスト・アルゴリズム SHA1 の URI: http://www.w3.org/2000/09/xmldsig#sha1
WSSVerifyPart.SHA256 ダイジェスト・アルゴリズム SHA256 の URI: http://www.w3.org/2001/04/xmlenc#sha256
WSSVerifyPart.SHA512 ダイジェスト・アルゴリズム SHA256 の URI: http://www.w3.org/2001/04/xmlenc#sha512

変換アルゴリズム

変換アルゴリズムは、<Transform> エレメント内で指定され、署名済みパーツの変換アルゴリズムを指定します。 WebSphere Application Server は、以下の事前構成済み変換アルゴリズムをサポートします。

表 2. パーツ変換方式の検査
ダイジェスト方式 説明
WSSVerifyPart.TRANSFORM_ENVELOPED_SIGNATURE 変換アルゴリズム enveloped signature の URI: http://www.w3.org/2000/09/xmldsig#enveloped-signature
WSSVerifyPart.TRANSFORM_STRT10 変換アルゴリズム STR-Transform の URI: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform
WSSVerifyPart.TRANSFORM_EXC_C14N (デフォルト値) 変換アルゴリズム Exc-C14N の URI: http://www.w3.org/2001/10/xml-exc-c14n#
WSSVerifyPart.TRANSFORM_XPATH2_FILTER 変換アルゴリズム XPath2 フィルターの URI: http://www.w3.org/2002/06/xmldsig-filter2
WSS API の場合、WebSphere Application Server は 以下の変換アルゴリズムをサポートしていません。
  • http://www.w3.org/TR/1999/REC-xpath-19991116
  • http://www.w3.org/2002/07/decrypt#XML

以下の例は、ダイジェスト方式として SHA256 を使用し、変換方式として TRANSFORM_EXC_14N および TRANSFORM_STRT10 を使用して本文を検査する場合の WSS API サンプル・コードです。

	  // get the message context
	  Object msgcontext = getMessageContext();

	  // generate WSSFactory instance
	  WSSFactory factory = WSSFactory.getInstance();		

	  // generate WSSConsumingContext instance
	  WSSConsumingContext concont = factory.newWSSConsumingContext();


	  // generate the cert 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 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	  	    
	  X509ConsumeCallbackHandler callbackHandler = new X509ConsumeCallbackHandler(
			  "dsig-receiver.ks", 
			  "jks",
			  "server".toCharArray(), 
			  certList, 
			  java.security.Security.getProvider("IBMCertPath")
	  );


	  //generate WSSVerification instance
	  WSSVerification ver = factory.newWSSVerification(X509Token.class, callbackHandler);

	  //set one or more candidates of the signature method used for the verification (step. 1)
	  // DEFAULT : WSSVerification.RSA_SHA1
	  ver.addAllowedSignatureMethod(WSSVerification.HMAC_SHA1);

	  //set one or more candidates of the canonicalization method used for the 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 
	  verPart.addAllowedTransform(WSSVerifyPart.TRANSFORM_EXC_C14N);
	  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);



関連タスク
WSS API を使用してメッセージの保全性を保護するための コンシューマー署名情報の検証
関連資料
WSSVerification API を使用したシグニチャー検査方式
WSSSignature API を使用したデジタル署名方式
WSSSignPart 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/rwbs_wssverifypartalgorithms.html