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 Summary
Constructors Constructor Description SelfSignedCertificateRule()
Creates a new instance.SelfSignedCertificateRule(String fqdn)
Creates a new instance.SelfSignedCertificateRule(String fqdn, SecureRandom random, int bits)
Creates a new instance.SelfSignedCertificateRule(String fqdn, SecureRandom random, int bits, TemporalAccessor notBefore, TemporalAccessor notAfter)
Creates a new instance.SelfSignedCertificateRule(String fqdn, TemporalAccessor notBefore, TemporalAccessor notAfter)
Creates a new instance.SelfSignedCertificateRule(TemporalAccessor notBefore, TemporalAccessor notAfter)
Creates a new instance. -
Method Summary
Modifier and Type Method Description protected void
after()
Deletes the generatedSelfSignedCertificate
.protected void
before()
Generates aSelfSignedCertificate
.X509Certificate
certificate()
Returns the generatedX509Certificate
.File
certificateFile()
Returns the self-signed certificate file.PrivateKey
privateKey()
Returns thePrivateKey
of the self-signed certificate.File
privateKeyFile()
Returns the private key file of the self-signed certificate.
-
Constructor Details
-
SelfSignedCertificateRule
public SelfSignedCertificateRule()Creates a new instance. -
SelfSignedCertificateRule
Creates a new instance.- Parameters:
notBefore
-Certificate
is not valid before this timenotAfter
-Certificate
is not valid after this time
-
SelfSignedCertificateRule
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 namenotBefore
-Certificate
is not valid before this timenotAfter
-Certificate
is not valid after this time
-
SelfSignedCertificateRule
Creates a new instance.- Parameters:
fqdn
- a fully qualified domain namerandom
- theSecureRandom
to usebits
- 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 namerandom
- theSecureRandom
to usebits
- the number of bits of the generated private keynotBefore
-Certificate
is not valid before this timenotAfter
-Certificate
is not valid after this time
-
-
Method Details
-
before
Generates aSelfSignedCertificate
.- Overrides:
before
in classExternalResource
- Throws:
Throwable
-
after
protected void after()Deletes the generatedSelfSignedCertificate
.- Overrides:
after
in classExternalResource
-
certificate
Returns the generatedX509Certificate
. -
certificateFile
Returns the self-signed certificate file. -
privateKey
Returns thePrivateKey
of the self-signed certificate. -
privateKeyFile
Returns the private key file of the self-signed certificate.
-