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 classIdentifiedUser.GenericFactoryCreate an IdentifiedUser, ignoring any per-request state.static classIdentifiedUser.RequestFactoryCreate an IdentifiedUser, relying on current request state.-
Nested classes/interfaces inherited from class com.google.gerrit.server.CurrentUser
CurrentUser.PropertyKey<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IdentifiedUserasIdentifiedUser()Cast to IdentifiedUser if possible.<T> Optional<T>get(CurrentUser.PropertyKey<T> key)Lookup a previously stored property.AccountgetAccount()Returns the account of the identified user.Account.IdgetAccountId()Return account ID ifCurrentUser.isIdentifiedUser()is true.ObjectgetCacheKey()Returns a unique identifier for this user that is intended to be used as a cache key.GroupMembershipgetEffectiveGroups()Get the set of groups the user is currently a member of.com.google.common.collect.ImmutableSet<String>getEmailAddresses()StringgetLoggableName()StringgetName()StringgetNameEmail()CurrentUsergetRealUser()Identity of the authenticated user.Optional<String>getUserName()Unique name of the user on this server, if one has been assigned.booleanhasEmailAddress(String email)booleanhasSameAccountId(CurrentUser other)Checks if the current user has the same account id of another.booleanisIdentifiedUser()Check if user is the IdentifiedUserbooleanisImpersonating()IdentifiedUsermaterializedCopy()Returns a materialized copy of the user with all dependencies.org.eclipse.jgit.lib.PersonIdentnewCommitterIdent(Date when, TimeZone tz)org.eclipse.jgit.lib.PersonIdentnewRefLogIdent()org.eclipse.jgit.lib.PersonIdentnewRefLogIdent(Date when, TimeZone tz)<T> voidput(CurrentUser.PropertyKey<T> key, T value)Store a property for later retrieval.AccountStatestate()Returns the account state of the identified user.StringtoString()-
Methods inherited from class com.google.gerrit.server.CurrentUser
getAccessPath, getLastLoginExternalIdKey, isInternalUser, setAccessPath, setLastLoginExternalIdKey, updateRealAccountId
-
-
-
-
Method Detail
-
getRealUser
public CurrentUser getRealUser()
Description copied from class:CurrentUserIdentity 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.- Overrides:
getRealUserin classCurrentUser
-
isImpersonating
public boolean isImpersonating()
- Overrides:
isImpersonatingin 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:CurrentUserCast to IdentifiedUser if possible.- Overrides:
asIdentifiedUserin classCurrentUser
-
getAccountId
public Account.Id getAccountId()
Description copied from class:CurrentUserReturn account ID ifCurrentUser.isIdentifiedUser()is true.- Overrides:
getAccountIdin classCurrentUser
-
getUserName
public Optional<String> getUserName()
Description copied from class:CurrentUserUnique name of the user on this server, if one has been assigned.- Overrides:
getUserNamein classCurrentUser- Returns:
- the user's user name; null if one has not been selected/assigned or if the user name is empty.
-
getLoggableName
public String getLoggableName()
- Overrides:
getLoggableNamein classCurrentUser- Returns:
- unique name of the user for logging, never
null
-
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()
-
getName
public String getName()
-
getNameEmail
public String getNameEmail()
-
getEffectiveGroups
public GroupMembership getEffectiveGroups()
Description copied from class:CurrentUserGet 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:
getEffectiveGroupsin classCurrentUser- Returns:
- active groups for this user.
-
getCacheKey
public Object getCacheKey()
Description copied from class:CurrentUserReturns 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:
getCacheKeyin classCurrentUser
-
newRefLogIdent
public org.eclipse.jgit.lib.PersonIdent newRefLogIdent()
-
newCommitterIdent
public org.eclipse.jgit.lib.PersonIdent newCommitterIdent(Date when, TimeZone tz)
-
isIdentifiedUser
public boolean isIdentifiedUser()
Check if user is the IdentifiedUser- Overrides:
isIdentifiedUserin classCurrentUser
-
get
public <T> Optional<T> get(CurrentUser.PropertyKey<T> key)
Description copied from class:CurrentUserLookup a previously stored property.- Overrides:
getin classCurrentUser- Parameters:
key- unique property key.- Returns:
- previously stored value, or
Optional#empty().
-
put
public <T> void put(CurrentUser.PropertyKey<T> key, T value)
Store a property for later retrieval.- Overrides:
putin classCurrentUser- Parameters:
key- unique property key.value- value to store; ornullto clear the value.
-
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:CurrentUserChecks 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:
hasSameAccountIdin classCurrentUser- Parameters:
other- user to compare- Returns:
- true if the two users have the same account id
-
-