mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Nickname is all one word.
This commit is contained in:
@@ -77,7 +77,7 @@ public class AppModule {
|
||||
return new DatabaseConfig() {
|
||||
|
||||
private volatile SecretKey key = null;
|
||||
private volatile String nickName;
|
||||
private volatile String nickname;
|
||||
|
||||
@Override
|
||||
public boolean databaseExists() {
|
||||
@@ -97,13 +97,13 @@ public class AppModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthorNick(String nickName) {
|
||||
this.nickName = nickName;
|
||||
public void setAuthorNick(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorNick() {
|
||||
return nickName;
|
||||
return nickname;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,8 +93,8 @@ public class BriarService extends Service {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
StartResult result = lifecycleManager
|
||||
.startServices(databaseConfig.getAuthorNick());
|
||||
String nickname = databaseConfig.getAuthorNick();
|
||||
StartResult result = lifecycleManager.startServices(nickname);
|
||||
if (result == SUCCESS) {
|
||||
started = true;
|
||||
} else if (result == ALREADY_RUNNING) {
|
||||
|
||||
@@ -135,7 +135,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
String nickname = nicknameEntry.getText().toString();
|
||||
String password = passwordEntry.getText().toString();
|
||||
|
||||
setupController.storeAuthorInfo(password, nickname,
|
||||
setupController.storeAuthorInfo(nickname, password,
|
||||
new UiResultHandler<Void>(this) {
|
||||
@Override
|
||||
public void onResultUi(Void result) {
|
||||
|
||||
@@ -6,7 +6,7 @@ public interface SetupController {
|
||||
|
||||
float estimatePasswordStrength(String password);
|
||||
|
||||
void storeAuthorInfo(String password, String nickname,
|
||||
void storeAuthorInfo(String nickname, String password,
|
||||
ResultHandler<Void> resultHandler);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,16 +10,12 @@ import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SetupControllerImpl extends PasswordControllerImpl
|
||||
implements SetupController {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SetupControllerImpl.class.getName());
|
||||
|
||||
private final PasswordStrengthEstimator strengthEstimator;
|
||||
|
||||
@Inject
|
||||
@@ -37,16 +33,16 @@ public class SetupControllerImpl extends PasswordControllerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeAuthorInfo(final String password, final String nickname,
|
||||
public void storeAuthorInfo(final String nickname, final String password,
|
||||
final ResultHandler<Void> resultHandler) {
|
||||
cryptoExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
databaseConfig.setAuthorNick(nickname);
|
||||
SecretKey key = crypto.generateSecretKey();
|
||||
databaseConfig.setEncryptionKey(key);
|
||||
String hex = encryptDatabaseKey(key, password);
|
||||
storeEncryptedDatabaseKey(hex);
|
||||
databaseConfig.setAuthorNick(nickname);
|
||||
resultHandler.onResult(null);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -52,7 +52,6 @@ public class SetupActivityTest {
|
||||
|
||||
private TestSetupActivity setupActivity;
|
||||
private TextInputLayout nicknameEntryWrapper;
|
||||
private TextInputLayout passwordEntryWrapper;
|
||||
private TextInputLayout passwordConfirmationWrapper;
|
||||
private EditText nicknameEntry;
|
||||
private EditText passwordEntry;
|
||||
@@ -71,8 +70,6 @@ public class SetupActivityTest {
|
||||
setupActivity = Robolectric.setupActivity(TestSetupActivity.class);
|
||||
nicknameEntryWrapper = (TextInputLayout) setupActivity
|
||||
.findViewById(R.id.nickname_entry_wrapper);
|
||||
passwordEntryWrapper = (TextInputLayout) setupActivity
|
||||
.findViewById(R.id.password_entry_wrapper);
|
||||
passwordConfirmationWrapper = (TextInputLayout) setupActivity
|
||||
.findViewById(R.id.password_confirm_wrapper);
|
||||
nicknameEntry =
|
||||
@@ -130,7 +127,7 @@ public class SetupActivityTest {
|
||||
// Verify that the controller's method was called with the correct
|
||||
// params and get the callback
|
||||
verify(mockedController, times(1))
|
||||
.storeAuthorInfo(eq(safePass), eq(nick),
|
||||
.storeAuthorInfo(eq(nick), eq(safePass),
|
||||
authorCaptor.capture());
|
||||
authorCaptor.getValue().onResult(null);
|
||||
// execute the callback
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface DatabaseConfig {
|
||||
|
||||
SecretKey getEncryptionKey();
|
||||
|
||||
void setAuthorNick(String nickName);
|
||||
void setAuthorNick(String nickname);
|
||||
|
||||
String getAuthorNick();
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ public interface LifecycleManager {
|
||||
|
||||
/**
|
||||
* Opens the {@link org.briarproject.api.db.DatabaseComponent
|
||||
* DatabaseComponent}, creates a local author with the provided nick, and
|
||||
* starts any registered {@link org.briarproject.api.clients.Client Clients}
|
||||
* and {@link Service Services}.
|
||||
* DatabaseComponent}, creates a local author with the provided nickname,
|
||||
* and starts any registered {@link org.briarproject.api.clients.Client
|
||||
* Clients} and {@link Service Services}.
|
||||
*/
|
||||
StartResult startServices(@Nullable String authorNick);
|
||||
StartResult startServices(@Nullable String nickname);
|
||||
|
||||
/**
|
||||
* Stops any registered {@link Service Services}, shuts down any
|
||||
|
||||
@@ -25,7 +25,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(IdentityManagerImpl.class.getName());
|
||||
|
||||
// Make sure that this variable is immutable
|
||||
// The local author is immutable so we can cache it
|
||||
private volatile LocalAuthor cachedAuthor;
|
||||
|
||||
@Inject
|
||||
@@ -40,7 +40,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
txn.setComplete();
|
||||
cachedAuthor = localAuthor;
|
||||
LOG.info("Local Author created");
|
||||
LOG.info("Local author registered");
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
cachedAuthor = loadLocalAuthor(txn);
|
||||
LOG.info("Author loaded from db");
|
||||
LOG.info("Local author loaded");
|
||||
txn.setComplete();
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
@@ -66,6 +66,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
public LocalAuthor getLocalAuthor(Transaction txn) throws DbException {
|
||||
if (cachedAuthor == null) {
|
||||
cachedAuthor = loadLocalAuthor(txn);
|
||||
LOG.info("Local author loaded");
|
||||
}
|
||||
return cachedAuthor;
|
||||
}
|
||||
@@ -87,10 +88,7 @@ class IdentityManagerImpl implements IdentityManager {
|
||||
@Override
|
||||
public Status getAuthorStatus(Transaction txn, AuthorId authorId)
|
||||
throws DbException {
|
||||
|
||||
// Compare to the IDs of the user's identity
|
||||
if (getLocalAuthor(txn).getId().equals(authorId)) return OURSELVES;
|
||||
|
||||
Collection<Contact> contacts = db.getContactsByAuthorId(txn, authorId);
|
||||
if (contacts.isEmpty()) return UNKNOWN;
|
||||
for (Contact c : contacts) {
|
||||
|
||||
@@ -305,8 +305,7 @@ class IntroduceeManager {
|
||||
boolean alice = comp < 0;
|
||||
|
||||
// get our local author
|
||||
LocalAuthor author =
|
||||
identityManager.getLocalAuthor(txn);
|
||||
LocalAuthor author = identityManager.getLocalAuthor(txn);
|
||||
|
||||
SecretKey secretKey;
|
||||
byte[] privateKeyBytes = localState.getRaw(OUR_PRIVATE_KEY);
|
||||
|
||||
@@ -93,7 +93,7 @@ class LifecycleManagerImpl implements LifecycleManager {
|
||||
.createLocalAuthor(nickname, publicKey, privateKey);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Identity creation took " + duration + " ms");
|
||||
LOG.info("Creating local author took " + duration + " ms");
|
||||
return localAuthor;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,11 @@ class LifecycleManagerImpl implements LifecycleManager {
|
||||
identityManager.registerLocalAuthor(author);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Author registration took " + duration +
|
||||
" ms");
|
||||
LOG.info("Registering local author took " + duration + " ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartResult startServices(@Nullable String authorNick) {
|
||||
public StartResult startServices(@Nullable String nickname) {
|
||||
if (!startStopSemaphore.tryAcquire()) {
|
||||
LOG.info("Already starting or stopping");
|
||||
return ALREADY_RUNNING;
|
||||
@@ -124,8 +123,8 @@ class LifecycleManagerImpl implements LifecycleManager {
|
||||
else LOG.info("Creating database took " + duration + " ms");
|
||||
}
|
||||
|
||||
if (authorNick != null) {
|
||||
registerLocalAuthor(createLocalAuthor(authorNick));
|
||||
if (nickname != null) {
|
||||
registerLocalAuthor(createLocalAuthor(nickname));
|
||||
}
|
||||
|
||||
dbLatch.countDown();
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TestDatabaseConfig implements DatabaseConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthorNick(String nickName) {
|
||||
public void setAuthorNick(String nickname) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TestLifecycleModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartResult startServices(String authorNick) {
|
||||
public StartResult startServices(String nickname) {
|
||||
return StartResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user