Package java.security
Class KeyStore.Builder
java.lang.Object
java.security.KeyStore.Builder
- Enclosing class:
- KeyStore
public abstract static class KeyStore.Builder extends Object
Builder is used to construct new instances of KeyStore.-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()Constructs a new instance ofBuilder. -
Method Summary
Modifier and Type Method Description abstract KeyStoregetKeyStore()Returns theKeyStorecreated by thisBuilder.abstract KeyStore.ProtectionParametergetProtectionParameter(String alias)Returns theProtectionParameterto be used when aEntrywith the specified alias is requested.static KeyStore.BuildernewInstance(String type, Provider provider, File file, KeyStore.ProtectionParameter protectionParameter)Returns a newBuilderthat creates a newKeyStorebased on the provided arguments.static KeyStore.BuildernewInstance(String type, Provider provider, KeyStore.ProtectionParameter protectionParameter)Returns a newBuilderthat creates a newKeyStorebased on the provided arguments.static KeyStore.BuildernewInstance(KeyStore keyStore, KeyStore.ProtectionParameter protectionParameter)Returns a newBuilderthat holds the givenKeyStoreand the givenProtectionParameter.
-
Constructor Details
-
Builder
protected Builder()Constructs a new instance ofBuilder.
-
-
Method Details
-
getKeyStore
Returns theKeyStorecreated by thisBuilder.- Returns:
- the
KeyStorecreated by thisBuilder. - Throws:
KeyStoreException- if an error occurred during construction.
-
getProtectionParameter
public abstract KeyStore.ProtectionParameter getProtectionParameter(String alias) throws KeyStoreExceptionReturns theProtectionParameterto be used when aEntrywith the specified alias is requested. Before this method is invoked,getKeyStore()must be called.- Parameters:
alias- the alias for the entry.- Returns:
- the
ProtectionParameterto be used when aEntrywith the specified alias is requested. - Throws:
KeyStoreException- if an error occurred during the lookup for the protection parameter.IllegalStateException- ifgetKeyStore()is not called prior the invocation of this method.NullPointerException- ifaliasisnull.
-
newInstance
public static KeyStore.Builder newInstance(KeyStore keyStore, KeyStore.ProtectionParameter protectionParameter)Returns a newBuilderthat holds the givenKeyStoreand the givenProtectionParameter.- Parameters:
keyStore- theKeyStoreto be held.protectionParameter- theProtectionParameterto be held.- Returns:
- a new instance of
Builderthat holds the specifiedKeyStoreand the specifiedProtectionParameter. - Throws:
NullPointerException- ifkeyStoreorprotectionParameterisnull.IllegalArgumentException- if the givenKeyStoreis not initialized.
-
newInstance
public static KeyStore.Builder newInstance(String type, Provider provider, File file, KeyStore.ProtectionParameter protectionParameter)Returns a newBuilderthat creates a newKeyStorebased on the provided arguments.If
providerisnull, all installed providers are searched, otherwise the key store from the specified provider is used.- Parameters:
type- the type of theKeyStoreto be constructed.provider- the provider of theKeyStoreto be constructed, maybenull.file- theFilethat contains the data for theKeyStore.protectionParameter- theProtectionParameterused to protect the stored keys.- Returns:
- a new
Builderthat creates a newKeyStorebased on the provided arguments. - Throws:
NullPointerException- iftype, protectionParameterorfileisnull.IllegalArgumentException-protectionParameternot an instance of eitherPasswordProtectionorCallbackHandlerProtection,fileis not a file or does not exist at all.
-
newInstance
public static KeyStore.Builder newInstance(String type, Provider provider, KeyStore.ProtectionParameter protectionParameter)Returns a newBuilderthat creates a newKeyStorebased on the provided arguments.If
providerisnull, all installed providers are searched, otherwise the key store from the specified provider is used.- Parameters:
type- the type of theKeyStoreto be constructed.provider- the provider of theKeyStoreto be constructed, maybenull.protectionParameter- theProtectionParameterused to protect the stored keys.- Returns:
- a new
Builderthat creates a newKeyStorebased on the provided arguments. - Throws:
NullPointerException- iftypeorprotectionParameterisnull.IllegalArgumentException-protectionParameternot an instance of eitherPasswordProtectionorCallbackHandlerProtection,fileis not a file or does not exist at all.
-