JavaTM Platform
Standard Ed. 6

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
関連項目:
KeyStore, KeyStoreBuilderParameters

コンストラクタの概要
protected KeyStore.Builder()
          新しい Builder を構築します。
 
メソッドの概要
abstract  KeyStore getKeyStore()
          このオブジェクトが記述する KeyStore を返します。
abstract  KeyStore.ProtectionParameter getProtectionParameter(String alias)
          指定された別名の Entry を取得する際に使用すべき ProtectionParameter を返します。
static KeyStore.Builder newInstance(KeyStore keyStore, KeyStore.ProtectionParameter protectionParameter)
          指定された KeyStore をカプセル化する新しい Builder を返します。
static KeyStore.Builder newInstance(String type, Provider provider, File file, KeyStore.ProtectionParameter protection)
          新しい Builder オブジェクトを返します。
static KeyStore.Builder newInstance(String type, Provider provider, KeyStore.ProtectionParameter protection)
          新しい Builder オブジェクトを返します。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

KeyStore.Builder

protected KeyStore.Builder()
新しい Builder を構築します。

メソッドの詳細

getKeyStore

public abstract KeyStore getKeyStore()
                              throws KeyStoreException
このオブジェクトが記述する KeyStore を返します。

例外:
KeyStoreException - 処理中にエラーが発生した場合 (KeyStore のインスタンス化またはロードに失敗した場合など)

getProtectionParameter

public abstract KeyStore.ProtectionParameter getProtectionParameter(String alias)
                                                             throws KeyStoreException
指定された別名の Entry を取得する際に使用すべき ProtectionParameter を返します。getKeyStore メソッドを呼び出したあとでないと、このメソッドを呼び出せません。

パラメータ:
alias - KeyStore エントリの別名
戻り値:
指定された別名の Entry を取得する際に使用するべき ProtectionParameter
例外:
NullPointerException - alias が null である場合
KeyStoreException - 処理中にエラーが発生した場合
IllegalStateException - このメソッドを呼び出す前に getKeyStore メソッドを呼び出していない場合

newInstance

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

このメソッドは、Builder ベースの API で既存の KeyStore オブジェクトを使用する必要がある場合に便利です。

パラメータ:
keyStore - カプセル化する KeyStore
protectionParameter - KeyStore エントリの保護に使用する ProtectionParameter
戻り値:
新しい Builder オブジェクト
例外:
NullPointerException - keyStore または protectionParameter のいずれかが null である場合
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 がスローされます。

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

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

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

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

newInstance

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

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

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

getProtectionParameter() を呼び出すと、protection が返されます。

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

パラメータ:
type - 構築する KeyStore の型
provider - KeyStore をインスタンス化する際の基となるプロバイダまたは null
protection - キーストアを保護する ProtectionParameter
戻り値:
新しい Builder オブジェクト
例外:
NullPointerException - type、protection のいずれかが null である場合

JavaTM Platform
Standard Ed. 6

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。