Class IdentifiedUser
- java.lang.Object
-
- com.google.gerrit.server.CurrentUser
-
- com.google.gerrit.server.IdentifiedUser
-
public class IdentifiedUser extends CurrentUser
An authenticated user.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IdentifiedUser.GenericFactory
Create an IdentifiedUser, ignoring any per-request state.static class
IdentifiedUser.RequestFactory
Create an IdentifiedUser, relying on current request state.
-
Field Summary
-
Fields inherited from class com.google.gerrit.server.CurrentUser
LAST_LOGIN_EXTERNAL_ID_PROPERTY_KEY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IdentifiedUser
asIdentifiedUser()
Cast to IdentifiedUser if possible.Account
getAccount()
Returns the account of the identified user.Account.Id
getAccountId()
Return account ID ifCurrentUser.isIdentifiedUser()
is true.Object
getCacheKey()
Returns a unique identifier for this user that is intended to be used as a cache key.GroupMembership
getEffectiveGroups()
Get the set of groups the user is currently a member of.com.google.common.collect.ImmutableSet<String>
getEmailAddresses()
Returns all email addresses associated with this user.com.google.common.collect.ImmutableSet<ExternalId.Key>
getExternalIdKeys()
Returns allExternalId.Key
s associated with this user.String
getLoggableName()
Returns unique name of the user for logging, nevernull
String
getName()
String
getNameEmail()
CurrentUser
getRealUser()
Identity of the authenticated user.Optional<String>
getUserName()
Returns the user's user name; null if one has not been selected/assigned or if the user name is empty.boolean
hasEmailAddress(String email)
boolean
hasSameAccountId(CurrentUser other)
Checks if the current user has the same account id of another.boolean
isIdentifiedUser()
Check if user is the IdentifiedUserboolean
isImpersonating()
IdentifiedUser
materializedCopy()
Returns a materialized copy of the user with all dependencies.org.eclipse.jgit.lib.PersonIdent
newCommitterIdent(Instant when, TimeZone tz)
org.eclipse.jgit.lib.PersonIdent
newCommitterIdent(org.eclipse.jgit.lib.PersonIdent ident)
org.eclipse.jgit.lib.PersonIdent
newRefLogIdent()
org.eclipse.jgit.lib.PersonIdent
newRefLogIdent(Instant when, TimeZone tz)
AccountState
state()
Returns the account state of the identified user.String
toString()
-
Methods inherited from class com.google.gerrit.server.CurrentUser
get, getAccessPath, getLastLoginExternalIdKey, isInternalUser, setAccessPath, updateRealAccountId
-
-
-
-
Method Detail
-
getRealUser
public CurrentUser getRealUser()
Description copied from class:CurrentUser
Identity of the authenticated user.In the normal case where a user authenticates as themselves
getRealUser() == this
.If
X-Gerrit-RunAs
orsuexec
was used this method returns the identity of the account that has permission to act on behalf of this user.- Overrides:
getRealUser
in classCurrentUser
-
isImpersonating
public boolean isImpersonating()
- Overrides:
isImpersonating
in classCurrentUser
-
state
public AccountState state()
Returns the account state of the identified user.- Returns:
- the account state of the identified user, an empty account state if the account is missing
-
asIdentifiedUser
public IdentifiedUser asIdentifiedUser()
Description copied from class:CurrentUser
Cast to IdentifiedUser if possible.- Overrides:
asIdentifiedUser
in classCurrentUser
-
getAccountId
public Account.Id getAccountId()
Description copied from class:CurrentUser
Return account ID ifCurrentUser.isIdentifiedUser()
is true.- Overrides:
getAccountId
in classCurrentUser
-
getUserName
public Optional<String> getUserName()
Returns the user's user name; null if one has not been selected/assigned or if the user name is empty.- Overrides:
getUserName
in classCurrentUser
-
getLoggableName
public String getLoggableName()
Returns unique name of the user for logging, nevernull
- Overrides:
getLoggableName
in classCurrentUser
-
getAccount
public Account getAccount()
Returns the account of the identified user.- Returns:
- the account of the identified user, an empty account if the account is missing
-
hasEmailAddress
public boolean hasEmailAddress(String email)
-
getEmailAddresses
public com.google.common.collect.ImmutableSet<String> getEmailAddresses()
Description copied from class:CurrentUser
Returns all email addresses associated with this user. ForAnonymousUser
and other users that don't represent a person user or service account, this set will be empty.- Overrides:
getEmailAddresses
in classCurrentUser
-
getExternalIdKeys
public com.google.common.collect.ImmutableSet<ExternalId.Key> getExternalIdKeys()
Description copied from class:CurrentUser
Returns allExternalId.Key
s associated with this user. ForAnonymousUser
and other users that don't represent a person user or service account, this set will be empty.- Overrides:
getExternalIdKeys
in classCurrentUser
-
getName
public String getName()
-
getNameEmail
public String getNameEmail()
-
getEffectiveGroups
public GroupMembership getEffectiveGroups()
Description copied from class:CurrentUser
Get the set of groups the user is currently a member of.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.
- Specified by:
getEffectiveGroups
in classCurrentUser
- Returns:
- active groups for this user.
-
getCacheKey
public Object getCacheKey()
Description copied from class:CurrentUser
Returns a unique identifier for this user that is intended to be used as a cache key. Returned object should to implementequals()
andhashCode()
for effective caching.- Specified by:
getCacheKey
in classCurrentUser
-
newRefLogIdent
public org.eclipse.jgit.lib.PersonIdent newRefLogIdent()
-
newCommitterIdent
public org.eclipse.jgit.lib.PersonIdent newCommitterIdent(org.eclipse.jgit.lib.PersonIdent ident)
-
newCommitterIdent
public org.eclipse.jgit.lib.PersonIdent newCommitterIdent(Instant when, TimeZone tz)
-
isIdentifiedUser
public boolean isIdentifiedUser()
Check if user is the IdentifiedUser- Overrides:
isIdentifiedUser
in classCurrentUser
-
materializedCopy
public IdentifiedUser materializedCopy()
Returns a materialized copy of the user with all dependencies.Invoke all providers and factories of dependent objects and store the references to a copy of the current identified user.
- Returns:
- copy of the identified user
-
hasSameAccountId
public boolean hasSameAccountId(CurrentUser other)
Description copied from class:CurrentUser
Checks if the current user has the same account id of another.Provide a generic interface for allowing subclasses to define whether two accounts represent the same account id.
- Overrides:
hasSameAccountId
in classCurrentUser
- Parameters:
other
- user to compare- Returns:
- true if the two users have the same account id
-
-