diff --git a/de.srsoftware.oidc.app/build.gradle.kts b/de.srsoftware.oidc.app/build.gradle.kts index 4e66135..50ef27e 100644 --- a/de.srsoftware.oidc.app/build.gradle.kts +++ b/de.srsoftware.oidc.app/build.gradle.kts @@ -7,7 +7,7 @@ plugins { dependencies{ implementation("org.json:json:20240303") implementation("de.srsoftware:tools.http:1.5.4") - implementation("de.srsoftware:tools.logging:1.2.0") + implementation("de.srsoftware:tools.logging:1.3.0") implementation("de.srsoftware:tools.optionals:1.0.0") implementation("de.srsoftware:tools.util:1.3.1") implementation(project(":de.srsoftware.oidc.api")) diff --git a/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java b/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java index f62d0b0..add24d3 100644 --- a/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java +++ b/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java @@ -9,6 +9,7 @@ import static de.srsoftware.tools.Optionals.nullable; import static de.srsoftware.tools.Paths.configDir; import static de.srsoftware.tools.Strings.uuid; import static java.lang.System.Logger.Level.ERROR; +import static java.lang.System.Logger.Level.INFO; import static java.lang.System.getenv; import static java.util.Optional.empty; @@ -51,6 +52,7 @@ public class Application { private static final System.Logger LOG = System.getLogger("Application"); // new ColorLogger("Application").setLogLevel(DEBUG); public static void main(String[] args) throws Exception { + LOG.log(INFO,"Starting LightOIDC…"); var argMap = map(args); Optional basePath = argMap.get(BASE_PATH) instanceof Path p ? Optional.of(p) : empty(); var configDir = configDir(APP_NAME); @@ -63,6 +65,8 @@ public class Application { 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); + if (encryptionKey.isPresent()) LOG.log(INFO,"Encryption key is set, using encrypted database."); + FileStoreProvider fileStoreProvider = new FileStoreProvider(passHasher); var userService = setupUserService(config, encryptionKey, defaultFile, fileStoreProvider, passHasher).init(firstUser); var sessionService = setupSessionService(config, defaultFile, fileStoreProvider); diff --git a/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Configuration.java b/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Configuration.java index f81c027..56ab9cd 100644 --- a/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Configuration.java +++ b/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Configuration.java @@ -12,10 +12,12 @@ import java.util.Optional; import org.json.JSONObject; public class Configuration { + private static final System.Logger LOG = System.getLogger(Configuration.class.getSimpleName()); private final JSONObject json; private final Path storageFile; public Configuration(File storage) throws IOException { + LOG.log(System.Logger.Level.INFO,"Using configuration from {}",storage); storageFile = storage.toPath(); if (!storage.exists()) { var parent = storage.getParentFile(); diff --git a/de.srsoftware.oidc.datastore.encrypted/src/main/java/de/srsoftware/oidc/datastore/encrypted/EncryptedUserService.java b/de.srsoftware.oidc.datastore.encrypted/src/main/java/de/srsoftware/oidc/datastore/encrypted/EncryptedUserService.java index 3bcd78f..30fa433 100644 --- a/de.srsoftware.oidc.datastore.encrypted/src/main/java/de/srsoftware/oidc/datastore/encrypted/EncryptedUserService.java +++ b/de.srsoftware.oidc.datastore.encrypted/src/main/java/de/srsoftware/oidc/datastore/encrypted/EncryptedUserService.java @@ -3,6 +3,7 @@ package de.srsoftware.oidc.datastore.encrypted; import static de.srsoftware.oidc.api.Constants.*; import static de.srsoftware.tools.result.Error.error; +import static java.lang.System.Logger.Level.INFO; import static java.lang.System.Logger.Level.WARNING; import static java.util.Optional.empty; @@ -23,6 +24,7 @@ public class EncryptedUserService extends EncryptedConfig implements UserService public EncryptedUserService(UserService backend, String key, String salt, PasswordHasher passHasher) { super(key, salt); + LOG.log(INFO,"Adding encryption layer to {0}",backend); this.backend = backend; hasher = passHasher; } diff --git a/de.srsoftware.oidc.datastore.file/src/main/java/de/srsoftware/oidc/datastore/file/FileStore.java b/de.srsoftware.oidc.datastore.file/src/main/java/de/srsoftware/oidc/datastore/file/FileStore.java index e21c480..8c6bda0 100644 --- a/de.srsoftware.oidc.datastore.file/src/main/java/de/srsoftware/oidc/datastore/file/FileStore.java +++ b/de.srsoftware.oidc.datastore.file/src/main/java/de/srsoftware/oidc/datastore/file/FileStore.java @@ -6,6 +6,7 @@ import static de.srsoftware.tools.Optionals.nullable; import static de.srsoftware.tools.Strings.uuid; import static de.srsoftware.tools.result.Error.error; import static java.lang.System.Logger.Level.*; +import static java.text.MessageFormat.format; import static java.time.temporal.ChronoUnit.SECONDS; import static java.util.Optional.empty; @@ -45,6 +46,7 @@ public class FileStore implements AuthorizationService, ClientService, SessionSe private Authenticator auth; public FileStore(File storage, PasswordHasher passwordHasher) throws IOException { + LOG.log(INFO,"Using data from {0}.",storage); this.storageFile = storage.toPath(); this.passwordHasher = passwordHasher; @@ -515,4 +517,9 @@ public class FileStore implements AuthorizationService, ClientService, SessionSe public MailConfig smtpAuth(boolean newValue) { return mailConfig(SMTP_AUTH, newValue); } + + @Override + public String toString() { + return format("{0}({1})",getClass().getSimpleName(),storageFile); + } }