WSS API を使用して、ジェネレーター・バインディングの署名済みパーツ情報を構成できます。 このアルゴリズムにはダイジェスト方式と変換方式が含まれます。
署名済みパーツと鍵情報を構成することで、メッセージの保全性を保護できます。 機密性が暗号化を意味するのに対して、「保全性」はデジタル・シグニチャーを意味します。 保全性によって、データがネットワーク内を伝送されている間に変更されるリスクが減少します。
エレメント内で指定されたダイジェスト方式アルゴリズムが、そのエレメント内で使用されます。 WebSphere Application Server は、以下の事前構成アルゴリズムをサポートします。
ダイジェスト方式 | 説明 |
---|---|
WSSSignPart.SHA1 (デフォルト値) | ダイジェスト・アルゴリズム SHA1 の URI: http://www.w3.org/2000/09/xmldsig#sha1 |
WSSSignPart.SHA256 | ダイジェスト・アルゴリズム SHA256 の URI: http://www.w3.org/2001/04/xmlenc#sha256 |
WSSSignPart.SHA512 | ダイジェスト・アルゴリズム SHA256 の URI: http://www.w3.org/2001/04/xmlenc#sha512 |
エレメント内で指定された変換方式アルゴリズムが、そのエレメント内で使用されます。 WebSphere Application Server は、以下の事前構成アルゴリズムをサポートします。
ダイジェスト方式 | 説明 |
---|---|
WSSSignPart.TRANSFORM_ENVELOPED_SIGNATURE | 変換アルゴリズム enveloped signature の URI: http://www.w3.org/2000/09/xmldsig#enveloped-signature |
WSSSignPart.TRANSFORM_STRT10 | 変換アルゴリズム STR-Transform の URI: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform |
WSSSignPart.TRANSFORM_EXC_C14N (デフォルト値) | 変換アルゴリズム Exc-C14N の URI: http://www.w3.org/2001/10/xml-exc-c14n# |
WSSSignPart.TRANSFORM_XPATH2_FILTER | 変換アルゴリズム XPath2 フィルターの URI: http://www.w3.org/2002/06/xmldsig-filter2 |
変換アルゴリズムは、<Transform> エレメント内で指定され、署名済みパーツの変換アルゴリズムを指定します。
以下の例では、シグニチャーと署名済みパーツを指定し、署名鍵の設定を行い、署名済みパーツとして STR-Transform 変換アルゴリズムを追加する場合の WSS API コードのサンプルを示しています。
//get the message context Object msgcontext = getMessageContext(); //generate WSSFactory instance WSSFactory factory = WSSFactory.getInstance(); //generate WSSGenerationContext instance WSSGenerationContext gencont = factory.newWSSGenerationContext(); //generate callback handler X509GenerateCallbackHandler callbackHandler = new X509GenerateCallbackHandler( "", "dsig-sender.ks", "jks", "client".toCharArray(), "soaprequester", "client".toCharArray(), "CN=SOAPRequester, OU=TRL, O=IBM, ST=Kanagawa, C=JP", null); //generate the security token used to the signature SecurityToken token = factory.newSecurityToken(X509Token.class, callbackHandler); //generate WSSSignature instance WSSSignature sig = factory.newWSSSignature(token); //set the part specified by WSSSignPart WSSSignPart sigPart = factory.newWSSSignPart(); //set the part specified by WSSSignPart sigPart.setSignPart(WSSSignature.BODY); //set the digest method specified by WSSSignPart sigPart.setDigestMethod(WSSSignPart.SHA256); //set the transform method specified by WSSSignPart sigPart.addTransform(WSSSignPart.TRANSFORM_STRT10); //set the part specified by WSSSignPart sig.addSignPart(sigPart); //add the WSSSignature to the WSSGenerationContext gencont.add(sig); //generate the WS-Security header gencont.process(msgcontext);