Package org.apache.jmeter.util.keystore
Class JmeterKeyStore
- java.lang.Object
-
- org.apache.jmeter.util.keystore.JmeterKeyStore
-
public final class JmeterKeyStore extends Object
Use this Keystore for JMeter specific KeyStores.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAlias()
Get the next or only alias.String
getAlias(int index)
int
getAliasCount()
X509Certificate[]
getCertificateChain(String alias)
Get the ordered certificate chain for a specific alias.String[]
getClientAliases(String keyType, Principal[] issuers)
Compiles the list of all client aliases with a private key.static JmeterKeyStore
getInstance(String type)
Create a keystore which returns the first alias only.static JmeterKeyStore
getInstance(String type, int startIndex, int endIndex, String clientCertAliasVarName)
Create a keystore which returns a range of aliases (if available)PrivateKey
getPrivateKey(String alias)
Return the private Key for a specific aliasvoid
load(InputStream is, String pword)
Process the input stream and try to read the keys from the store
-
-
-
Method Detail
-
load
public void load(InputStream is, String pword) throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, UnrecoverableKeyException
Process the input stream and try to read the keys from the store- Parameters:
is
-InputStream
from which the store should be loadedpword
- the password used to check the integrity of the store- Throws:
IOException
- if there is a problem decoding or reading the store. A bad password might be the cause for this, or an empty storeCertificateException
- if any of the certificated in the store can not be loadedNoSuchAlgorithmException
- if the algorithm to check the integrity of the store can not be foundKeyStoreException
- if the store has not been initialized (should not happen here)UnrecoverableKeyException
- if the key can not be recovered from the store (should not happen here, either)
-
getCertificateChain
public X509Certificate[] getCertificateChain(String alias)
Get the ordered certificate chain for a specific alias.- Parameters:
alias
- the alias for which the certificate chain should be given- Returns:
- the certificate chain for the alias
- Throws:
IllegalArgumentException
- if no chain could be found for the alias
-
getAlias
public String getAlias()
Get the next or only alias.- Returns:
- the next or only alias.
- Throws:
IllegalArgumentException
- ifclientCertAliasVarName
is not empty and no key for this alias could be found
-
getAliasCount
public int getAliasCount()
-
getAlias
public String getAlias(int index)
-
getPrivateKey
public PrivateKey getPrivateKey(String alias)
Return the private Key for a specific alias- Parameters:
alias
- the name of the alias for the private key- Returns:
- the private key for the given
alias
- Throws:
IllegalArgumentException
- when no private key could be found
-
getInstance
public static JmeterKeyStore getInstance(String type, int startIndex, int endIndex, String clientCertAliasVarName) throws KeyStoreException
Create a keystore which returns a range of aliases (if available)- Parameters:
type
- store type (e.g. JKS)startIndex
- first index (from 0)endIndex
- last index (to count -1)clientCertAliasVarName
- name of the default key to, if empty the first key will be used as default key- Returns:
- the keystore
- Throws:
KeyStoreException
- when the type of the store is not supportedIllegalArgumentException
- whenstartIndex
< 0,endIndex
< 0, orendIndex
<startIndex
-
getInstance
public static JmeterKeyStore getInstance(String type) throws KeyStoreException
Create a keystore which returns the first alias only.- Parameters:
type
- of the store e.g. JKS- Returns:
- the keystore
- Throws:
KeyStoreException
- when the type of the store is not supported
-
getClientAliases
public String[] getClientAliases(String keyType, Principal[] issuers)
Compiles the list of all client aliases with a private key. TODO Currently, keyType and issuers are both ignored.- Parameters:
keyType
- the key algorithm type name (RSA, DSA, etc.)issuers
- the CA certificates we are narrowing our selection on.- Returns:
- the array of aliases; may be empty
-
-