Package net.dona.doip.util.tls

# Class AutoSelfSignedKeyManager

java.lang.Object
javax.net.ssl.X509ExtendedKeyManager
net.dona.doip.util.tls.AutoSelfSignedKeyManager

All Implemented Interfaces:
  `KeyManager`, `X509KeyManager`

public class AutoSelfSignedKeyManager extends X509ExtendedKeyManager
This object is used to provide a private key for authentication to the other side of a secure socket connection.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AutoSelfSignedKeyManager(String id)`
  Constructs a key manager for the supplied identity with a newly minted keypair.
  `AutoSelfSignedKeyManager(String id, X509Certificate[] chain, PrivateKey privKey)`
  Constructs a key manager corresponding to the supplied certificate chain and private key.
  `AutoSelfSignedKeyManager(String id, X509Certificate cert, PrivateKey privKey)`
  Constructs a key manager corresponding to the supplied certificate and private key.
  `AutoSelfSignedKeyManager(String id, PublicKey pubKey, PrivateKey privKey)`
  Constructs a key manager corresponding the the supplied keypair.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `chooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket)`
  `String`
  `chooseEngineClientAlias(String[] as, Principal[] aprincipal, SSLEngine sslengine)`
  `String`
  `chooseEngineServerAlias(String s, Principal[] aprincipal, SSLEngine sslengine)`
  `String`
  `chooseServerAlias(String keyType, Principal[] issuers, Socket socket)`
  `X509Certificate`
  `getCertificate()`
  Returns the certificate (supplied or generated).
  `X509Certificate[]`
  `getCertificateChain(String alias)`
  `String[]`
  `getClientAliases(String keyType, Principal[] issuers)`
  `PrivateKey`
  `getPrivateKey(String alias)`
  `String[]`
  `getServerAliases(String keyType, Principal[] issuers)`

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

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

- ## Constructor Details

  - ### AutoSelfSignedKeyManager

    public AutoSelfSignedKeyManager(String id, X509Certificate[] chain, PrivateKey privKey)
    Constructs a key manager corresponding to the supplied certificate chain and private key.
    Parameters:
      `id` - the identifier of the entity
      `chain` - the certificate chain of the entity
      `privKey` - the private key of the entity

  - ### AutoSelfSignedKeyManager

    public AutoSelfSignedKeyManager(String id, X509Certificate cert, PrivateKey privKey)
    Constructs a key manager corresponding to the supplied certificate and private key.
    Parameters:
      `id` - the identifier of the entity
      `cert` - the certificate of the entity
      `privKey` - the private key of the entity

  - ### AutoSelfSignedKeyManager

    public AutoSelfSignedKeyManager(String id, PublicKey pubKey, PrivateKey privKey)
    Constructs a key manager corresponding the the supplied keypair. A self-signed certificate will be generated with the appropriate id.
    Parameters:
      `id` - the identifier of the entity
      `pubKey` - the public key of the entity
      `privKey` - the private key of the entity

  - ### AutoSelfSignedKeyManager

    public AutoSelfSignedKeyManager(String id) throws Exception
    Constructs a key manager for the supplied identity with a newly minted keypair.
    Parameters:
      `id` - the identifier of the entity
    Throws:
      `Exception` - if there is any issue minting a keypair

- ## Method Details

  - ### getCertificate

    public X509Certificate getCertificate()
    Returns the certificate (supplied or generated).
    Returns:
      the certificate

  - ### chooseClientAlias

    public String chooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket)

  - ### chooseServerAlias

    public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket)

  - ### getServerAliases

    public String[] getServerAliases(String keyType, Principal[] issuers)

  - ### getCertificateChain

    public X509Certificate[] getCertificateChain(String alias)

  - ### getClientAliases

    public String[] getClientAliases(String keyType, Principal[] issuers)

  - ### getPrivateKey

    public PrivateKey getPrivateKey(String alias)

  - ### chooseEngineClientAlias

    public String chooseEngineClientAlias(String[] as, Principal[] aprincipal, SSLEngine sslengine)
    Overrides:
      `chooseEngineClientAlias` in class `X509ExtendedKeyManager`

  - ### chooseEngineServerAlias

    public String chooseEngineServerAlias(String s, Principal[] aprincipal, SSLEngine sslengine)
    Overrides:
      `chooseEngineServerAlias` in class `X509ExtendedKeyManager`