implemented sqlite keystore
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -21,12 +21,14 @@ import de.srsoftware.oidc.backend.*;
|
||||
import de.srsoftware.oidc.datastore.file.FileStore;
|
||||
import de.srsoftware.oidc.datastore.file.PlaintextKeyStore;
|
||||
import de.srsoftware.oidc.datastore.file.UuidHasher;
|
||||
import de.srsoftware.oidc.datastore.sqlite.SqliteKeyStore;
|
||||
import de.srsoftware.oidc.web.Forward;
|
||||
import de.srsoftware.oidc.web.StaticPages;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.sqlite.SQLiteDataSource;
|
||||
|
||||
public class Application {
|
||||
public static final String API_CLIENT = "/api/client";
|
||||
@@ -55,10 +57,17 @@ public class Application {
|
||||
var firstHash = passwordHasher.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_SMTP, MANAGE_USERS);
|
||||
KeyStorage keyStore = new PlaintextKeyStore(keyDir);
|
||||
KeyManager keyManager = new RotatingKeyManager(keyStore);
|
||||
FileStore fileStore = new FileStore(storageFile, passwordHasher).init(firstUser);
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
|
||||
var staticPages = (StaticPages) new StaticPages(basePath).bindPath(STATIC_PATH, FAVICON).on(server);
|
||||
{ // SQLite
|
||||
SQLiteDataSource dataSource = new SQLiteDataSource();
|
||||
var dbFile = storageFile.getParentFile().toPath().resolve("db.sqlite3").toFile();
|
||||
dataSource.setUrl("jdbc:sqlite:%s".formatted(dbFile));
|
||||
var conn = dataSource.getConnection();
|
||||
keyStore = new SqliteKeyStore(conn);
|
||||
}
|
||||
KeyManager keyManager = new RotatingKeyManager(keyStore);
|
||||
FileStore fileStore = new FileStore(storageFile, passwordHasher).init(firstUser);
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
|
||||
var staticPages = (StaticPages) new StaticPages(basePath).bindPath(STATIC_PATH, FAVICON).on(server);
|
||||
new Forward(INDEX).bindPath(ROOT).on(server);
|
||||
new WellKnownController().bindPath(WELL_KNOWN).on(server);
|
||||
new UserController(fileStore, fileStore, fileStore, staticPages).bindPath(API_USER).on(server);
|
||||
|
||||
Reference in New Issue
Block a user