Nickname is all one word.

This commit is contained in:
akwizgran
2016-11-01 17:05:32 +00:00
parent 88272c5d61
commit c85767d2a0
13 changed files with 28 additions and 39 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -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);
}
});

View File

@@ -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

View File

@@ -14,7 +14,7 @@ public interface DatabaseConfig {
SecretKey getEncryptionKey();
void setAuthorNick(String nickName);
void setAuthorNick(String nickname);
String getAuthorNick();

View File

@@ -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

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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();

View File

@@ -39,7 +39,7 @@ public class TestDatabaseConfig implements DatabaseConfig {
}
@Override
public void setAuthorNick(String nickName) {
public void setAuthorNick(String nickname) {
}

View File

@@ -38,7 +38,7 @@ public class TestLifecycleModule {
}
@Override
public StartResult startServices(String authorNick) {
public StartResult startServices(String nickname) {
return StartResult.SUCCESS;
}