|
|
@ -51,22 +51,22 @@ public class Application { |
|
|
|
private static ConnectionProvider connectionProvider = new ConnectionProvider(); |
|
|
|
private static ConnectionProvider connectionProvider = new ConnectionProvider(); |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception { |
|
|
|
public static void main(String[] args) throws Exception { |
|
|
|
var argMap = map(args); |
|
|
|
var argMap = map(args); |
|
|
|
Optional<Path> basePath = argMap.get(BASE_PATH) instanceof Path p ? Optional.of(p) : empty(); |
|
|
|
Optional<Path> basePath = argMap.get(BASE_PATH) instanceof Path p ? Optional.of(p) : empty(); |
|
|
|
var configFile = (argMap.get(CONFIG_PATH) instanceof Path p ? p : configDir(APP_NAME).resolve("config.json")).toFile(); |
|
|
|
var configDir = configDir(APP_NAME); |
|
|
|
var config = new Configuration(configFile); |
|
|
|
var defaultFile = configDir.resolve("data.json"); |
|
|
|
var passHasher = new UuidHasher(); |
|
|
|
var configFile = (argMap.get(CONFIG_PATH) instanceof Path p ? p : configDir.resolve("config.json")).toFile(); |
|
|
|
var firstHash = passHasher.hash(FIRST_USER_PASS, FIRST_UUID); |
|
|
|
var config = new Configuration(configFile); |
|
|
|
var firstUser = new User(FIRST_USER, firstHash, FIRST_USER, "%s@internal".formatted(FIRST_USER), FIRST_UUID).add(MANAGE_CLIENTS, MANAGE_PERMISSIONS, MANAGE_SMTP, MANAGE_USERS); |
|
|
|
var passHasher = new UuidHasher(); |
|
|
|
|
|
|
|
var firstHash = passHasher.hash(FIRST_USER_PASS, FIRST_UUID); |
|
|
|
|
|
|
|
var firstUser = new User(FIRST_USER, firstHash, FIRST_USER, "%s@internal".formatted(FIRST_USER), FIRST_UUID).add(MANAGE_CLIENTS, MANAGE_PERMISSIONS, MANAGE_SMTP, MANAGE_USERS); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileStoreProvider fileStoreProvider = new FileStoreProvider(passHasher); |
|
|
|
FileStoreProvider fileStoreProvider = new FileStoreProvider(passHasher); |
|
|
|
var defaultConfigDir = configDir(APP_NAME); |
|
|
|
|
|
|
|
var defaultFile = defaultConfigDir.resolve("data.json"); |
|
|
|
|
|
|
|
var userService = setupUserService(config, defaultFile, fileStoreProvider).init(firstUser); |
|
|
|
var userService = setupUserService(config, defaultFile, fileStoreProvider).init(firstUser); |
|
|
|
var sessionService = setupSessionService(config, defaultFile, fileStoreProvider); |
|
|
|
var sessionService = setupSessionService(config, defaultFile, fileStoreProvider); |
|
|
|
var mailConfig = setupMailConfig(config, defaultFile, fileStoreProvider); |
|
|
|
var mailConfig = setupMailConfig(config, defaultFile, fileStoreProvider); |
|
|
|
var keyStore = setupKeyStore(config, defaultConfigDir); |
|
|
|
var keyStore = setupKeyStore(config, configDir); |
|
|
|
KeyManager keyManager = new RotatingKeyManager(keyStore); |
|
|
|
KeyManager keyManager = new RotatingKeyManager(keyStore); |
|
|
|
var authService = setupAuthService(config, defaultFile, fileStoreProvider); |
|
|
|
var authService = setupAuthService(config, defaultFile, fileStoreProvider); |
|
|
|
var clientService = setupClientService(config, defaultFile, fileStoreProvider); |
|
|
|
var clientService = setupClientService(config, defaultFile, fileStoreProvider); |
|
|
|