Class SelfSignedCertificateRule

java.lang.Object
org.junit.rules.ExternalResource
com.linecorp.armeria.testing.junit4.server.SelfSignedCertificateRule
All Implemented Interfaces:
TestRule

public final class SelfSignedCertificateRule extends ExternalResource
A TestRule that provides a temporary self-signed certificate.
  • Constructor Details

    • SelfSignedCertificateRule

      public SelfSignedCertificateRule()
      Creates a new instance.
    • SelfSignedCertificateRule

      public SelfSignedCertificateRule(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
    • SelfSignedCertificateRule

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

      public SelfSignedCertificateRule(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
    • SelfSignedCertificateRule

      public SelfSignedCertificateRule(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
    • SelfSignedCertificateRule

      public SelfSignedCertificateRule(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

      protected void before() throws Throwable
      Generates a self-signed certificate.
      Overrides:
      before in class ExternalResource
      Throws:
      Throwable
    • after

      protected void after()
      Deletes the generated self-signed certificate.
      Overrides:
      after in class ExternalResource
    • certificate

      public X509Certificate certificate()
      Returns the generated self-signed 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.