Package com.google.gerrit.server.account
Class AccountManager
- java.lang.Object
-
- com.google.gerrit.server.account.AccountManager
-
public class AccountManager extends Object
Tracks authentication related details for user accounts.
-
-
Constructor Summary
Constructors Constructor Description AccountManager(Sequences sequences, org.eclipse.jgit.lib.Config cfg, Accounts accounts, com.google.inject.Provider<AccountsUpdate> accountsUpdateProvider, AccountCache byIdCache, Realm accountMapper, IdentifiedUser.GenericFactory userFactory, SshKeyCache sshKeyCache, ProjectCache projectCache, ExternalIds externalIds, GroupsUpdate.Factory groupsUpdateFactory, SetInactiveFlag setInactiveFlag, ExternalIdFactory externalIdFactory, ExternalIdKeyFactory externalIdKeyFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthResult
authenticate(AuthRequest who)
Authenticate the user, potentially creating a new account if they are new.AuthResult
link(Account.Id to, AuthRequest who)
Link another authentication identity to an existing account.Optional<Account.Id>
lookup(String externalId)
Returns a user identified by this external identity stringvoid
unlink(Account.Id from, ExternalId.Key extIdKey)
Unlink an external identity from an existing account.void
unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys)
Unlink an external identities from an existing account.AuthResult
updateLink(Account.Id to, AuthRequest who)
Update the link to another unique authentication identity to an existing account.
-
-
-
Constructor Detail
-
AccountManager
@Inject public AccountManager(Sequences sequences, org.eclipse.jgit.lib.Config cfg, Accounts accounts, com.google.inject.Provider<AccountsUpdate> accountsUpdateProvider, AccountCache byIdCache, Realm accountMapper, IdentifiedUser.GenericFactory userFactory, SshKeyCache sshKeyCache, ProjectCache projectCache, ExternalIds externalIds, GroupsUpdate.Factory groupsUpdateFactory, SetInactiveFlag setInactiveFlag, ExternalIdFactory externalIdFactory, ExternalIdKeyFactory externalIdKeyFactory)
-
-
Method Detail
-
lookup
public Optional<Account.Id> lookup(String externalId) throws AccountException
Returns a user identified by this external identity string- Throws:
AccountException
-
authenticate
public AuthResult authenticate(AuthRequest who) throws AccountException, IOException
Authenticate the user, potentially creating a new account if they are new.- Parameters:
who
- identity of the user, with any details we received about them.- Returns:
- the result of authenticating the user.
- Throws:
AccountException
- the account does not exist, and cannot be created, or exists, but cannot be located, is unable to be activated or deactivated, or is inactive, or cannot be added to the admin group (only for the first account).IOException
-
link
public AuthResult link(Account.Id to, AuthRequest who) throws AccountException, IOException, org.eclipse.jgit.errors.ConfigInvalidException
Link another authentication identity to an existing account.- Parameters:
to
- account to link the identity onto.who
- the additional identity.- Returns:
- the result of linking the identity to the user.
- Throws:
AccountException
- the identity belongs to a different account, or it cannot be linked at this time.IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
updateLink
public AuthResult updateLink(Account.Id to, AuthRequest who) throws AccountException, IOException, org.eclipse.jgit.errors.ConfigInvalidException
Update the link to another unique authentication identity to an existing account.Existing external identities with the same scheme will be removed and replaced with the new one.
- Parameters:
to
- account to link the identity onto.who
- the additional identity.- Returns:
- the result of linking the identity to the user.
- Throws:
AccountException
- the identity belongs to a different account, or it cannot be linked at this time.IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
unlink
public void unlink(Account.Id from, ExternalId.Key extIdKey) throws AccountException, IOException, org.eclipse.jgit.errors.ConfigInvalidException
Unlink an external identity from an existing account.- Parameters:
from
- account to unlink the external identity fromextIdKey
- the key of the external ID that should be deleted- Throws:
AccountException
- the identity belongs to a different account, or the identity was not foundIOException
org.eclipse.jgit.errors.ConfigInvalidException
-
unlink
public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys) throws AccountException, IOException, org.eclipse.jgit.errors.ConfigInvalidException
Unlink an external identities from an existing account.- Parameters:
from
- account to unlink the external identity fromextIdKeys
- the keys of the external IDs that should be deleted- Throws:
AccountException
- any of the identity belongs to a different account, or any of the identity was not foundIOException
org.eclipse.jgit.errors.ConfigInvalidException
-
-