public class Configuration extends Object
Constructor and Description |
---|
Configuration() |
Modifier and Type | Method and Description |
---|---|
Integer |
actionHandlerThreadCount() |
Configuration |
actionHandlerThreadCount(Integer actionHandlerThreadCount)
Number of threads for the action handler thread pool
|
void |
addSslSubjectAlternativeNameDomains(String... additionalSubjectAlternativeNameDomains) |
void |
addSslSubjectAlternativeNameIps(String... additionalSubjectAlternativeNameIps) |
void |
addSubjectAlternativeName(String host) |
Boolean |
alwaysCloseSocketConnections() |
Configuration |
alwaysCloseSocketConnections(Boolean alwaysCloseSocketConnections)
If true socket connections will always be closed after a response is returned, if false connection is only closed if request header indicate connection should be closed.
|
Boolean |
attemptToProxyIfNoMatchingExpectation() |
Configuration |
attemptToProxyIfNoMatchingExpectation(Boolean attemptToProxyIfNoMatchingExpectation)
If true (the default) when no matching expectation is found, and the host header of the request does not match MockServer's host, then MockServer attempts to proxy the request if that fails then a 404 is returned.
|
String |
certificateAuthorityCertificate() |
Configuration |
certificateAuthorityCertificate(String certificateAuthorityCertificate)
File system path or classpath location of custom X.509 Certificate for Certificate Authority for TLS, the certificate must be a X509 PEM file and must match the certificateAuthorityPrivateKey
|
String |
certificateAuthorityPrivateKey() |
Configuration |
certificateAuthorityPrivateKey(String certificateAuthorityPrivateKey)
File system path or classpath location of custom Private Key for Certificate Authority for TLS, the private key must be a PKCS#8 or PKCS#1 PEM file and must match the certificateAuthorityCertificate
To convert a PKCS#1 (i.e.
|
void |
clearSslSubjectAlternativeNameDomains() |
void |
clearSslSubjectAlternativeNameIps() |
Integer |
clientNioEventLoopThreadCount() |
Configuration |
clientNioEventLoopThreadCount(Integer clientNioEventLoopThreadCount)
Client Netty worker thread pool size for handling requests and response.
|
static Configuration |
configuration() |
String |
controlPlaneJWTAuthenticationExpectedAudience() |
Configuration |
controlPlaneJWTAuthenticationExpectedAudience(String controlPlaneJWTAuthenticationExpectedAudience)
Audience claim (i.e.
|
String |
controlPlaneJWTAuthenticationJWKSource() |
Configuration |
controlPlaneJWTAuthenticationJWKSource(String controlPlaneJWTAuthenticationJWKSource)
JWK source used when JWT authentication is enabled for control plane requests
|
Map<String,String> |
controlPlaneJWTAuthenticationMatchingClaims() |
Configuration |
controlPlaneJWTAuthenticationMatchingClaims(Map<String,String> controlPlaneJWTAuthenticationMatchingClaims)
Matching claims expected when JWT authentication is enabled for control plane requests
|
Boolean |
controlPlaneJWTAuthenticationRequired() |
Configuration |
controlPlaneJWTAuthenticationRequired(Boolean controlPlaneJWTAuthenticationRequired)
Require JWT authentication for all control plane requests
|
Set<String> |
controlPlaneJWTAuthenticationRequiredClaims() |
Configuration |
controlPlaneJWTAuthenticationRequiredClaims(Set<String> controlPlaneJWTAuthenticationRequiredClaims)
Required claims that should exist (i.e.
|
String |
controlPlanePrivateKeyPath() |
Configuration |
controlPlanePrivateKeyPath(String controlPlanePrivateKeyPath)
File system path or classpath location of a fixed custom private key for control plane connections using mTLS for authentication.
|
String |
controlPlaneTLSMutualAuthenticationCAChain() |
Configuration |
controlPlaneTLSMutualAuthenticationCAChain(String controlPlaneTLSMutualAuthenticationCAChain)
File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for control plane mTLS authentication
|
Boolean |
controlPlaneTLSMutualAuthenticationRequired() |
Configuration |
controlPlaneTLSMutualAuthenticationRequired(Boolean controlPlaneTLSMutualAuthenticationRequired)
Require mTLS (also called client authentication and two-way TLS) for all control plane requests
|
String |
controlPlaneX509CertificatePath() |
Configuration |
controlPlaneX509CertificatePath(String controlPlaneX509CertificatePath)
File system path or classpath location of a fixed custom X.509 Certificate for control plane connections using mTLS for authentication.
|
Boolean |
corsAllowCredentials() |
Configuration |
corsAllowCredentials(Boolean corsAllowCredentials)
The value used for CORS in the access-control-allow-credentials header.
|
String |
corsAllowHeaders() |
Configuration |
corsAllowHeaders(String corsAllowHeaders)
the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers.
|
String |
corsAllowMethods() |
Configuration |
corsAllowMethods(String corsAllowMethods)
the value used for CORS in the access-control-allow-methods header.
|
String |
corsAllowOrigin() |
Configuration |
corsAllowOrigin(String corsAllowOrigin)
the value used for CORS in the access-control-allow-origin header.
|
Integer |
corsMaxAgeInSeconds() |
Configuration |
corsMaxAgeInSeconds(Integer corsMaxAgeInSeconds)
The value used for CORS in the access-control-max-age header.
|
Boolean |
detailedMatchFailures() |
Configuration |
detailedMatchFailures(Boolean detailedMatchFailures)
If true (the default) the log event recording that a request matcher did not match will include a detailed reason why each non-matching field did not match.
|
String |
directoryToSaveDynamicSSLCertificate() |
Configuration |
directoryToSaveDynamicSSLCertificate(String directoryToSaveDynamicSSLCertificate)
Directory used to save the dynamically generated Certificate Authority X.509 Certificate and Private Key.
|
Boolean |
disableLogging() |
Configuration |
disableLogging(Boolean disableLogging)
Disable all logging and processing of log events
|
Boolean |
disableSystemOut() |
Configuration |
disableSystemOut(Boolean disableSystemOut)
Disable printing log to system out for JVM, default is enabled
|
Boolean |
dynamicallyCreateCertificateAuthorityCertificate() |
Configuration |
dynamicallyCreateCertificateAuthorityCertificate(Boolean dynamicallyCreateCertificateAuthorityCertificate)
Enable dynamic creation of Certificate Authority X509 certificate and private key.
|
Boolean |
enableCORSForAllResponses() |
Configuration |
enableCORSForAllResponses(Boolean enableCORSForAllResponses)
Enable CORS for all responses from MockServer, including the REST API and expectation responses
|
Boolean |
enableCORSForAPI() |
Configuration |
enableCORSForAPI(Boolean enableCORSForAPI)
Enable CORS for MockServer REST API so that the API can be used for javascript running in browsers, such as selenium
|
InetSocketAddress |
forwardHttpProxy() |
Configuration |
forwardHttpProxy(InetSocketAddress forwardHttpProxy)
Use HTTP proxy (i.e.
|
InetSocketAddress |
forwardHttpsProxy() |
Configuration |
forwardHttpsProxy(InetSocketAddress forwardHttpsProxy)
Use HTTPS proxy (i.e.
|
String |
forwardProxyAuthenticationPassword() |
Configuration |
forwardProxyAuthenticationPassword(String forwardProxyAuthenticationPassword)
Password for proxy authentication when using HTTPS proxy (i.e.
|
String |
forwardProxyAuthenticationUsername() |
Configuration |
forwardProxyAuthenticationUsername(String forwardProxyAuthenticationUsername)
Username for proxy authentication when using HTTPS proxy (i.e.
|
String |
forwardProxyCertificateChain() |
Configuration |
forwardProxyCertificateChain(String forwardProxyCertificateChain)
File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for Trusting (i.e.
|
String |
forwardProxyPrivateKey() |
Configuration |
forwardProxyPrivateKey(String forwardProxyPrivateKey)
File system path or classpath location of custom Private Key for proxied TLS connections out of MockServer, the private key must be a PKCS#8 or PKCS#1 PEM file
|
String |
forwardProxyTLSCustomTrustX509Certificates() |
Configuration |
forwardProxyTLSCustomTrustX509Certificates(String forwardProxyTLSCustomTrustX509Certificates)
File system path or classpath location of custom file for trusted X509 Certificate Authority roots for forwarded or proxied requests, the certificate chain must be a X509 PEM file.
|
ForwardProxyTLSX509CertificatesTrustManager |
forwardProxyTLSX509CertificatesTrustManagerType() |
Configuration |
forwardProxyTLSX509CertificatesTrustManagerType(ForwardProxyTLSX509CertificatesTrustManager forwardProxyTLSX509CertificatesTrustManagerType)
Configure trusted set of certificates for forwarded or proxied requests.
|
InetSocketAddress |
forwardSocksProxy() |
Configuration |
forwardSocksProxy(InetSocketAddress forwardSocksProxy)
Use SOCKS proxy for all outbound / forwarded requests, support TLS tunnelling of TCP connections
|
String |
initializationClass() |
Configuration |
initializationClass(String initializationClass)
The class (and package) used to initialize expectations in MockServer at startup, if set MockServer will load and call this class to initialize expectations when is starts.
|
String |
initializationJsonPath() |
Configuration |
initializationJsonPath(String initializationJsonPath)
The path to the json file used to initialize expectations in MockServer at startup, if set MockServer will load this file and initialise expectations for each item in the file when is starts.
|
Boolean |
launchUIForLogLevelDebug() |
Configuration |
launchUIForLogLevelDebug(Boolean launchUIForLogLevelDebug)
If true (the default) the ClientAndServer constructor will open the UI in the default browser when the log level is set to DEBUG.
|
String |
livenessHttpGetPath() |
Configuration |
livenessHttpGetPath(String livenessHttpGetPath)
Path to support HTTP GET requests for status response (also available on PUT /mockserver/status).
|
String |
localBoundIP() |
Configuration |
localBoundIP(String localBoundIP)
The local IP address to bind to for accepting new socket connections
|
org.slf4j.event.Level |
logLevel() |
Configuration |
logLevel(org.slf4j.event.Level level)
Override the default logging level of INFO
|
Configuration |
logLevel(String level)
Override the default logging level of INFO
|
Boolean |
matchersFailFast() |
Configuration |
matchersFailFast(Boolean matchersFailFast)
If true (the default) request matchers will fail on the first non-matching field, if false request matchers will compare all fields.
|
Integer |
maxChunkSize() |
Configuration |
maxChunkSize(Integer maxChunkSize)
Maximum size of HTTP chunks in request or responses
|
Integer |
maxExpectations() |
Configuration |
maxExpectations(Integer maxExpectations)
Maximum number of expectations stored in memory.
|
Long |
maxFutureTimeoutInMillis() |
Configuration |
maxFutureTimeoutInMillis(Long maxFutureTimeoutInMillis)
Maximum time allowed in milliseconds for any future to wait, for example when waiting for a response over a web socket callback.
|
Integer |
maxHeaderSize() |
Configuration |
maxHeaderSize(Integer maxHeaderSize)
Maximum size of HTTP request headers
|
Integer |
maximumNumberOfRequestToReturnInVerificationFailure() |
Configuration |
maximumNumberOfRequestToReturnInVerificationFailure(Integer maximumNumberOfRequestToReturnInVerificationFailure)
The maximum number of requests to return in verification failure result, if more expectations are found the failure result does not list them separately
|
Integer |
maxInitialLineLength() |
Configuration |
maxInitialLineLength(Integer maxInitialLineLength)
Maximum size of the first line of an HTTP request
|
Integer |
maxLogEntries() |
Configuration |
maxLogEntries(Integer maxLogEntries)
Maximum number of log entries stored in memory.
|
Long |
maxSocketTimeoutInMillis() |
Configuration |
maxSocketTimeoutInMillis(Long maxSocketTimeoutInMillis)
Maximum time in milliseconds allowed for a response from a socket
|
Integer |
maxWebSocketExpectations() |
Configuration |
maxWebSocketExpectations(Integer maxWebSocketExpectations)
Maximum number of remote (not the same JVM) method callbacks (i.e.
|
String |
memoryUsageCsvDirectory() |
Configuration |
memoryUsageCsvDirectory(String memoryUsageCsvDirectory)
Directory to output JVM memory usage metrics CSV files to when outputMemoryUsageCsv enabled
|
Boolean |
metricsEnabled() |
Configuration |
metricsEnabled(Boolean metricsEnabled)
Enable gathering of metrics, default is false
|
Integer |
nioEventLoopThreadCount() |
Configuration |
nioEventLoopThreadCount(Integer nioEventLoopThreadCount)
Netty worker thread pool size for handling requests and response.
|
Boolean |
outputMemoryUsageCsv() |
Configuration |
outputMemoryUsageCsv(Boolean outputMemoryUsageCsv)
Output JVM memory usage metrics to CSV file periodically called memoryUsage_<yyyy-MM-dd>.csv
|
String |
persistedExpectationsPath() |
Configuration |
persistedExpectationsPath(String persistedExpectationsPath)
The file path used to save persisted expectations as json, which is updated whenever the expectation state is updated (i.e.
|
Boolean |
persistExpectations() |
Configuration |
persistExpectations(Boolean persistExpectations)
Enable the persisting of expectations as json, which is updated whenever the expectation state is updated (i.e.
|
Boolean |
preventCertificateDynamicUpdate() |
Configuration |
preventCertificateDynamicUpdate(Boolean preventCertificateDynamicUpdate)
Prevent certificates from dynamically updating when domain list changes
|
String |
privateKeyPath() |
Configuration |
privateKeyPath(String privateKeyPath)
File system path or classpath location of a fixed custom private key for TLS connections into MockServer.
|
Boolean |
proactivelyInitialiseTLS() |
Configuration |
proactivelyInitialiseTLS(Boolean proactivelyInitialiseTLS)
Proactively initialise TLS during start to ensure that if dynamicallyCreateCertificateAuthorityCertificate is enabled the Certificate Authority X.509 Certificate and Private Key will be created during start up and not when the first TLS connection is received.
|
String |
proxyAuthenticationPassword() |
Configuration |
proxyAuthenticationPassword(String proxyAuthenticationPassword)
The required password for proxy authentication to MockServer
|
String |
proxyAuthenticationRealm() |
Configuration |
proxyAuthenticationRealm(String proxyAuthenticationRealm)
The authentication realm for proxy authentication to MockServer
|
String |
proxyAuthenticationUsername() |
Configuration |
proxyAuthenticationUsername(String proxyAuthenticationUsername)
The required username for proxy authentication to MockServer
|
boolean |
rebuildServerTLSContext() |
Configuration |
rebuildServerTLSContext(boolean rebuildServerTLSContext) |
boolean |
rebuildTLSContext() |
Configuration |
rebuildTLSContext(boolean rebuildTLSContext) |
int |
ringBufferSize() |
Long |
socketConnectionTimeoutInMillis() |
Configuration |
socketConnectionTimeoutInMillis(Long socketConnectionTimeoutInMillis)
Maximum time in milliseconds allowed to connect to a socket
|
String |
sslCertificateDomainName() |
Configuration |
sslCertificateDomainName(String sslCertificateDomainName)
The domain name for auto-generate TLS certificates
|
Set<String> |
sslSubjectAlternativeNameDomains() |
Configuration |
sslSubjectAlternativeNameDomains(Set<String> sslSubjectAlternativeNameDomains)
The Subject Alternative Name (SAN) domain names for auto-generate TLS certificates
|
Configuration |
sslSubjectAlternativeNameDomains(String... sslSubjectAlternativeNameDomains)
The Subject Alternative Name (SAN) domain names for auto-generate TLS certificates
|
Set<String> |
sslSubjectAlternativeNameIps() |
Configuration |
sslSubjectAlternativeNameIps(Set<String> sslSubjectAlternativeNameIps)
The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates
|
Configuration |
sslSubjectAlternativeNameIps(String... sslSubjectAlternativeNameIps)
The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates
|
String |
tlsMutualAuthenticationCertificateChain() |
Configuration |
tlsMutualAuthenticationCertificateChain(String tlsMutualAuthenticationCertificateChain)
File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for trusting (i.e.
|
Boolean |
tlsMutualAuthenticationRequired() |
Configuration |
tlsMutualAuthenticationRequired(Boolean tlsMutualAuthenticationRequired)
Require mTLS (also called client authentication and two-way TLS) for all TLS connections / HTTPS requests to MockServer
|
Boolean |
useSemicolonAsQueryParameterSeparator() |
Configuration |
useSemicolonAsQueryParameterSeparator(Boolean useSemicolonAsQueryParameterSeparator)
If true semicolons are treated as a separator for a query parameter string, if false the semicolon is treated as a normal character that is part of a query parameter value.
|
Boolean |
watchInitializationJson() |
Configuration |
watchInitializationJson(Boolean watchInitializationJson)
If enabled the initialization json file will be watched for changes, any changes found will result in expectations being created, remove or updated by matching against their key.
|
Integer |
webSocketClientEventLoopThreadCount() |
Configuration |
webSocketClientEventLoopThreadCount(Integer webSocketClientEventLoopThreadCount)
Client Netty worker thread pool size for handling requests and response.
|
String |
x509CertificatePath() |
Configuration |
x509CertificatePath(String x509CertificatePath)
File system path or classpath location of a fixed custom X.509 Certificate for TLS connections into MockServer.
|
public static Configuration configuration()
public org.slf4j.event.Level logLevel()
public Configuration logLevel(org.slf4j.event.Level level)
level
- the log level, which can be TRACE, DEBUG, INFO, WARN, ERROR, OFF, FINEST, FINE, INFO, WARNING, SEVEREpublic Configuration logLevel(String level)
level
- the log level, which can be TRACE, DEBUG, INFO, WARN, ERROR, OFF, FINEST, FINE, INFO, WARNING, SEVEREpublic Boolean disableSystemOut()
public Configuration disableSystemOut(Boolean disableSystemOut)
disableSystemOut
- printing log to system out for JVMpublic Boolean disableLogging()
public Configuration disableLogging(Boolean disableLogging)
The default is false
disableLogging
- disable all loggingpublic Boolean detailedMatchFailures()
public Configuration detailedMatchFailures(Boolean detailedMatchFailures)
detailedMatchFailures
- enabled detailed match failure log eventspublic Boolean launchUIForLogLevelDebug()
public Configuration launchUIForLogLevelDebug(Boolean launchUIForLogLevelDebug)
launchUIForLogLevelDebug
- enabled ClientAndServer constructor launching UI when log level is DEBUGpublic Boolean metricsEnabled()
public Configuration metricsEnabled(Boolean metricsEnabled)
metricsEnabled
- enable metricspublic Integer maxExpectations()
public Configuration maxExpectations(Integer maxExpectations)
Maximum number of expectations stored in memory. Expectations are stored in a circular queue so once this limit is reach the oldest and lowest priority expectations are overwritten
The default maximum depends on the available memory in the JVM with an upper limit of 5000
maxExpectations
- maximum number of expectations to storepublic Integer maxLogEntries()
public Configuration maxLogEntries(Integer maxLogEntries)
Maximum number of log entries stored in memory. Log entries are stored in a circular queue so once this limit is reach the oldest log entries are overwritten
The default maximum depends on the available memory in the JVM with an upper limit of 60000
maxLogEntries
- maximum number of expectations to storepublic Integer maxWebSocketExpectations()
public Configuration maxWebSocketExpectations(Integer maxWebSocketExpectations)
Maximum number of remote (not the same JVM) method callbacks (i.e. web sockets) registered for expectations. The web socket client registry entries are stored in a circular queue so once this limit is reach the oldest are overwritten.
The default is 1500
maxWebSocketExpectations
- maximum number of method callbacks (i.e. web sockets) registered for expectationspublic Boolean outputMemoryUsageCsv()
public Configuration outputMemoryUsageCsv(Boolean outputMemoryUsageCsv)
Output JVM memory usage metrics to CSV file periodically called memoryUsage_<yyyy-MM-dd>.csv
outputMemoryUsageCsv
- output of JVM memory metricspublic String memoryUsageCsvDirectory()
public Configuration memoryUsageCsvDirectory(String memoryUsageCsvDirectory)
Directory to output JVM memory usage metrics CSV files to when outputMemoryUsageCsv enabled
memoryUsageCsvDirectory
- directory to save JVM memory metrics CSV filespublic Integer nioEventLoopThreadCount()
public Configuration nioEventLoopThreadCount(Integer nioEventLoopThreadCount)
Netty worker thread pool size for handling requests and response. These threads handle deserializing and serialising HTTP requests and responses and some other fast logic, long running tasks are done on the action handler thread pool.
nioEventLoopThreadCount
- Netty worker thread pool sizepublic Integer actionHandlerThreadCount()
public Configuration actionHandlerThreadCount(Integer actionHandlerThreadCount)
Number of threads for the action handler thread pool
These threads are used for handling actions such as:
Default is maximum of 5 or available processors count
actionHandlerThreadCount
- Netty worker thread pool sizepublic Integer clientNioEventLoopThreadCount()
public Configuration clientNioEventLoopThreadCount(Integer clientNioEventLoopThreadCount)
Client Netty worker thread pool size for handling requests and response. These threads handle deserializing and serialising HTTP requests and responses and some other fast logic.
Default is 5 threads
clientNioEventLoopThreadCount
- Client Netty worker thread pool sizepublic Integer webSocketClientEventLoopThreadCount()
public Configuration webSocketClientEventLoopThreadCount(Integer webSocketClientEventLoopThreadCount)
Client Netty worker thread pool size for handling requests and response. These threads handle deserializing and serialising HTTP requests and responses and some other fast logic.
Default is 5 threads
webSocketClientEventLoopThreadCount
- Client Netty worker thread pool sizepublic Long maxFutureTimeoutInMillis()
public Configuration maxFutureTimeoutInMillis(Long maxFutureTimeoutInMillis)
Default is 60,000 ms
maxFutureTimeoutInMillis
- maximum time allowed in millisecondspublic Boolean matchersFailFast()
public Configuration matchersFailFast(Boolean matchersFailFast)
matchersFailFast
- enabled request matchers failing fastpublic Long maxSocketTimeoutInMillis()
public Configuration maxSocketTimeoutInMillis(Long maxSocketTimeoutInMillis)
Default is 20,000 ms
maxSocketTimeoutInMillis
- maximum time in milliseconds allowedpublic Long socketConnectionTimeoutInMillis()
public Configuration socketConnectionTimeoutInMillis(Long socketConnectionTimeoutInMillis)
Default is 20,000 ms
socketConnectionTimeoutInMillis
- maximum time allowed in millisecondspublic Boolean alwaysCloseSocketConnections()
public Configuration alwaysCloseSocketConnections(Boolean alwaysCloseSocketConnections)
If true socket connections will always be closed after a response is returned, if false connection is only closed if request header indicate connection should be closed.
Default is false
alwaysCloseSocketConnections
- true socket connections will always be closed after a response is returnedpublic String localBoundIP()
public Configuration localBoundIP(String localBoundIP)
Default is 0.0.0.0
localBoundIP
- local IP address to bind to for accepting new socket connectionspublic Integer maxInitialLineLength()
public Configuration maxInitialLineLength(Integer maxInitialLineLength)
The default is Integer.MAX_VALUE
maxInitialLineLength
- maximum size of the first line of an HTTP requestpublic Integer maxHeaderSize()
public Configuration maxHeaderSize(Integer maxHeaderSize)
The default is Integer.MAX_VALUE
maxHeaderSize
- maximum size of HTTP request headerspublic Integer maxChunkSize()
public Configuration maxChunkSize(Integer maxChunkSize)
The default is Integer.MAX_VALUE
maxChunkSize
- maximum size of HTTP chunks in request or responsespublic Boolean useSemicolonAsQueryParameterSeparator()
public Configuration useSemicolonAsQueryParameterSeparator(Boolean useSemicolonAsQueryParameterSeparator)
The default is true
useSemicolonAsQueryParameterSeparator
- true semicolons are treated as a separator for a query parameter stringpublic Boolean enableCORSForAPI()
public Configuration enableCORSForAPI(Boolean enableCORSForAPI)
The default is false
enableCORSForAPI
- CORS for MockServer REST APIpublic Boolean enableCORSForAllResponses()
public Configuration enableCORSForAllResponses(Boolean enableCORSForAllResponses)
The default is false
enableCORSForAllResponses
- CORS for all responses from MockServerpublic String corsAllowOrigin()
public Configuration corsAllowOrigin(String corsAllowOrigin)
the value used for CORS in the access-control-allow-origin header.
The default is ""
corsAllowOrigin
- the value used for CORS in the access-control-allow-methods headerpublic String corsAllowMethods()
public Configuration corsAllowMethods(String corsAllowMethods)
the value used for CORS in the access-control-allow-methods header.
The default is ""
corsAllowMethods
- the value used for CORS in the access-control-allow-methods headerpublic String corsAllowHeaders()
public Configuration corsAllowHeaders(String corsAllowHeaders)
the value used for CORS in the access-control-allow-headers and access-control-expose-headers headers.
In addition to this default value any headers specified in the request header access-control-request-headers also get added to access-control-allow-headers and access-control-expose-headers headers in a CORS response.
The default is ""
corsAllowHeaders
- the value used for CORS in the access-control-allow-headers and access-control-expose-headers headerspublic Boolean corsAllowCredentials()
public Configuration corsAllowCredentials(Boolean corsAllowCredentials)
The default is false
corsAllowCredentials
- the value used for CORS in the access-control-allow-credentials headerpublic Integer corsMaxAgeInSeconds()
public Configuration corsMaxAgeInSeconds(Integer corsMaxAgeInSeconds)
The default is 0
corsMaxAgeInSeconds
- the value used for CORS in the access-control-max-age header.public String initializationClass()
public Configuration initializationClass(String initializationClass)
The default is null
initializationClass
- class (and package) used to initialize expectations in MockServer at startuppublic String initializationJsonPath()
public Configuration initializationJsonPath(String initializationJsonPath)
The path to the json file used to initialize expectations in MockServer at startup, if set MockServer will load this file and initialise expectations for each item in the file when is starts.
The expected format of the file is a JSON array of expectations, as per the REST API format
initializationJsonPath
- path to the json file used to initialize expectations in MockServer at startuppublic Boolean watchInitializationJson()
public Configuration watchInitializationJson(Boolean watchInitializationJson)
If enabled the initialization json file will be watched for changes, any changes found will result in expectations being created, remove or updated by matching against their key.
If duplicate keys exist only the last duplicate key in the file will be processed and all duplicates except the last duplicate will be removed.
The order of expectations in the file is the order in which they are created if they are new, however, re-ordering existing expectations does not change the order they are matched against incoming requests.
The default is false
watchInitializationJson
- if enabled the initialization json file will be watched for changespublic Boolean persistExpectations()
public Configuration persistExpectations(Boolean persistExpectations)
The default is false
persistExpectations
- the persisting of expectations as jsonpublic String persistedExpectationsPath()
public Configuration persistedExpectationsPath(String persistedExpectationsPath)
The default is "persistedExpectations.json"
persistedExpectationsPath
- file path used to save persisted expectations as jsonpublic Integer maximumNumberOfRequestToReturnInVerificationFailure()
public Configuration maximumNumberOfRequestToReturnInVerificationFailure(Integer maximumNumberOfRequestToReturnInVerificationFailure)
maximumNumberOfRequestToReturnInVerificationFailure
- maximum number of expectations to return in verification failure resultpublic Boolean attemptToProxyIfNoMatchingExpectation()
public Configuration attemptToProxyIfNoMatchingExpectation(Boolean attemptToProxyIfNoMatchingExpectation)
attemptToProxyIfNoMatchingExpectation
- enables automatically attempted proxying of request that don't match an expectation and look like they should be proxiedpublic InetSocketAddress forwardHttpProxy()
public Configuration forwardHttpProxy(InetSocketAddress forwardHttpProxy)
The default is null
forwardHttpProxy
- host and port for HTTP proxy (i.e. via Host header) for all outbound / forwarded requestspublic InetSocketAddress forwardHttpsProxy()
public Configuration forwardHttpsProxy(InetSocketAddress forwardHttpsProxy)
The default is null
forwardHttpsProxy
- host and port for HTTPS proxy (i.e. HTTP CONNECT) for all outbound / forwarded requestspublic InetSocketAddress forwardSocksProxy()
public Configuration forwardSocksProxy(InetSocketAddress forwardSocksProxy)
The default is null
forwardSocksProxy
- host and port for SOCKS proxy for all outbound / forwarded requestspublic String forwardProxyAuthenticationUsername()
public Configuration forwardProxyAuthenticationUsername(String forwardProxyAuthenticationUsername)
Username for proxy authentication when using HTTPS proxy (i.e. HTTP CONNECT) for all outbound / forwarded requests
Note: 8u111 Update Release Notes state that the Basic authentication scheme has been deactivated when setting up an HTTPS tunnel. To resolve this clear or set to an empty string the following system properties: jdk.http.auth.tunneling.disabledSchemes
and jdk.http.auth.proxying.disabledSchemes
.
The default is null
forwardProxyAuthenticationUsername
- username for proxy authenticationpublic String forwardProxyAuthenticationPassword()
public Configuration forwardProxyAuthenticationPassword(String forwardProxyAuthenticationPassword)
Password for proxy authentication when using HTTPS proxy (i.e. HTTP CONNECT) for all outbound / forwarded requests
Note: 8u111 Update Release Notes state that the Basic authentication scheme has been deactivated when setting up an HTTPS tunnel. To resolve this clear or set to an empty string the following system properties: jdk.http.auth.tunneling.disabledSchemes
and jdk.http.auth.proxying.disabledSchemes
.
The default is null
forwardProxyAuthenticationPassword
- password for proxy authenticationpublic String proxyAuthenticationRealm()
public Configuration proxyAuthenticationRealm(String proxyAuthenticationRealm)
proxyAuthenticationRealm
- the authentication realm for proxy authenticationpublic String proxyAuthenticationUsername()
public Configuration proxyAuthenticationUsername(String proxyAuthenticationUsername)
The required username for proxy authentication to MockServer
Note: 8u111 Update Release Notes state that the Basic authentication scheme has been deactivated when setting up an HTTPS tunnel. To resolve this clear or set to an empty string the following system properties: jdk.http.auth.tunneling.disabledSchemes
and jdk.http.auth.proxying.disabledSchemes
.
The default is ""
proxyAuthenticationUsername
- required username for proxy authentication to MockServerpublic String proxyAuthenticationPassword()
public Configuration proxyAuthenticationPassword(String proxyAuthenticationPassword)
The required password for proxy authentication to MockServer
Note: 8u111 Update Release Notes state that the Basic authentication scheme has been deactivated when setting up an HTTPS tunnel. To resolve this clear or set to an empty string the following system properties: jdk.http.auth.tunneling.disabledSchemes
and jdk.http.auth.proxying.disabledSchemes
.
The default is ""
proxyAuthenticationPassword
- required password for proxy authentication to MockServerpublic String livenessHttpGetPath()
public Configuration livenessHttpGetPath(String livenessHttpGetPath)
If this value is not modified then only PUT /mockserver/status but is a none blank value is provided for this value then GET requests to this path will return the 200 Ok status response showing the MockServer version and bound ports.
A GET request to this path will be matched before any expectation matching or proxying of requests.
The default is ""
livenessHttpGetPath
- path to support HTTP GET requests for status responsepublic Boolean controlPlaneTLSMutualAuthenticationRequired()
public Configuration controlPlaneTLSMutualAuthenticationRequired(Boolean controlPlaneTLSMutualAuthenticationRequired)
controlPlaneTLSMutualAuthenticationRequired
- TLS mutual authentication for all control plane requestspublic String controlPlaneTLSMutualAuthenticationCAChain()
public Configuration controlPlaneTLSMutualAuthenticationCAChain(String controlPlaneTLSMutualAuthenticationCAChain)
The X.509 Certificate Chain is for trusting (i.e. signature verification of) Client X.509 Certificates, the certificate chain must be a X509 PEM file.
This certificate chain will be used for to performs mTLS (client authentication) for inbound TLS connections if controlPlaneTLSMutualAuthenticationRequired is enabled
controlPlaneTLSMutualAuthenticationCAChain
- File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for Trusting (i.e. signature verification of) Client X.509 Certificatespublic String controlPlanePrivateKeyPath()
public Configuration controlPlanePrivateKeyPath(String controlPlanePrivateKeyPath)
The private key must be a PKCS#8 or PKCS#1 PEM file and must be the private key corresponding to the controlPlaneX509CertificatePath X509 (public key) configuration. The controlPlaneTLSMutualAuthenticationCAChain configuration must be the Certificate Authority for the corresponding X509 certificate (i.e. able to valid its signature).
To convert a PKCS#1 (i.e. default for Bouncy Castle) to a PKCS#8 the following command can be used: openssl pkcs8 -topk8 -inform PEM -in private_key_PKCS_1.pem -out private_key_PKCS_8.pem -nocrypt
This configuration will be ignored unless x509CertificatePath is also set.
controlPlanePrivateKeyPath
- location of the PKCS#8 PEM file containing the private keypublic String controlPlaneX509CertificatePath()
public Configuration controlPlaneX509CertificatePath(String controlPlaneX509CertificatePath)
The certificate must be a X509 PEM file and must be the public key corresponding to the controlPlanePrivateKeyPath private key configuration. The controlPlaneTLSMutualAuthenticationCAChain configuration must be the Certificate Authority for this certificate (i.e. able to valid its signature).
This configuration will be ignored unless privateKeyPath is also set.
controlPlaneX509CertificatePath
- location of the PEM file containing the X509 certificatepublic Boolean controlPlaneJWTAuthenticationRequired()
public Configuration controlPlaneJWTAuthenticationRequired(Boolean controlPlaneJWTAuthenticationRequired)
Require JWT authentication for all control plane requests
controlPlaneJWTAuthenticationRequired
- TLS mutual authentication for all control plane requestspublic String controlPlaneJWTAuthenticationJWKSource()
public Configuration controlPlaneJWTAuthenticationJWKSource(String controlPlaneJWTAuthenticationJWKSource)
JWK source used when JWT authentication is enabled for control plane requests
JWK source can be a file system path, classpath location or a URL
See: https://openid.net/specs/draft-jones-json-web-key-03.html
controlPlaneJWTAuthenticationJWKSource
- file system path, classpath location or a URL of JWK sourcepublic String controlPlaneJWTAuthenticationExpectedAudience()
public Configuration controlPlaneJWTAuthenticationExpectedAudience(String controlPlaneJWTAuthenticationExpectedAudience)
Audience claim (i.e. aud) required when JWT authentication is enabled for control plane requests
controlPlaneJWTAuthenticationExpectedAudience
- required value for audience claim (i.e. aud)public Map<String,String> controlPlaneJWTAuthenticationMatchingClaims()
public Configuration controlPlaneJWTAuthenticationMatchingClaims(Map<String,String> controlPlaneJWTAuthenticationMatchingClaims)
Matching claims expected when JWT authentication is enabled for control plane requests
Value should be string with comma separated key=value items, for example: scope=internal public,sub=some_subject
controlPlaneJWTAuthenticationMatchingClaims
- required values for claimspublic Set<String> controlPlaneJWTAuthenticationRequiredClaims()
public Configuration controlPlaneJWTAuthenticationRequiredClaims(Set<String> controlPlaneJWTAuthenticationRequiredClaims)
Required claims that should exist (i.e. with any value) when JWT authentication is enabled for control plane requests
Value should be string with comma separated values, for example: scope,sub
controlPlaneJWTAuthenticationRequiredClaims
- required claimspublic Boolean proactivelyInitialiseTLS()
public Configuration proactivelyInitialiseTLS(Boolean proactivelyInitialiseTLS)
Proactively initialise TLS during start to ensure that if dynamicallyCreateCertificateAuthorityCertificate is enabled the Certificate Authority X.509 Certificate and Private Key will be created during start up and not when the first TLS connection is received.
This setting will also ensure any configured private key and X.509 will be loaded during start up and not when the first TLS connection is received to give immediate feedback on any related TLS configuration errors.
proactivelyInitialiseTLS
- proactively initialise TLS at startuppublic boolean rebuildTLSContext()
public Configuration rebuildTLSContext(boolean rebuildTLSContext)
public boolean rebuildServerTLSContext()
public Configuration rebuildServerTLSContext(boolean rebuildServerTLSContext)
public Boolean dynamicallyCreateCertificateAuthorityCertificate()
public Configuration dynamicallyCreateCertificateAuthorityCertificate(Boolean dynamicallyCreateCertificateAuthorityCertificate)
Enable this property to increase the security of trusting the MockServer Certificate Authority X509 by ensuring a local dynamic value is used instead of the public value in the MockServer git repo.
These PEM files will be created and saved in the directory specified with configuration property directoryToSaveDynamicSSLCertificate.
dynamicallyCreateCertificateAuthorityCertificate
- dynamic creation of Certificate Authority X509 certificate and private key.public String directoryToSaveDynamicSSLCertificate()
public Configuration directoryToSaveDynamicSSLCertificate(String directoryToSaveDynamicSSLCertificate)
directoryToSaveDynamicSSLCertificate
- directory to save Certificate Authority X.509 Certificate and Private Keypublic Boolean preventCertificateDynamicUpdate()
public Configuration preventCertificateDynamicUpdate(Boolean preventCertificateDynamicUpdate)
preventCertificateDynamicUpdate
- prevent certificates from dynamically updating when domain list changespublic String sslCertificateDomainName()
public Configuration sslCertificateDomainName(String sslCertificateDomainName)
The default is "localhost"
sslCertificateDomainName
- domain name for auto-generate TLS certificatespublic Configuration sslSubjectAlternativeNameDomains(String... sslSubjectAlternativeNameDomains)
The default is "localhost"
sslSubjectAlternativeNameDomains
- Subject Alternative Name (SAN) domain names for auto-generate TLS certificatespublic Configuration sslSubjectAlternativeNameDomains(Set<String> sslSubjectAlternativeNameDomains)
The default is "localhost"
sslSubjectAlternativeNameDomains
- Subject Alternative Name (SAN) domain names for auto-generate TLS certificatespublic Configuration sslSubjectAlternativeNameIps(String... sslSubjectAlternativeNameIps)
The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates
The default is 127.0.0.1, 0.0.0.0
sslSubjectAlternativeNameIps
- Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificatespublic Configuration sslSubjectAlternativeNameIps(Set<String> sslSubjectAlternativeNameIps)
The Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificates
The default is 127.0.0.1, 0.0.0.0
sslSubjectAlternativeNameIps
- Subject Alternative Name (SAN) IP addresses for auto-generate TLS certificatespublic String certificateAuthorityPrivateKey()
public Configuration certificateAuthorityPrivateKey(String certificateAuthorityPrivateKey)
certificateAuthorityPrivateKey
- location of the PEM file containing the certificate authority private keypublic String certificateAuthorityCertificate()
public Configuration certificateAuthorityCertificate(String certificateAuthorityCertificate)
certificateAuthorityCertificate
- location of the PEM file containing the certificate authority X509 certificatepublic String privateKeyPath()
public Configuration privateKeyPath(String privateKeyPath)
The private key must be a PKCS#8 or PKCS#1 PEM file and must be the private key corresponding to the x509CertificatePath X509 (public key) configuration. The certificateAuthorityCertificate configuration must be the Certificate Authority for the corresponding X509 certificate (i.e. able to valid its signature), see: x509CertificatePath.
To convert a PKCS#1 (i.e. default for Bouncy Castle) to a PKCS#8 the following command can be used: openssl pkcs8 -topk8 -inform PEM -in private_key_PKCS_1.pem -out private_key_PKCS_8.pem -nocrypt
This configuration will be ignored unless x509CertificatePath is also set.
privateKeyPath
- location of the PKCS#8 PEM file containing the private keypublic String x509CertificatePath()
public Configuration x509CertificatePath(String x509CertificatePath)
The certificate must be a X509 PEM file and must be the public key corresponding to the privateKeyPath private key configuration. The certificateAuthorityCertificate configuration must be the Certificate Authority for this certificate (i.e. able to valid its signature).
This configuration will be ignored unless privateKeyPath is also set.
x509CertificatePath
- location of the PEM file containing the X509 certificatepublic Boolean tlsMutualAuthenticationRequired()
public Configuration tlsMutualAuthenticationRequired(Boolean tlsMutualAuthenticationRequired)
tlsMutualAuthenticationRequired
- TLS mutual authenticationpublic String tlsMutualAuthenticationCertificateChain()
public Configuration tlsMutualAuthenticationCertificateChain(String tlsMutualAuthenticationCertificateChain)
This certificate chain will be used if MockServer performs mTLS (client authentication) for inbound TLS connections because tlsMutualAuthenticationRequired is enabled
tlsMutualAuthenticationCertificateChain
- File system path or classpath location of custom mTLS (TLS client authentication) X.509 Certificate Chain for Trusting (i.e. signature verification of) Client X.509 Certificatespublic ForwardProxyTLSX509CertificatesTrustManager forwardProxyTLSX509CertificatesTrustManagerType()
public Configuration forwardProxyTLSX509CertificatesTrustManagerType(ForwardProxyTLSX509CertificatesTrustManager forwardProxyTLSX509CertificatesTrustManagerType)
MockServer will only be able to establish a TLS connection to endpoints that have a trusted X509 certificate according to the trust manager type, as follows:
ALL - Insecure will trust all X509 certificates and not perform host name verification. JVM - Will trust all X509 certificates trust by the JVM. CUSTOM - Will trust all X509 certificates specified in forwardProxyTLSCustomTrustX509Certificates configuration value.
forwardProxyTLSX509CertificatesTrustManagerType
- trusted set of certificates for forwarded or proxied requests, allowed values: ALL, JVM, CUSTOM.public String forwardProxyTLSCustomTrustX509Certificates()
public Configuration forwardProxyTLSCustomTrustX509Certificates(String forwardProxyTLSCustomTrustX509Certificates)
MockServer will only be able to establish a TLS connection to endpoints that have an X509 certificate chain that is signed by one of the provided custom certificates, i.e. where a path can be established from the endpoints X509 certificate to one or more of the custom X509 certificates provided.
forwardProxyTLSCustomTrustX509Certificates
- custom set of trusted X509 certificate authority roots for forwarded or proxied requests in PEM format.public String forwardProxyPrivateKey()
public Configuration forwardProxyPrivateKey(String forwardProxyPrivateKey)
To convert a PKCS#1 (i.e. default for Bouncy Castle) to a PKCS#8 the following command can be used: openssl pkcs8 -topk8 -inform PEM -in private_key_PKCS_1.pem -out private_key_PKCS_8.pem -nocrypt
This private key will be used if MockServer needs to perform mTLS (client authentication) for outbound TLS connections.
forwardProxyPrivateKey
- location of the PEM file containing the private keypublic String forwardProxyCertificateChain()
public Configuration forwardProxyCertificateChain(String forwardProxyCertificateChain)
This certificate chain will be used if MockServer needs to perform mTLS (client authentication) for outbound TLS connections.
forwardProxyCertificateChain
- location of the PEM file containing the certificate chainpublic void addSubjectAlternativeName(String host)
public void addSslSubjectAlternativeNameIps(String... additionalSubjectAlternativeNameIps)
public void clearSslSubjectAlternativeNameIps()
public void addSslSubjectAlternativeNameDomains(String... additionalSubjectAlternativeNameDomains)
public void clearSslSubjectAlternativeNameDomains()
public int ringBufferSize()
Copyright © 2022. All rights reserved.