public class IdentifiedUser extends CurrentUser
Modifier and Type | Class and 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.
|
CurrentUser.PropertyKey<T>
Modifier and Type | Method and Description |
---|---|
IdentifiedUser |
asIdentifiedUser()
Cast to IdentifiedUser if possible.
|
<T> java.util.Optional<T> |
get(CurrentUser.PropertyKey<T> key)
Lookup a previously stored property.
|
Account |
getAccount()
Returns the account of the identified user.
|
Account.Id |
getAccountId()
Return account ID if
CurrentUser.isIdentifiedUser() is true. |
java.lang.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<java.lang.String> |
getEmailAddresses() |
java.lang.String |
getLoggableName() |
java.lang.String |
getName() |
java.lang.String |
getNameEmail() |
CurrentUser |
getRealUser()
Identity of the authenticated user.
|
java.util.Optional<java.lang.String> |
getUserName()
Unique name of the user on this server, if one has been assigned.
|
boolean |
hasEmailAddress(java.lang.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 IdentifiedUser
|
boolean |
isImpersonating() |
IdentifiedUser |
materializedCopy()
Returns a materialized copy of the user with all dependencies.
|
org.eclipse.jgit.lib.PersonIdent |
newCommitterIdent(java.util.Date when,
java.util.TimeZone tz) |
org.eclipse.jgit.lib.PersonIdent |
newRefLogIdent() |
org.eclipse.jgit.lib.PersonIdent |
newRefLogIdent(java.util.Date when,
java.util.TimeZone tz) |
<T> void |
put(CurrentUser.PropertyKey<T> key,
T value)
Store a property for later retrieval.
|
AccountState |
state()
Returns the account state of the identified user.
|
java.lang.String |
toString() |
getAccessPath, getLastLoginExternalIdKey, isInternalUser, setAccessPath, setLastLoginExternalIdKey, updateRealAccountId
public CurrentUser getRealUser()
CurrentUser
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.
getRealUser
in class CurrentUser
public boolean isImpersonating()
isImpersonating
in class CurrentUser
public AccountState state()
public IdentifiedUser asIdentifiedUser()
CurrentUser
asIdentifiedUser
in class CurrentUser
public Account.Id getAccountId()
CurrentUser
CurrentUser.isIdentifiedUser()
is true.getAccountId
in class CurrentUser
public java.util.Optional<java.lang.String> getUserName()
CurrentUser
getUserName
in class CurrentUser
public java.lang.String getLoggableName()
getLoggableName
in class CurrentUser
null
public Account getAccount()
public boolean hasEmailAddress(java.lang.String email)
public com.google.common.collect.ImmutableSet<java.lang.String> getEmailAddresses()
public java.lang.String getName()
public java.lang.String getNameEmail()
public GroupMembership getEffectiveGroups()
CurrentUser
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.
getEffectiveGroups
in class CurrentUser
public java.lang.Object getCacheKey()
CurrentUser
equals()
and hashCode()
for effective caching.getCacheKey
in class CurrentUser
public org.eclipse.jgit.lib.PersonIdent newRefLogIdent()
public org.eclipse.jgit.lib.PersonIdent newRefLogIdent(java.util.Date when, java.util.TimeZone tz)
public org.eclipse.jgit.lib.PersonIdent newCommitterIdent(java.util.Date when, java.util.TimeZone tz)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isIdentifiedUser()
isIdentifiedUser
in class CurrentUser
public <T> java.util.Optional<T> get(CurrentUser.PropertyKey<T> key)
CurrentUser
get
in class CurrentUser
key
- unique property key.Optional#empty()
.public <T> void put(CurrentUser.PropertyKey<T> key, T value)
put
in class CurrentUser
key
- unique property key.value
- value to store; or null
to clear the value.public IdentifiedUser materializedCopy()
Invoke all providers and factories of dependent objects and store the references to a copy of the current identified user.
public boolean hasSameAccountId(CurrentUser other)
CurrentUser
Provide a generic interface for allowing subclasses to define whether two accounts represent the same account id.
hasSameAccountId
in class CurrentUser
other
- user to compare