- java.lang.Object
-
- io.javalin.community.ssl.SSLPlugin
-
- All Implemented Interfaces:
io.javalin.plugin.Plugin
public class SSLPlugin extends java.lang.Object implements io.javalin.plugin.PluginA plugin to easily enable SSL on a Javalin server.The intended configuration pattern is to use the
SSLPlugin(Consumer)constructor to configure the plugin, either though a lambda or a Consumer. This allows for a more fluent configuration pattern.Hot reloading of the SSL certificates is supported. This means that the plugin will replace the SSL certificates without restarting the server, allowing for a seamless transition. This is done by using the
reload(Consumer)method.- See Also:
SSLConfig
-
-
Constructor Summary
Constructors Constructor Description SSLPlugin()Creates a new SSLPlugin with the default configuration.SSLPlugin(SSLConfig config)Creates a new SSLPlugin with the given configuration.SSLPlugin(java.util.function.Consumer<SSLConfig> config)Creates a new SSLPlugin with the given configuration lambda/supplier.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidapply(@NotNull io.javalin.Javalin javalin)Method to apply the plugin to a Javalin instancevoidpatch(@NotNull org.eclipse.jetty.server.Server server)Method to apply the SSLConfig to a given Jetty Server.voidreload(SSLConfig newConfig)Deprecated, for removal: This API element is subject to removal in a future version.Usereload(Consumer)instead.voidreload(java.util.function.Consumer<SSLConfig> newConfig)Method to hot-swap the certificate and key material of the plugin.
-
-
-
Constructor Detail
-
SSLPlugin
public SSLPlugin()
Creates a new SSLPlugin with the default configuration.
-
SSLPlugin
public SSLPlugin(SSLConfig config)
Creates a new SSLPlugin with the given configuration.- Parameters:
config- The configuration to use.
-
SSLPlugin
public SSLPlugin(java.util.function.Consumer<SSLConfig> config)
Creates a new SSLPlugin with the given configuration lambda/supplier. This is useful if you want to use the default configuration and only change a few values. Recommended way to create a new SSLPlugin with the given configuration.- Parameters:
config- The configuration to use.
-
-
Method Detail
-
apply
public void apply(@NotNull @NotNull io.javalin.Javalin javalin)Method to apply the plugin to a Javalin instance- Specified by:
applyin interfaceio.javalin.plugin.Plugin- Parameters:
javalin- Javalin instance
-
patch
public void patch(@NotNull @NotNull org.eclipse.jetty.server.Server server)Method to apply the SSLConfig to a given Jetty Server. Can be used to patch pre-existing or custom servers.- Parameters:
server- The Jetty Server to patch.
-
reload
@Deprecated(forRemoval=true, since="5.3.2") public void reload(SSLConfig newConfig)Deprecated, for removal: This API element is subject to removal in a future version.Usereload(Consumer)instead.Method to hot-swap the certificate and key material of the plugin. Any configuration changes will be ignored, only the certificate and key material will be updated.- Parameters:
newConfig- A config containing the new certificate and key material.
-
reload
public void reload(java.util.function.Consumer<SSLConfig> newConfig)
Method to hot-swap the certificate and key material of the plugin. Any configuration changes will be ignored, only the certificate and key material will be updated.- Parameters:
newConfig- A consumer providing the new certificate and key material.
-
-