mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Create AccountManager to encapsulate authentication and account logic
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package org.briarproject.bramble.api.account;
|
||||
|
||||
import org.briarproject.bramble.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface AccountManager {
|
||||
|
||||
@CryptoExecutor
|
||||
void createAccount(String name, String password);
|
||||
|
||||
AccountState getAccountState();
|
||||
|
||||
/**
|
||||
* Returns the name of the {@link LocalAuthor} if it was just created and
|
||||
* null otherwise.
|
||||
*
|
||||
* See {@link IdentityManager#getLocalAuthor()} for reliable retrieval.
|
||||
*/
|
||||
@Nullable
|
||||
String getCreatedLocalAuthorName();
|
||||
|
||||
/**
|
||||
* Validates the account password and returns true if it was valid.
|
||||
*/
|
||||
boolean validatePassword(String password);
|
||||
|
||||
/**
|
||||
* Changes the password and returns true if successful, false otherwise.
|
||||
*/
|
||||
@CryptoExecutor
|
||||
boolean changePassword(String password, String newPassword);
|
||||
|
||||
void deleteAccount();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.briarproject.bramble.api.account;
|
||||
|
||||
public enum AccountState {
|
||||
|
||||
NO_ACCOUNT,
|
||||
CREATING_ACCOUNT,
|
||||
SIGNING_IN,
|
||||
SIGNED_IN,
|
||||
SIGNING_OUT,
|
||||
SIGNED_OUT
|
||||
|
||||
}
|
||||
@@ -21,10 +21,5 @@ public interface DatabaseConfig {
|
||||
@Nullable
|
||||
SecretKey getEncryptionKey();
|
||||
|
||||
void setLocalAuthorName(String nickname);
|
||||
|
||||
@Nullable
|
||||
String getLocalAuthorName();
|
||||
|
||||
long getMaxSize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user