JmeterKeyStore (Apache JMeter dist API)
Description: declaration: package: org.apache.jmeter.util.keystore, class: JmeterKeyStore

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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_ALIAS_VAR_NAME`

- ## Method Summary

  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 alias
  `void`
  `load(InputStream is, String pword)`
  Process the input stream and try to read the keys from the store

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_ALIAS_VAR_NAME

    public static final String DEFAULT_ALIAS_VAR_NAME
    See Also:
      - Constant Field Values

- ## Method Details

  - ### 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 loaded
      `pword` - 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 store
      `CertificateException` - if any of the certificated in the store can not be loaded
      `NoSuchAlgorithmException` - if the algorithm to check the integrity of the store can not be found
      `KeyStoreException` - 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 or null if not found
    See Also:
      - `X509KeyManager.getCertificateChain(String)`

  - ### getAlias

    public String getAlias()
    Get the next or only alias.
    Returns:
      the next or only alias.
    Throws:
      `IllegalArgumentException` - if `clientCertAliasVarName` 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 supported
      `IllegalArgumentException` - when `startIndex` < 0, `endIndex` < -1, or `endIndex` < `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; null if none.
    See Also:
      - `X509KeyManager.getClientAliases(java.lang.String, java.security.Principal[])`