PrivateKeyCallback (JASPIC 3.1 API Documentation - Apache Tomcat 11.0.24)
Description: declaration: package: jakarta.security.auth.message.callback, class: PrivateKeyCallback

# Class PrivateKeyCallback

java.lang.Object
jakarta.security.auth.message.callback.PrivateKeyCallback

All Implemented Interfaces:
  `Callback`

public class PrivateKeyCallback extends Object implements Callback
A callback that enables an authentication module to request a certificate chain and private key from the runtime. The request identifies the desired key material using one of several `PrivateKeyCallback.Request` subtypes, such as keystore alias, certificate digest, subject key identifier, or issuer and serial number.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `PrivateKeyCallback.AliasRequest`
  A request to retrieve a certificate chain and private key by keystore alias.
  `static class`
  `PrivateKeyCallback.DigestRequest`
  A request to retrieve a certificate chain and private key by certificate digest value.
  `static class`
  `PrivateKeyCallback.IssuerSerialNumRequest`
  A request to retrieve a certificate chain and private key by the issuer distinguished name and certificate serial number.
  `static interface`
  `PrivateKeyCallback.Request`
  Base interface for private key requests.
  `static class`
  `PrivateKeyCallback.SubjectKeyIDRequest`
  A request to retrieve a certificate chain and private key by the Subject Key Identifier extension value.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PrivateKeyCallback(PrivateKeyCallback.Request request)`
  Creates a new `PrivateKeyCallback` with the specified request.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Certificate[]`
  `getChain()`
  Returns the certificate chain resolved by the runtime.
  `PrivateKey`
  `getKey()`
  Returns the private key resolved by the runtime.
  `PrivateKeyCallback.Request`
  `getRequest()`
  Returns the request associated with this callback.
  `void`
  `setKey(PrivateKey key, Certificate[] chain)`
  Sets the private key and certificate chain resolved by the runtime in response to the request.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### PrivateKeyCallback

    public PrivateKeyCallback(PrivateKeyCallback.Request request)
    Creates a new `PrivateKeyCallback` with the specified request.
    Parameters:
      `request` - the `Request` object identifying the desired certificate chain and private key

- ## Method Details

  - ### getRequest

    public PrivateKeyCallback.Request getRequest()
    Returns the request associated with this callback.
    Returns:
      the `Request` object

  - ### setKey

    public void setKey(PrivateKey key, Certificate[] chain)
    Sets the private key and certificate chain resolved by the runtime in response to the request.
    Parameters:
      `key` - the resolved `PrivateKey`
      `chain` - the corresponding certificate chain

  - ### getKey

    public PrivateKey getKey()
    Returns the private key resolved by the runtime.
    Returns:
      the `PrivateKey`, or `null` if not yet resolved

  - ### getChain

    public Certificate[] getChain()
    Returns the certificate chain resolved by the runtime.
    Returns:
      the certificate chain, or `null` if not yet resolved