Class SelfSignedCertificateExtension

java.lang.Object
com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
com.linecorp.armeria.testing.junit5.server.SelfSignedCertificateExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

public class SelfSignedCertificateExtension extends AbstractAllOrEachExtension
An Extension that provides a temporary self-signed certificate.
  • Constructor Details

    • SelfSignedCertificateExtension

      public SelfSignedCertificateExtension()
      Creates a new instance.
    • SelfSignedCertificateExtension

      public SelfSignedCertificateExtension(TemporalAccessor notBefore, TemporalAccessor notAfter)
      Creates a new instance.
      Parameters:
      notBefore - Certificate is not valid before this time
      notAfter - Certificate is not valid after this time
    • SelfSignedCertificateExtension

      public SelfSignedCertificateExtension(String fqdn)
      Creates a new instance.
      Parameters:
      fqdn - a fully qualified domain name
    • SelfSignedCertificateExtension

      public SelfSignedCertificateExtension(String fqdn, TemporalAccessor notBefore, TemporalAccessor notAfter)
      Creates a new instance.
      Parameters:
      fqdn - a fully qualified domain name
      notBefore - Certificate is not valid before this time
      notAfter - Certificate is not valid after this time
    • SelfSignedCertificateExtension

      public SelfSignedCertificateExtension(String fqdn, SecureRandom random, int bits)
      Creates a new instance.
      Parameters:
      fqdn - a fully qualified domain name
      random - the SecureRandom to use
      bits - the number of bits of the generated private key
    • SelfSignedCertificateExtension

      public SelfSignedCertificateExtension(String fqdn, SecureRandom random, int bits, TemporalAccessor notBefore, TemporalAccessor notAfter)
      Creates a new instance.
      Parameters:
      fqdn - a fully qualified domain name
      random - the SecureRandom to use
      bits - the number of bits of the generated private key
      notBefore - Certificate is not valid before this time
      notAfter - Certificate is not valid after this time
  • Method Details

    • before

      public void before(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Generates a self-signed certificate.
      Specified by:
      before in class AbstractAllOrEachExtension
      Throws:
      Exception
    • after

      public void after(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Deletes the generated self-signed certificate.
      Specified by:
      after in class AbstractAllOrEachExtension
      Throws:
      Exception
    • certificate

      public X509Certificate certificate()
      Returns the generated X509Certificate.
    • certificateFile

      public File certificateFile()
      Returns the self-signed certificate file.
    • privateKey

      public PrivateKey privateKey()
      Returns the PrivateKey of the self-signed certificate.
    • privateKeyFile

      public File privateKeyFile()
      Returns the private key file of the self-signed certificate.