org.apache.jmeter.util.keystore

## Class JmeterKeyStore

- java.lang.Object
- - org.apache.jmeter.util.keystore.JmeterKeyStore

-     public final class JmeterKeyStore
      extends java.lang.Object

  Use this Keystore for JMeter specific KeyStores.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getAlias()` Get the next or only alias.
    `java.lang.String` | `getAlias(int index)`
    `int` | `getAliasCount()`
    `java.security.cert.X509Certificate[]` | `getCertificateChain(java.lang.String alias)` Get the ordered certificate chain for a specific alias.
    `java.lang.String[]` | `getClientAliases(java.lang.String keyType, java.security.Principal[] issuers)` Compiles the list of all client aliases with a private key.
    `static JmeterKeyStore` | `getInstance(java.lang.String type)` Create a keystore which returns the first alias only.
    `static JmeterKeyStore` | `getInstance(java.lang.String type, int startIndex, int endIndex, java.lang.String clientCertAliasVarName)` Create a keystore which returns a range of aliases (if available)
    `java.security.PrivateKey` | `getPrivateKey(java.lang.String alias)` Return the private Key for a specific alias
    `void` | `load(java.io.InputStream is, java.lang.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`

- - ### Method Detail

    - #### load

          public void load(java.io.InputStream is,
                           java.lang.String pword)
                    throws java.security.NoSuchAlgorithmException,
                           java.security.cert.CertificateException,
                           java.io.IOException,
                           java.security.KeyStoreException,
                           java.security.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:
        `java.io.IOException` - if there is a problem decoding or reading the store. A bad password might be the cause for this, or an empty store
        `java.security.cert.CertificateException` - if any of the certificated in the store can not be loaded
        `java.security.NoSuchAlgorithmException` - if the algorithm to check the integrity of the store can not be found
        `java.security.KeyStoreException` - if the store has not been initialized (should not happen here)
        `java.security.UnrecoverableKeyException` - if the key can not be recovered from the store (should not happen here, either)

    - #### getCertificateChain

          public java.security.cert.X509Certificate[] getCertificateChain(java.lang.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:
        `java.lang.IllegalArgumentException` - if no chain could be found for the alias

    - #### getAlias

          public java.lang.String getAlias()

      Get the next or only alias.
      Returns:
        the next or only alias.
      Throws:
        `java.lang.IllegalArgumentException` - if `clientCertAliasVarName` is not empty and no key for this alias could be found

    - #### getAliasCount

          public int getAliasCount()

    - #### getAlias

          public java.lang.String getAlias(int index)

    - #### getPrivateKey

          public java.security.PrivateKey getPrivateKey(java.lang.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:
        `java.lang.IllegalArgumentException` - when no private key could be found

    - #### getInstance

          public static JmeterKeyStore getInstance(java.lang.String type,
                                                   int startIndex,
                                                   int endIndex,
                                                   java.lang.String clientCertAliasVarName)
                                            throws java.security.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:
        `java.security.KeyStoreException` - when the type of the store is not supported
        `java.lang.IllegalArgumentException` - when `startIndex` < 0, `endIndex` < 0, or `endIndex` < `startIndex`

    - #### getInstance

          public static JmeterKeyStore getInstance(java.lang.String type)
                                            throws java.security.KeyStoreException

      Create a keystore which returns the first alias only.
      Parameters:
        `type` - of the store e.g. JKS
      Returns:
        the keystore
      Throws:
        `java.security.KeyStoreException` - when the type of the store is not supported

    - #### getClientAliases

          public java.lang.String[] getClientAliases(java.lang.String keyType,
                                                     java.security.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

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.