diff --git a/briar-api/src/org/briarproject/api/DeviceId.java b/briar-api/src/org/briarproject/api/DeviceId.java deleted file mode 100644 index e6501f41c5cd5b1a6dc3243621e83726fc3d926d..0000000000000000000000000000000000000000 --- a/briar-api/src/org/briarproject/api/DeviceId.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.briarproject.api; - -/** - * Type-safe wrapper for a byte array that uniquely identifies a device. - */ -public class DeviceId extends UniqueId { - - public DeviceId(byte[] id) { - super(id); - } - - @Override - public boolean equals(Object o) { - return o instanceof DeviceId && super.equals(o); - } -} diff --git a/briar-api/src/org/briarproject/api/db/DatabaseComponent.java b/briar-api/src/org/briarproject/api/db/DatabaseComponent.java index 96ec6f17d38387157db5ee39c382912375485e5b..d2a0b28210ceef4bfa445baa0813fb407ff5d032 100644 --- a/briar-api/src/org/briarproject/api/db/DatabaseComponent.java +++ b/briar-api/src/org/briarproject/api/db/DatabaseComponent.java @@ -1,6 +1,5 @@ package org.briarproject.api.db; -import org.briarproject.api.DeviceId; import org.briarproject.api.TransportId; import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.ContactId; @@ -205,13 +204,6 @@ public interface DatabaseComponent { Collection<ContactId> getContacts(Transaction txn, AuthorId a) throws DbException; - /** - * Returns the unique ID for this device. - * <p/> - * Read-only. - */ - DeviceId getDeviceId(Transaction txn) throws DbException; - /** * Returns the group with the given ID. * <p/> diff --git a/briar-core/src/org/briarproject/db/Database.java b/briar-core/src/org/briarproject/db/Database.java index 1eb5c484d5045dcdbafb96808f52d4eb0bac9c81..0d2327200d39888bfe6dbbaf1bbb4755c2ce6022 100644 --- a/briar-core/src/org/briarproject/db/Database.java +++ b/briar-core/src/org/briarproject/db/Database.java @@ -1,6 +1,5 @@ package org.briarproject.db; -import org.briarproject.api.DeviceId; import org.briarproject.api.TransportId; import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.ContactId; @@ -227,13 +226,6 @@ interface Database<T> { */ Collection<ContactId> getContacts(T txn, AuthorId a) throws DbException; - /** - * Returns the unique ID for this device. - * <p/> - * Read-only. - */ - DeviceId getDeviceId(T txn) throws DbException; - /** * Returns the amount of free storage space available to the database, in * bytes. This is based on the minimum of the space available on the device diff --git a/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java b/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java index bac6f84ad019e6d3673d3c97f9efdf153a6a4466..e09ed8f2c4064481cd37daf7b25d62b03458cb19 100644 --- a/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java +++ b/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java @@ -1,6 +1,5 @@ package org.briarproject.db; -import org.briarproject.api.DeviceId; import org.briarproject.api.TransportId; import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.ContactId; @@ -414,12 +413,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent { return db.getContacts(txn, a); } - @Override - public DeviceId getDeviceId(Transaction transaction) throws DbException { - T txn = unbox(transaction); - return db.getDeviceId(txn); - } - @Override public Group getGroup(Transaction transaction, GroupId g) throws DbException { diff --git a/briar-core/src/org/briarproject/db/DatabaseConstants.java b/briar-core/src/org/briarproject/db/DatabaseConstants.java index ddeb138dbc70585921a8a23b2f172bdbea535eba..68e3ca1ef393c7c203e040ec7fc1d14d31ed52ca 100644 --- a/briar-core/src/org/briarproject/db/DatabaseConstants.java +++ b/briar-core/src/org/briarproject/db/DatabaseConstants.java @@ -29,15 +29,4 @@ interface DatabaseConstants { */ String MIN_SCHEMA_VERSION_KEY = "minSchemaVersion"; - /** - * The namespace of the {@link Settings Settings} - * where the unique device ID is stored. - */ - String DEVICE_SETTINGS_NAMESPACE = "device"; - - /** - * The {@link Settings Settings} key under which the - * unique device ID is stored. - */ - String DEVICE_ID_KEY = "deviceId"; } diff --git a/briar-core/src/org/briarproject/db/DatabaseModule.java b/briar-core/src/org/briarproject/db/DatabaseModule.java index d7a4b123eda653da54ecf781813087a9fb9ef1e8..39b1e49dbe9e5f3d0790cb737de857c0983bff0c 100644 --- a/briar-core/src/org/briarproject/db/DatabaseModule.java +++ b/briar-core/src/org/briarproject/db/DatabaseModule.java @@ -6,7 +6,6 @@ import org.briarproject.api.event.EventBus; import org.briarproject.api.lifecycle.ShutdownManager; import org.briarproject.api.system.Clock; -import java.security.SecureRandom; import java.sql.Connection; import javax.inject.Singleton; @@ -19,9 +18,8 @@ public class DatabaseModule { @Provides @Singleton - Database<Connection> provideDatabase(DatabaseConfig config, - SecureRandom random, Clock clock) { - return new H2Database(config, random, clock); + Database<Connection> provideDatabase(DatabaseConfig config, Clock clock) { + return new H2Database(config, clock); } @Provides diff --git a/briar-core/src/org/briarproject/db/H2Database.java b/briar-core/src/org/briarproject/db/H2Database.java index 5c062120d419cb850bb3b89598db1a0624ae535a..27099f15ba048d6a993cdca4478ebf06bbddc5e2 100644 --- a/briar-core/src/org/briarproject/db/H2Database.java +++ b/briar-core/src/org/briarproject/db/H2Database.java @@ -6,7 +6,6 @@ import org.briarproject.api.system.Clock; import org.briarproject.util.StringUtils; import java.io.File; -import java.security.SecureRandom; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -26,8 +25,8 @@ class H2Database extends JdbcDatabase { private final String url; @Inject - H2Database(DatabaseConfig config, SecureRandom random, Clock clock) { - super(HASH_TYPE, BINARY_TYPE, COUNTER_TYPE, SECRET_TYPE, random, clock); + H2Database(DatabaseConfig config, Clock clock) { + super(HASH_TYPE, BINARY_TYPE, COUNTER_TYPE, SECRET_TYPE, clock); this.config = config; File dir = config.getDatabaseDirectory(); String path = new File(dir, "db").getAbsolutePath(); diff --git a/briar-core/src/org/briarproject/db/JdbcDatabase.java b/briar-core/src/org/briarproject/db/JdbcDatabase.java index cce35cacad8b07d966f0246ef8cef5bd285337be..4131ec9f4e8564e5fd6d2bc7a27cbebbbea1b596 100644 --- a/briar-core/src/org/briarproject/db/JdbcDatabase.java +++ b/briar-core/src/org/briarproject/db/JdbcDatabase.java @@ -1,8 +1,6 @@ package org.briarproject.db; -import org.briarproject.api.DeviceId; import org.briarproject.api.TransportId; -import org.briarproject.api.UniqueId; import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.ContactId; import org.briarproject.api.crypto.SecretKey; @@ -25,10 +23,8 @@ import org.briarproject.api.system.Clock; import org.briarproject.api.transport.IncomingKeys; import org.briarproject.api.transport.OutgoingKeys; import org.briarproject.api.transport.TransportKeys; -import org.briarproject.util.StringUtils; import org.jetbrains.annotations.Nullable; -import java.security.SecureRandom; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -59,8 +55,6 @@ import static org.briarproject.api.sync.ValidationManager.State.INVALID; import static org.briarproject.api.sync.ValidationManager.State.PENDING; import static org.briarproject.api.sync.ValidationManager.State.UNKNOWN; import static org.briarproject.db.DatabaseConstants.DB_SETTINGS_NAMESPACE; -import static org.briarproject.db.DatabaseConstants.DEVICE_ID_KEY; -import static org.briarproject.db.DatabaseConstants.DEVICE_SETTINGS_NAMESPACE; import static org.briarproject.db.DatabaseConstants.MIN_SCHEMA_VERSION_KEY; import static org.briarproject.db.DatabaseConstants.SCHEMA_VERSION_KEY; import static org.briarproject.db.ExponentialBackoff.calculateExpiry; @@ -240,7 +234,6 @@ abstract class JdbcDatabase implements Database<Connection> { // Different database libraries use different names for certain types private final String hashType, binaryType, counterType, secretType; - private final SecureRandom random; private final Clock clock; private final LinkedList<Connection> connections = @@ -255,12 +248,11 @@ abstract class JdbcDatabase implements Database<Connection> { private final Condition connectionsChanged = connectionsLock.newCondition(); JdbcDatabase(String hashType, String binaryType, String counterType, - String secretType, SecureRandom random, Clock clock) { + String secretType, Clock clock) { this.hashType = hashType; this.binaryType = binaryType; this.counterType = counterType; this.secretType = secretType; - this.random = random; this.clock = clock; } @@ -279,7 +271,6 @@ abstract class JdbcDatabase implements Database<Connection> { } else { createTables(txn); storeSchemaVersion(txn); - storeDeviceId(txn); } commitTransaction(txn); } catch (DbException e) { @@ -304,14 +295,6 @@ abstract class JdbcDatabase implements Database<Connection> { mergeSettings(txn, s, DB_SETTINGS_NAMESPACE); } - private void storeDeviceId(Connection txn) throws DbException { - byte[] deviceId = new byte[UniqueId.LENGTH]; - random.nextBytes(deviceId); - Settings s = new Settings(); - s.put(DEVICE_ID_KEY, StringUtils.toHexString(deviceId)); - mergeSettings(txn, s, DEVICE_SETTINGS_NAMESPACE); - } - private void tryToClose(ResultSet rs) { try { if (rs != null) rs.close(); @@ -463,12 +446,6 @@ abstract class JdbcDatabase implements Database<Connection> { if (interrupted) Thread.currentThread().interrupt(); } - @Override - public DeviceId getDeviceId(Connection txn) throws DbException { - Settings s = getSettings(txn, DEVICE_SETTINGS_NAMESPACE); - return new DeviceId(StringUtils.fromHexString(s.get(DEVICE_ID_KEY))); - } - @Override public ContactId addContact(Connection txn, Author remote, AuthorId local, boolean verified, boolean active) throws DbException { diff --git a/briar-tests/src/org/briarproject/db/H2DatabaseTest.java b/briar-tests/src/org/briarproject/db/H2DatabaseTest.java index 0b092c3d9a494abe0ebcac3003e71bcd230c3623..5f1270265b169ea0cd9bd36299cf6ae905537839 100644 --- a/briar-tests/src/org/briarproject/db/H2DatabaseTest.java +++ b/briar-tests/src/org/briarproject/db/H2DatabaseTest.java @@ -1658,7 +1658,7 @@ public class H2DatabaseTest extends BriarTestCase { private Database<Connection> open(boolean resume) throws Exception { Database<Connection> db = new H2Database(new TestDatabaseConfig(testDir, - MAX_SIZE), new SecureRandom(), new SystemClock()); + MAX_SIZE), new SystemClock()); if (!resume) TestUtils.deleteTestDirectory(testDir); db.open(); return db;