| Oracle® Fusion Middleware Oracle Security Developer Toolsによるアプリケーションの開発 12c (12.2.1) E72521-01 |
|
前 |
次 |
XKMS (XML Key Management Specification)は、公開鍵の管理に関するW3C仕様です。これを使用すると、開発者はデジタル署名の処理に関する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セキュリティ開発ツールは、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の主要なクラスとインタフェースの使用について説明し、コード例を示します。コア・クラスを次に示します。
このクラスは、XKMSのLocateRequest要素を表します。
次の例に、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);
このクラスは、xkms:LocateResult要素を表します。
次の例に、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);
このクラスは、XKMSの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);
このクラスは、XKMSのValidateResult要素を表します。
次の例に、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);
このクラスは、XKMSのRecoverRequest要素を表します。
次の例に、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);
このクラスは、xkms:RecoverResult要素を表します。
次の例に、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);