Oracle® Fusion Middleware Oracle Security Developer Toolsによるアプリケーションの開発 12c (12.2.1.2) E82830-01 |
|
前 |
次 |
XKMS (XML Key Management Specification)は、公開鍵の管理に関するW3C仕様です。Oracle XKMS APIはこの仕様に準拠しています。これを使用すると、開発者はデジタル署名の処理に関するXMLトランザクションを記述できるため、公開鍵のインフラストラクチャを簡単に処理できるようになります。
この章には次のトピックが含まれます:
Oracle XKMSは、複数の業務やアプリケーションにわたって鍵の検出とユーザー・アイデンティティの検証を行うためのツールキットからなるPure Javaソリューションです。これを使用すると、Webサービスに必要な安全かつ信頼できるメッセージングをサポートできるほか、PKIに関連するコストや複雑性をある程度軽減することができます。
Oracle XKMSでは次の機能が提供されます。
PKI機能への容易なアクセス - W3C XKMS Standardを実装したOracle XKMSは、XMLの簡易性とPKIの堅牢性を兼ね備えています。このツールキットを利用すると、開発者は安全で軽量なクライアント・ソフトウェアをデプロイすることにより、堅牢なアプリケーション機能を簡単にデプロイできるようになります。
鍵/証明書のライフ・サイクルの完全サポート - Oracle XKMSでは、軽量のWebサービス・インフラストラクチャを使用して、エンタープライズ・アプリケーションによる署名と暗号鍵の検出、取得、検証を行うことができます。
XML署名を使用したXKMSメッセージのセキュリティ保護 - Oracle XMLツールキットを使用して、リクエストとレスポンスにデジタル署名を付けることができます。
ネイティブ・メソッドのない100% Java
JAXP 1.1準拠のXMLパーサーとの連携
Oracle XKMSライブラリには、次のパッケージが含まれています。
表11-1 Oracle XKMSライブラリに含まれるパッケージ
パッケージ | 説明 |
---|---|
|
主なXKMSメッセージ要素が含まれています。 |
|
鍵情報サービスの仕様に関するクラスが含まれています。 |
|
鍵登録サービスの仕様に関するクラスが含まれています。 |
|
定数とユーティリティ・クラスが含まれています。 |
Oracle XKMSの環境を設定するには、Oracleセキュリティ開発ツールとJava Development Kit (JDK)をインストールし、必要なすべてのjarファイルおよびclassファイルへのCLASSPATH変数を設定します。
Oracleセキュリティ開発ツールは、Oracle WebLogic ServerとともにORACLE_HOME
にインストールされます。
Oracle XKMSを使用するには、システムに次のコンポーネントがインストールされている必要があります。
Java Development Kit (JDK)バージョン1.6以上
Oracle XML Securityツールキット
CLASSPATH
環境変数には、必要なjarファイルおよびclassファイルのフルパスとファイル名を指定してください。次のファイルをCLASSPATH
に指定します。
osdt_core.jar
osdt_cert.jar
osdt_xmlsec.jar
org.jaxen_1.1.1.jar
。セキュリティ・ツール・ディストリビューションの$ORACLE_HOME/modules/
ディレクトリにあります。Oracle XML Securityは、XPathの処理のためにJaxen XPathエンジンを利用します。
たとえば、CLASSPATH
は次のようになります。
C:%ORACLE_HOME%\modules\oracle.osdt_11.1.1\osdt_core.jar; %ORACLE_HOME%\modules\oracle.osdt_11.1.1\osdt_cert.jar; %ORACLE_HOME%\modules\oracle.osdt_11.1.1\osdt_xmlsec.jar; %ORACLE_HOME%\modules\org.jaxen_1.1.1.jar;
関連項目:
Oracle XKMSのコア・クラスにより、メッセージ・リクエストおよび結果を検索、検証およびリカバリできます。Oracle XKMSのコア・クラスとインタフェースを使用方法については、コード例を参照してください。
コア・クラスを次に示します。
oracle.security.xmlsec.xkms.xkiss.LocateRequest
クラスは、XKMSのLocateRequest
要素を表します。例を参照してLocateRequest
のインスタンスを作成し、RespondWith
属性をLocateRequest
に追加できます。
// Parse the XML document containing the dsig:Signature. Document sigDoc = //Instance of org.w3c.dom.Document; //Create Query Key Binding QueryKeyBinding queryKeyBinding = new QueryKeyBinding(sigDoc); queryKeyBinding.setTimeInstant(new Date()); // Create the xkms:LocateRequest. LocateRequest loc = new LocateRequest(sigDoc, queryKeyBinding);
LocateRequest
タイプのクライアント・リクエストには、xkms:RespondWith
属性を含める必要があります。
次の例に、RespondWith
をLocateRequest
に追加する方法を示します。
//Add xkms:RespondWith as X.509 Certificate. loc.addRespondWith(XKMSURI.respondWith_X509Cert);
oracle.security.xmlsec.xkms.xkiss.LocateResult
クラスは、xkms:LocateResult
要素を表します。LocateResult
要素のインスタンスを作成できます。LocateRequest
にX509Certificate
のRespondWith
属性が含まれている場合は、X509証明書をLocateResult
に追加できます。
次に例を示します。
//Parse the XML document containin the dsig:Signature Document sigDoc = //Instance of org.w3c.doc.Document; // Create the xkms:LocateResult LocateResult locRes = new LocateResult(sigDoc); //Set ResultMajor to Success. locRes.setResultCode(XKMSURI.result_major_success, null);
LocateRequest
にX509Certificate
のRespondWith
属性が含まれている場合は、次のコードを使用してX509証明書をLocateResult
に追加します。
//Creating a signature and adding X509 certificate to the KeyInfo element. X509Certificate userCert = // Instance of java.security.cert.X509Certificate XSSignature Sig = XSSignature.newInstance(sigDoc, "MySignature"); XSKeyInfo xsInfo = sig.getKeyInfo(); X509Data xData = xsInfo.createX509Data(userCert); //Add X509Data to the KeyInfo xsInfo.addKeyInfoData(xData); //Set Key Binding and add KeyInfo the the KeyBinding UnverifiedKeyBinding keyBinding = new UnverifiedKeyBinding(sigDoc); keyBinding.setKeyInfo(xsInfo); //Add Key Binding to LocateResult locRes.addKeyBinding(keyBinding);
oracle.security.xmlsec.xkms.xkiss.ValidateRequest
クラスは、XKMSのxkms:ValidateRequest
要素を表します。このクラスを使用して、xkms:ValidateRequest
要素のインスタンスを作成できます。
次の例に、xkms:ValidateRequest
のインスタンスを作成する方法を示します。
// Parse the XML document containing the dsig:Signature. Document sigDoc = //Instance of org.w3c.dom.Document; //Create Query Key Binding QueryKeyBinding queryKeyBinding = new QueryKeyBinding(sigDoc); queryKeyBinding.setTimeInstant(new Date()); // Create the xkms:ValidateRequest. ValidateRequest validateReq = new ValidateRequest(sigDoc, queryKeyBinding);
ValidateRequest
タイプのリクエストには、xkms:RespondWith
属性を含める必要があります。次の例に、RespondWith
をValidateRequest
に追加する方法を示します。
//Add xkms:RespondWith as X.509 Certificate. validateReq.addRespondWith(XKMSURI.respondWith_X509Cert);
oracle.security.xmlsec.xkms.xkiss.ValidateResult
クラスを使用して、ValidateResult
のインスタンスを作成できます。ValidateRequest
に対するレスポンスでステータスを設定することもできます。
次の例に、ValidateResult
のインスタンスを作成する方法を示します。
//Parse the XML document containin the dsig:Signature Document sigDoc = //Instance of org.w3c.doc.Document; // Create the xkms:ValidateResult ValidateResult valRes = new ValidateResult(sigDoc); //Set ResultMajor to Success. valRes.setResultCode(XKMSURI.result_major_success, null);
ValidateRequest
に対するレスポンスでステータスを設定するには、次のコードを使用します。
//Create a status element and add reasons. Status responseStatus = new Status(sigDoc); responseStatus.addValidReason(XKMSURI.reasonCode_IssuerTrust); responseStatus.addValidReason(XKMSURI.reasonCode_RevocationStatus); responseStatus.addValidReason(XKMSURI.reasonCode_ValidityInterval); responseStatus.addValidReason(XKMSURI.reasonCode_Signature); //Create a xkms:KeyBinding to add status and X509Data XSKeyInfo xsInfo = // Instance of oracle.security.xmlsec.dsig.XSKeyInfo, // which contains X509Data KeyBinding keyBinding = new KeyBinding(sigDoc); keyBinding.setStatus(responseStatus); keyBinding.setKeyInfo(xsInfo); // Add the key binding to the ValidateResult. valRes.addKeyBinding(keyBinding);
oracle.security.xmlsec.xkms.xkrss.RecoverRequest
クラスは、XKMSのRecoverRequest
要素を表します。このクラスを使用して、RecoverRequest
のインスタンスを作成できます。RecoverRequest
にAuthentication
要素とRecoverKeyBinding
要素を追加することもできます。
次の例に、RecoverRequest
のインスタンスを作成する方法を示します。
// Parse the XML document containing the dsig:Signature. Document sigDoc = //Instance of org.w3c.dom.Document; // Create the xkms:RecoverRequest RecoverRequest recReq = new RecoverRequest(sigDoc); //Set RespondWith to PrivateKey, so that the RecoverResult contains the private key. recReq.addRespondWith(XKMSURI.respondWith_PrivateKey);
RecoverRequest
には、Authentication
要素とRecoverKeyBinding
要素を含める必要があります。これらを追加するには、次のコードを使用します。
//Create an instance of XSSignature. XSSignature sig = //Instance of oracle.security.xmlsec.dsig.XSSignature //Create an instance of Authentication element. Authentication auth = new Authentication(sigDoc); //Set key binding authentication. auth.setKeyBindingAuthentication(sig); //Set Authentication for the RecoverRequest. recReq.setAuthentication(auth); //Add RecoverKeyBinding to RecoverRequest. RecoverKeyBinding recKeyBind = new RecoverKeyBinding(sigDoc); //Add Key Info on the key to be recovered. XSKeyInfo xsInfo = //Instance of oracle.security.xmlsec.dsig.XSKeyInfo recKeyBind.setKeyInfo(xsInfo); //Adding status, as known to the key holder, to the KeyBinding Status keyStatus = new Status(sigDoc); keyStatus.setStatusValue(XKMSURI.kbs_Indeterminate); recKeyBind.setStatus(keyStatus); //Adding RecoverKeyBinding to RecoverRequest. recReq.setKeyBinding(recKeyBind);
oracle.security.xmlsec.xkms.xkrss.RecoverResult
クラスは、xkms:RecoverResult
要素を表します。このクラスを使用して、RecoverResult
のインスタンスを作成できます。RecoverResult
のKeyBinding
を設定できます。RecoverResult
に復元されたPrivateKey
を設定することもできます。
次の例に、RecoverResult
のインスタンスを作成する方法を示します。
// Parse the XML document containing the dsig:Signature. Document sigDoc = //Instance of org.w3c.dom.Document; // Create the xkms:RecoverResult RecoverResult recResult = new RecoverResult(sigDoc); //Set ResultMajor to Success. recResult.setResultCode(XKMSURI.result_major_success, null);
RecoverResult
には、KeyBinding
を設定する必要があります。この設定を行うには、次のコードを使用します。
//Create a xkms:KeyBinding to add status and X509Data XSKeyInfo xsInfo = //Instance of oracle.security.xmlsec.dsig.XSKeyInfo, //which contains X509Data KeyBinding keyBinding = new KeyBinding(sigDoc); keyBinding.setKeyInfo(xsInfo); //Create a status element and add reasons. //Status is set to Invalid because the service can decide //to revoke the key binding in the case of recovery. Status responseStatus = new Status(sigDoc); responseStatus.addInvalidReason(XKMSURI.reasonCode_IssuerTrust); responseStatus.addInvalidReason(XKMSURI.reasonCode_RevocationStatus); responseStatus.addInvalidReason(XKMSURI.reasonCode_ValidityInterval); responseStatus.addInvalidReason(XKMSURI.reasonCode_Signature); responseStatus.setStatusValue(XKMSURI.kbs_Invalid); keyBinding.setStatus(responseStatus); //Set KeyBinding into RecoverResult recResult.addKeyBinding(keyBinding);
次の例に、復元されたPrivateKey
をRecoverResult
に設定する方法を示します。
//Create an Instance of dsig:XEEncryptedData XEEncryptedData encryptedData = //Instance of oracle.security.xmlsec.enc.XEEncryptedData //Create an instance of oracle.security.xmlsec.xkms.xkrss.PrivateKey PrivateKey privKey = new PrivateKey(sigDoc); privKey.setEncryptedData(encryptedData); //Add PrivateKey to RecoverResult recResult.setPrivateKey(privKey);