public abstract class CurrentUser extends Object
This is a RequestScoped
property managed by Guice.
AnonymousUser
,
IdentifiedUser
Modifier and Type | Class and Description |
---|---|
static class |
CurrentUser.PropertyKey<T>
Unique key for plugin/extension specific data on a CurrentUser.
|
Constructor and Description |
---|
CurrentUser() |
Modifier and Type | Method and Description |
---|---|
IdentifiedUser |
asIdentifiedUser()
Cast to IdentifiedUser if possible.
|
<T> T |
get(CurrentUser.PropertyKey<T> key)
Lookup a previously stored property.
|
AccessPath |
getAccessPath()
How this user is accessing the Gerrit Code Review application.
|
Account.Id |
getAccountId()
Return account ID if
isIdentifiedUser() is true. |
abstract GroupMembership |
getEffectiveGroups()
Get the set of groups the user is currently a member of.
|
ExternalId.Key |
getLastLoginExternalIdKey() |
CurrentUser |
getRealUser()
Identity of the authenticated user.
|
String |
getUserName()
Unique name of the user on this server, if one has been assigned.
|
boolean |
hasSameAccountId(CurrentUser other)
Checks if the current user has the same account id of another.
|
boolean |
isIdentifiedUser()
Check if user is the IdentifiedUser
|
boolean |
isImpersonating() |
boolean |
isInternalUser()
Check if the CurrentUser is an InternalUser.
|
<T> void |
put(CurrentUser.PropertyKey<T> key,
T value)
Store a property for later retrieval.
|
void |
setAccessPath(AccessPath path) |
void |
setLastLoginExternalIdKey(ExternalId.Key externalIdKey) |
void |
updateRealAccountId(Consumer<Account.Id> setter)
If the
getRealUser() has an account ID associated with it, call the given setter with
that ID. |
public final AccessPath getAccessPath()
public void setAccessPath(AccessPath path)
public CurrentUser getRealUser()
In the normal case where a user authenticates as themselves getRealUser() == this
.
If X-Gerrit-RunAs
or suexec
was used this method returns the identity of the
account that has permission to act on behalf of this user.
public boolean isImpersonating()
public void updateRealAccountId(Consumer<Account.Id> setter)
getRealUser()
has an account ID associated with it, call the given setter with
that ID.public abstract GroupMembership getEffectiveGroups()
The returned set may be a subset of the user's actual groups; if the user's account is currently deemed to be untrusted then the effective group set is only the anonymous and registered user groups. To enable additional groups (and gain their granted permissions) the user must update their account to use only trusted authentication providers.
public String getUserName()
public boolean isIdentifiedUser()
public IdentifiedUser asIdentifiedUser()
public Account.Id getAccountId()
isIdentifiedUser()
is true.UnsupportedOperationException
- if the user is not logged in.public boolean isInternalUser()
public <T> T get(CurrentUser.PropertyKey<T> key)
key
- unique property key.null
.public <T> void put(CurrentUser.PropertyKey<T> key, T value)
key
- unique property key.value
- value to store; or null
to clear the value.public void setLastLoginExternalIdKey(ExternalId.Key externalIdKey)
public ExternalId.Key getLastLoginExternalIdKey()
public boolean hasSameAccountId(CurrentUser other)
Provide a generic interface for allowing subclasses to define whether two accounts represent the same account id.
other
- user to compare