public abstract static class KeyStore.Builder extends Object
此类的实例封装了实例化和初始化KeyStore对象所需的信息。 当调用getKeyStore()方法时,会触发该进程。
这使得可以将配置从KeyStore对象创建中解耦,例如延迟密码提示直到需要。
KeyStore , KeyStoreBuilderParameters 
       | Modifier | Constructor and Description | 
|---|---|
| protected  | Builder()
              构建新的Builder。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract KeyStore | getKeyStore()
              返回此对象描述的KeyStore。 
             | 
| abstract KeyStore.ProtectionParameter | getProtectionParameter(String alias) 
             返回应用于获取具有给定别名的 Entry的ProtectionParameters 。 | 
| 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对象。 
             | 
public abstract KeyStore getKeyStore() throws KeyStoreException
KeyStore KeyStore 
           KeyStoreException - 如果在操作期间发生错误,例如,如果KeyStore无法实例化或加载 
           public abstract KeyStore.ProtectionParameter getProtectionParameter(String alias) throws KeyStoreException
Entry的ProtectionParameters 。 
           在调用此方法之前,必须调用getKeyStore方法。 
          alias - KeyStore条目的别名 
           Entry 。 
           NullPointerException - 如果别名为空 
           KeyStoreException - 操作过程中是否发生错误 
           IllegalStateException - 如果在调用此方法之前尚未调用getKeyStore方法 
           public static KeyStore.Builder newInstance(KeyStore keyStore, KeyStore.ProtectionParameter protectionParameter)
keyStore ,该getProtectionParameter()方法将返回protectionParameters 。 
           如果现有的KeyStore对象需要与基于Builder的API一起使用,这将非常有用。
keyStore - 要封装的KeyStore 
           protectionParameter - 用于保护KeyStore条目的ProtectionParameter 
           NullPointerException - 如果keyStore或protectParameters为空 
           IllegalArgumentException - 如果keyStore尚未初始化 
           public static KeyStore.Builder newInstance(String type, Provider provider, File file, KeyStore.ProtectionParameter protection)
 在返回的构建器上首次调用getKeyStore()方法将创建一个类型为type的KeyStore,并调用其load()方法。 inputStream参数由file 。 如果protection是PasswordProtection ,则通过调用getPassword方法获得密码。 否则,如果protection是CallbackHandlerProtection ,则通过调用CallbackHandler获取密码。 
 后续调用getKeyStore()返回与初始调用相同的对象。 如果初始调用失败与KeyStoreException,后续调用也会抛出一个KeyStoreException。 
 KeyStore如果非空,则从provider化。 否则,将搜索所有已安装的提供程序。 
 调用getProtectionParameter()将返回一个封装用于调用load方法的密码的PasswordProtection对象。 
 请注意 , getKeyStore()方法在调用此方法的代码的AccessControlContext内执行。 
type - 要构建的KeyStore的类型 
           provider - 要从其中实例化KeyStore的提供者(或null) 
           file - 包含KeyStore数据的文件 
           protection - 保护KeyStore数据的ProtectionParameter 
           NullPointerException - 如果类型,文件或保护为空 
           IllegalArgumentException - 如果保护不是PasswordProtection或CallbackHandlerProtection的实例; 
            或者如果文件不存在或不引用普通文件 
           public static KeyStore.Builder newInstance(String type, Provider provider, KeyStore.ProtectionParameter protection)
 每次调用返回的构建器上的getKeyStore()方法将返回一个类型为type的新KeyStore对象。 它的load()方法是使用LoadStoreParameter protection的protection来调用的。 
 KeyStore如果非空,则从provider化。 否则,将搜索所有已安装的提供程序。 
 致电getProtectionParameter()将返回protection 。 
 请注意 , getKeyStore()方法在调用此方法的代码的AccessControlContext中执行。 
type - 要构建的KeyStore的类型 
           provider - 要从其中实例化KeyStore的提供者(或null) 
           protection - 保护密钥库的ProtectionParameter 
           NullPointerException - 如果类型或保护为空 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.