public class PrivateKeyEntryFactoryBean extends org.springframework.beans.factory.config.AbstractFactoryBean<KeyStore.PrivateKeyEntry>
FactoryBean
that reads a JKS-file and extracts a private key with its
certificate.Modifier and Type | Field and Description |
---|---|
protected String |
alias
The alias holding the private key entry.
|
protected char[] |
keyPassword
The password for unlocking the key.
|
protected org.springframework.core.io.Resource |
storeLocation
The resource holding the keystore.
|
protected char[] |
storePassword
The keystore password.
|
protected String |
storeType
The type of keystore.
|
Constructor and Description |
---|
PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation,
char[] storePassword)
Constructor setting up a factory bean that will load the JKS-file given by
storeLocation , unlock it and
then load the private key entry using the storePassword . |
PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation,
char[] storePassword,
String storeType)
Constructor setting up a factory bean that will load the keystore of the given type from
storeLocation ,
unlock it and then load the private key entry using the storePassword . |
PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation,
char[] storePassword,
String alias,
char[] keyPassword)
Constructor setting up a factory bean the will load a JKS-store, unlock it and locate and unlock the given private
key entry identified by
alias . |
PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation,
char[] storePassword,
String storeType,
String alias,
char[] keyPassword)
Constructor setting up a factory bean the will load a keystore of the given type, unlock it and locate and unlock
the given private key entry identified by
alias . |
Modifier and Type | Method and Description |
---|---|
protected KeyStore.PrivateKeyEntry |
createInstance() |
void |
destroy() |
protected void |
destroyInstance(KeyStore.PrivateKeyEntry instance) |
Class<? extends KeyStore.PrivateKeyEntry> |
getObjectType() |
protected org.springframework.core.io.Resource storeLocation
protected char[] storePassword
protected String storeType
protected String alias
null
the first private key entry is selected.protected char[] keyPassword
null
the store password will be used.public PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation, char[] storePassword)
storeLocation
, unlock it and
then load the private key entry using the storePassword
.
This constructor should be used if the caller knows that the keystore only contains one private key entry that has the same password as the store itself. However, if the keystore contains several private key entries, the first one that can be unlocked using the keystore password will be returned.
storeLocation
- the path to the JKS-filestorePassword
- the password for unlocking the JKS-filePrivateKeyEntryFactoryBean(Resource, char[], String, char[])
public PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation, char[] storePassword, String storeType)
storeLocation
,
unlock it and then load the private key entry using the storePassword
.
This constructor should be used if the caller knows that the keystore only contains one private key entry that has the same password as the store itself. However, if the keystore contains several private key entries, the first one that can be unlocked using the keystore password will be returned.
storeLocation
- the path to the keystorestorePassword
- the password for unlocking the keystorestoreType
- the type of keystore ("jks", "pkcs12", ...)PrivateKeyEntryFactoryBean(Resource, char[], String, String, char[])
public PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation, char[] storePassword, String alias, char[] keyPassword)
alias
.storeLocation
- the path to the JKS-filestorePassword
- the password for unlocking the keystorealias
- keystore alias for the private key entrykeyPassword
- the password for unlocking the private key entrypublic PrivateKeyEntryFactoryBean(org.springframework.core.io.Resource storeLocation, char[] storePassword, String storeType, String alias, char[] keyPassword)
alias
.storeLocation
- the path to the JKS-filestorePassword
- the password for unlocking the keystorestoreType
- the type of keystore ("jks", "pkcs12", ...)alias
- keystore alias for the private key entrykeyPassword
- the password for unlocking the private key entryprotected KeyStore.PrivateKeyEntry createInstance() throws Exception
createInstance
in class org.springframework.beans.factory.config.AbstractFactoryBean<KeyStore.PrivateKeyEntry>
Exception
public Class<? extends KeyStore.PrivateKeyEntry> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<KeyStore.PrivateKeyEntry>
getObjectType
in class org.springframework.beans.factory.config.AbstractFactoryBean<KeyStore.PrivateKeyEntry>
public void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
destroy
in class org.springframework.beans.factory.config.AbstractFactoryBean<KeyStore.PrivateKeyEntry>
Exception
protected void destroyInstance(KeyStore.PrivateKeyEntry instance) throws Exception
destroyInstance
in class org.springframework.beans.factory.config.AbstractFactoryBean<KeyStore.PrivateKeyEntry>
Exception
Copyright © 2018 Litsec AB. All rights reserved.