SiLAServer.Builder: Allow specifying UUID and server name without persistent config file

The server name and UUID are stored in ServerConfiguration objects. SiLAServer.Builder has a static method withConfig(Path configFile, ServerInformation serverInformation). To get a Path for a ServerConfiguration, it is required to wrap the ServerConfiguration in a new PersistentServerConfigWrapper(Path configFile, String defaultServerName).

I propose adding a static method Builder SiLAServer.Builder.withConfig(ServerConfiguration config, ServerInformation info) to allow specifying the server name and server UUID explicitly without a config file.

Why? SiLA Part B recommends to store the server UUID in the certificate. If I don't want to use a certificate auto-generated by the server (which currently does not work, see #19 (closed)), I have to provide a certificate to the server (using withPersistedTLS(Path keyFile, Path certFile, @Nullable String certPassword)). Setting up the full config file stuff requires a lot of code, just to set the server name and UUID:

final UUID serverUuid = ...;  // same UUID as in the certificate
final ServerConfiguration serverConfiguration = new ServerConfiguration("Server Name", serverUuid);

// I want to get rid of these three lines, and the generated JSON file
final Path configFilePath = Paths.get("server-config.json");
final IServerConfigWrapper configWrapper = new PersistentServerConfigWrapper(configFilePath, serverName);
configWrapper.setConfig(serverConfiguration);

// I want to have .withConfig(serverConfiguration, serverInformation)
try (SiLAServer server = SiLAServer.Builder.withConfig(configFilePath, serverInformation)
                                           .withPersistedTLS(
                                               Paths.get("key.pem")
                                               Paths.get("cert.pem"));
                                           .start()) {
            ...
        }
    }

As I a developer I want to be able to specify a server UUID with or without a persistant configuration

Edited Aug 31, 2022 by Timothy
Assignee Loading
Time tracking Loading