Package com.google.gerrit.server
Class CurrentUser
- java.lang.Object
- 
- com.google.gerrit.server.CurrentUser
 
- 
- Direct Known Subclasses:
- AnonymousUser,- ExternalUser,- GroupBackedUser,- IdentifiedUser,- InternalUser,- PeerDaemonUser
 
 public abstract class CurrentUser extends Object Information about the currently logged in user.This is a RequestScopedproperty managed by Guice.- See Also:
- AnonymousUser,- IdentifiedUser
 
- 
- 
Field SummaryFields Modifier and Type Field Description static PropertyMap.Key<ExternalId.Key>LAST_LOGIN_EXTERNAL_ID_PROPERTY_KEY
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedCurrentUser()protectedCurrentUser(PropertyMap properties)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description IdentifiedUserasIdentifiedUser()Cast to IdentifiedUser if possible.<T> Optional<T>get(PropertyMap.Key<T> key)Lookup a stored property.AccessPathgetAccessPath()How this user is accessing the Gerrit Code Review application.Account.IdgetAccountId()Return account ID ifisIdentifiedUser()is true.abstract ObjectgetCacheKey()Returns a unique identifier for this user that is intended to be used as a cache key.abstract GroupMembershipgetEffectiveGroups()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.Keys associated with this user.Optional<ExternalId.Key>getLastLoginExternalIdKey()StringgetLoggableName()Returns unique name of the user for logging, nevernullCurrentUsergetRealUser()Identity of the authenticated user.Optional<String>getUserName()Unique name of the user on this server, if one has been assigned.booleanhasSameAccountId(CurrentUser other)Checks if the current user has the same account id of another.booleanisIdentifiedUser()Check if user is the IdentifiedUserbooleanisImpersonating()booleanisInternalUser()Check if the CurrentUser is an InternalUser.voidsetAccessPath(AccessPath path)voidupdateRealAccountId(Consumer<Account.Id> setter)If thegetRealUser()has an account ID associated with it, call the given setter with that ID.
 
- 
- 
- 
Field Detail- 
LAST_LOGIN_EXTERNAL_ID_PROPERTY_KEYpublic static final PropertyMap.Key<ExternalId.Key> LAST_LOGIN_EXTERNAL_ID_PROPERTY_KEY 
 
- 
 - 
Constructor Detail- 
CurrentUserprotected CurrentUser() 
 - 
CurrentUserprotected CurrentUser(PropertyMap properties) 
 
- 
 - 
Method Detail- 
getAccessPathpublic final AccessPath getAccessPath() How this user is accessing the Gerrit Code Review application.
 - 
setAccessPathpublic void setAccessPath(AccessPath path) 
 - 
getRealUserpublic CurrentUser getRealUser() Identity of the authenticated user.In the normal case where a user authenticates as themselves getRealUser() == this.If X-Gerrit-RunAsorsuexecwas used this method returns the identity of the account that has permission to act on behalf of this user.
 - 
isImpersonatingpublic boolean isImpersonating() 
 - 
updateRealAccountIdpublic void updateRealAccountId(Consumer<Account.Id> setter) If thegetRealUser()has an account ID associated with it, call the given setter with that ID.
 - 
getEffectiveGroupspublic abstract GroupMembership getEffectiveGroups() 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. - Returns:
- active groups for this user.
 
 - 
getCacheKeypublic abstract Object getCacheKey() 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.
 - 
getUserNamepublic Optional<String> getUserName() Unique name of the user on this server, if one has been assigned.
 - 
getLoggableNamepublic String getLoggableName() Returns unique name of the user for logging, nevernull
 - 
isIdentifiedUserpublic boolean isIdentifiedUser() Check if user is the IdentifiedUser
 - 
asIdentifiedUserpublic IdentifiedUser asIdentifiedUser() Cast to IdentifiedUser if possible.
 - 
getAccountIdpublic Account.Id getAccountId() Return account ID ifisIdentifiedUser()is true.- Throws:
- UnsupportedOperationException- if the user is not logged in.
 
 - 
getEmailAddressespublic com.google.common.collect.ImmutableSet<String> getEmailAddresses() Returns all email addresses associated with this user. ForAnonymousUserand other users that don't represent a person user or service account, this set will be empty.
 - 
getExternalIdKeyspublic com.google.common.collect.ImmutableSet<ExternalId.Key> getExternalIdKeys() Returns allExternalId.Keys associated with this user. ForAnonymousUserand other users that don't represent a person user or service account, this set will be empty.
 - 
isInternalUserpublic boolean isInternalUser() Check if the CurrentUser is an InternalUser.
 - 
getpublic <T> Optional<T> get(PropertyMap.Key<T> key) Lookup a stored property.- Parameters:
- key- unique property key. This key has to be the same instance that was used to store the value when constructing the- PropertyMap
- Returns:
- stored value, or Optional#empty().
 
 - 
getLastLoginExternalIdKeypublic Optional<ExternalId.Key> getLastLoginExternalIdKey() 
 - 
hasSameAccountIdpublic boolean hasSameAccountId(CurrentUser other) 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. - Parameters:
- other- user to compare
- Returns:
- true if the two users have the same account id
 
 
- 
 
-