モジュール java.base
パッケージ java.security

クラスKeyStore.Builder

java.lang.Object
java.security.KeyStore.Builder
含まれているクラス:
KeyStore

public abstract static class KeyStore.Builder extends Object
インスタンス化予定のKeyStoreオブジェクトの説明。

このクラスのインスタンスは、KeyStoreオブジェクトのインスタンス化と初期化に必要な情報をカプセル化します。 getKeyStore()メソッドを呼び出すと、この処理が起動されます。

これにより、KeyStoreオブジェクトの作成から構成を分離でき、パスワード・プロンプトが必要になるまで遅延します。

導入されたバージョン:
1.5
関連項目:
  • コンストラクタの詳細

    • Builder

      protected Builder()
      新しいBuilderを作成します。
  • メソッドの詳細

    • getKeyStore

      public abstract KeyStore getKeyStore() throws KeyStoreException
      このオブジェクトによって記述されたKeyStoreを返します。
      戻り値:
      このオブジェクトが記述するKeyStore
      例外:
      KeyStoreException - 操作中にエラーが発生した場合(たとえば、KeyStoreをインスタンス化またはロードできなかった場合)
    • getProtectionParameter

      public abstract KeyStore.ProtectionParameter getProtectionParameter(String alias) throws KeyStoreException
      指定された別名でEntryを取得するために使用する必要があるProtectionParameterを返します。 getKeyStoreメソッドを呼び出したあとでないと、このメソッドを呼び出せません。
      パラメータ:
      alias - KeyStoreエントリの別名
      戻り値:
      指定された別名でEntryを取得するために使用するProtectionParameter
      例外:
      NullPointerException - 別名がnullの場合
      KeyStoreException - 処理中にエラーが発生した場合
      IllegalStateException - このメソッドをコールする前にgetKeyStoreメソッドが呼び出されていない場合
    • newInstance

      public static KeyStore.Builder newInstance(KeyStore keyStore, KeyStore.ProtectionParameter protectionParameter)
      指定されたKeyStoreをカプセル化する新しいBuilderを返します。 返されたオブジェクトのgetKeyStore()メソッドはkeyStoreを返し、getProtectionParameter()メソッドはprotectionParametersを戻します。

      これは、既存のKeyStoreオブジェクトをビルダー・ベースのAPIとともに使用する必要がある場合に便利です。

      パラメータ:
      keyStore - カプセル化するKeyStore
      protectionParameter - KeyStoreエントリを保護するために使用されるProtectionParameter
      戻り値:
      新しいBuilderオブジェクト
      例外:
      NullPointerException - keyStoreまたはprotectionParameternullの場合
      IllegalArgumentException - keyStoreが初期化されていない場合
    • newInstance

      public static KeyStore.Builder newInstance(String type, Provider provider, File file, KeyStore.ProtectionParameter protection)
      新しいBuilderオブジェクトを返します。

      戻されたビルダーでgetKeyStore()メソッドの最初のコールでは、type型のKeyStoreが作成され、そのload()メソッドがコールされます。 inputStream引数はfileに基づいて構築されます。 protectionPasswordProtectionである場合、パスワードを取得するにはgetPasswordメソッドを呼び出します。 protectionCallbackHandlerProtectionである場合、パスワードを取得するにはCallbackHandlerを呼び出します。

      後続のgetKeyStore()呼出しでは、初回の呼出し時と同じオブジェクトが返されます。 最初の呼び出しがKeyStoreExceptionで失敗した場合、後続の呼び出しもKeyStoreExceptionをスローします。

      null以外の場合、KeyStoreproviderからインスタンス化されます。 そうでない場合は、インストールされたすべてのプロバイダが検索されます。

      getProtectionParameter()を呼び出すと、loadメソッドの呼出し時に使用されたパスワードをカプセル化したPasswordProtectionオブジェクトが返されます。

      getKeyStore()メソッドは、このメソッドを呼び出しているコードのAccessControlContext内で実行されることに注意してください

      パラメータ:
      type - 構築されるKeyStoreのタイプ
      provider - KeyStoreをインスタンス化するプロバイダ(またはnull)
      file - KeyStoreデータを含むファイル
      protection - KeyStoreデータを保護するProtectionParameter
      戻り値:
      新しいBuilderオブジェクト
      例外:
      NullPointerException - タイプ、ファイルまたは保護がnullの場合
      IllegalArgumentException - protectionがPasswordProtection、CallbackHandlerProtectionのどちらのインスタンスでもない場合、またはfileが存在しないか、通常のファイルを参照していない場合
    • newInstance

      public static KeyStore.Builder newInstance(File file, KeyStore.ProtectionParameter protection)
      新しいBuilderオブジェクトを返します。

      戻されたビルダーでgetKeyStore()メソッドの最初のコールでは、fileを使用してKeyStoreを作成し、キーストア・タイプを検出してから、そのload()メソッドをコールします。 KeyStore.getInstance(File, LoadStoreParameter)で説明されているように、同じアルゴリズムを使用してキーストアの型を判別します。 inputStream引数はfileに基づいて構築されます。 protectionPasswordProtectionである場合、パスワードを取得するにはgetPasswordメソッドを呼び出します。 protectionCallbackHandlerProtectionである場合、パスワードを取得するにはCallbackHandlerを呼び出します。

      後続のgetKeyStore()呼出しでは、初回の呼出し時と同じオブジェクトが返されます。 最初の呼び出しがKeyStoreExceptionで失敗した場合、後続の呼び出しもKeyStoreExceptionをスローします。

      getProtectionParameter()を呼び出すと、loadメソッドの呼出し時に使用されたパスワードをカプセル化したPasswordProtectionオブジェクトが返されます。

      getKeyStore()メソッドは、このメソッドを呼び出しているコードのAccessControlContext内で実行されることに注意してください

      パラメータ:
      file - KeyStoreデータを含むファイル
      protection - KeyStoreデータを保護するProtectionParameter
      戻り値:
      新しいBuilderオブジェクト
      例外:
      NullPointerException - ファイルまたは保護がnullの場合
      IllegalArgumentException - protectionがPasswordProtection、CallbackHandlerProtectionのどちらのインスタンスでもない場合、またはfileが存在しないか、通常のファイルを参照していない場合
      導入されたバージョン:
      9
    • newInstance

      public static KeyStore.Builder newInstance(String type, Provider provider, KeyStore.ProtectionParameter protection)
      新しいBuilderオブジェクトを返します。

      戻されたビルダーでgetKeyStore()メソッドを呼び出すたびに、タイプtypeの新しいKeyStoreオブジェクトが返されます。 そのload()メソッドは、protectionをカプセル化したLoadStoreParameterを使用して呼び出されます。

      null以外の場合、KeyStoreproviderからインスタンス化されます。 そうでない場合は、インストールされたすべてのプロバイダが検索されます。

      getProtectionParameter()を呼び出すと、protectionを返します。

      getKeyStore()メソッドは、このメソッドを呼び出しているコードのAccessControlContext内で実行されることに注意してください

      パラメータ:
      type - 構築されるKeyStoreのタイプ
      provider - KeyStoreをインスタンス化するプロバイダ(またはnull)
      protection - Keystoreを保護するProtectionParameter
      戻り値:
      新しいBuilderオブジェクト
      例外:
      NullPointerException - タイプまたは保護がnullの場合