Class Pkcs11Credential

All Implemented Interfaces:
PkiCredential, ReloadablePkiCredential

public class Pkcs11Credential extends AbstractReloadablePkiCredential
A PKCS#11 credential implementation of the PkiCredential and ReloadablePkiCredential interfaces.

Note: In all cases where the SunPKCS11 security provider is used, it is recommended to use the KeyStoreCredential implementation instead.

Author:
Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
  • Constructor Details

  • Method Details

    • getPrivateKey

      @Nonnull public PrivateKey getPrivateKey()
      Gets the private key.
      Returns:
      the private key
    • getCertificateChain

      @Nonnull public List<X509Certificate> getCertificateChain()
      Gets a certificate chain for the credential, where the first element is the entity certificate (PkiCredential.getCertificate()). If no certificate is configured for the credential an empty list is returned.
      Returns:
      a list of certificates, or an empty list
    • isHardwareCredential

      public boolean isHardwareCredential()
      Returns true.
      Returns:
      true if the credential resides in a hardware module and false otherwise
    • reload

      public void reload() throws Exception
      Is called if the connection to the device has been lost. In those cases we reload the private key.
      Throws:
      Exception - for reloading errors
    • destroy

      @PreDestroy public void destroy()
      Clears the saved PIN code.
    • getDefaultName

      @Nonnull protected String getDefaultName()
      If the credential name property is not explicitly assigned using AbstractPkiCredential.setName(String) a name is calculated based on a credential's properties.
      Specified by:
      getDefaultName in class AbstractPkiCredential
      Returns:
      the credential name