Skip to content
Snippets Groups Projects
Commit 79233a47 authored by akwizgran's avatar akwizgran
Browse files

Throw an exception if BriarService is (re)created without a password.

parent 371cdf0f
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import java.util.logging.Logger; ...@@ -12,6 +12,7 @@ import java.util.logging.Logger;
import net.sf.briar.R; import net.sf.briar.R;
import net.sf.briar.api.crypto.KeyManager; import net.sf.briar.api.crypto.KeyManager;
import net.sf.briar.api.db.DatabaseComponent; import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.db.DatabaseConfig;
import net.sf.briar.api.db.DbException; import net.sf.briar.api.db.DbException;
import net.sf.briar.api.plugins.PluginManager; import net.sf.briar.api.plugins.PluginManager;
import roboguice.service.RoboService; import roboguice.service.RoboService;
...@@ -34,9 +35,10 @@ public class BriarService extends RoboService { ...@@ -34,9 +35,10 @@ public class BriarService extends RoboService {
private final CountDownLatch shutdownLatch = new CountDownLatch(1); private final CountDownLatch shutdownLatch = new CountDownLatch(1);
private final Binder binder = new BriarBinder(); private final Binder binder = new BriarBinder();
@Inject private DatabaseComponent db; @Inject private DatabaseConfig databaseConfig = null;
@Inject private KeyManager keyManager; @Inject private DatabaseComponent db = null;
@Inject private PluginManager pluginManager; @Inject private KeyManager keyManager = null;
@Inject private PluginManager pluginManager = null;
@Override @Override
public void onCreate() { public void onCreate() {
...@@ -90,6 +92,8 @@ public class BriarService extends RoboService { ...@@ -90,6 +92,8 @@ public class BriarService extends RoboService {
} }
private void startServices() { private void startServices() {
if(databaseConfig.getEncryptionKey() == null)
throw new IllegalStateException();
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Starting"); if(LOG.isLoggable(INFO)) LOG.info("Starting");
boolean reopened = db.open(); boolean reopened = db.open();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment