Package org.nuxeo.ecm.core.api
Interface NuxeoPrincipal
-
- All Superinterfaces:
Principal
,Serializable
- All Known Implementing Classes:
MultiTenantPrincipal
,NuxeoPrincipalImpl
,NuxeoPrincipalImpl.TransferableClone
,SystemPrincipal
,UserPrincipal
public interface NuxeoPrincipal extends Principal, Serializable
Class to represent a principal in Nuxeo. This class holds the list of roles and groups for this principal.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PREFIX
static String
TRANSIENT_USER_FORMAT
Deprecated.since 10.3.static String
TRANSIENT_USER_PREFIX
static String
TRANSIENT_USERNAME_UNIQUE_PROP
Property that defines if a transient username should be unique no matter what base username is provided, or if a transient username should be always the same for a given base username.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static String
computeTransientUsername(String baseUsername)
Computes a transient username from the givenbaseUsername
.String
getActingUser()
Gets the acting user for this principal.List<String>
getAllGroups()
Gets the groups this principal directly or undirectly is member of.String
getCompany()
Gets the company name of this principal.static NuxeoPrincipal
getCurrent()
Returns the current logged inNuxeoPrincipal
.String
getEmail()
Get the user email if any.String
getFirstName()
Gets the first name of this principal.List<String>
getGroups()
Gets the groups this principal is directly member of.String
getLastName()
Gets the last name of this principal.DocumentModel
getModel()
String
getOriginatingUser()
Gets the base user from which this principal was created, ornull
if this principal was not created from another user.String
getPassword()
Gets the password of this principal.String
getPrincipalId()
Returns a generated id that is unique for each principal instance.List<String>
getRoles()
Gets the roles for this principal.String
getTenantId()
boolean
isAdministrator()
Returns true if the principal is an administrator.boolean
isAnonymous()
Checks if the principal is anonymous (guest user).static boolean
isCurrentAdministrator()
Checks if the current logged inNuxeoPrincipal
is an Administrator.boolean
isMemberOf(String group)
Recursively test if the user is member of this group.boolean
isTransient()
Returns true if the principal is a transient principal.static boolean
isTransientUsername(String username)
Returns true if the given @{code username} is a transient username.void
setCompany(String company)
void
setEmail(String email)
void
setFirstName(String firstName)
void
setGroups(List<String> groups)
void
setLastName(String lastName)
void
setModel(DocumentModel model)
void
setName(String name)
void
setOriginatingUser(String originatingUser)
Sets the originating user.void
setPassword(String password)
void
setPrincipalId(String principalId)
Sets the principalId.void
setRoles(List<String> roles)
-
-
-
Field Detail
-
PREFIX
static final String PREFIX
- See Also:
- Constant Field Values
-
TRANSIENT_USER_PREFIX
static final String TRANSIENT_USER_PREFIX
- Since:
- 8.1
- See Also:
- Constant Field Values
-
TRANSIENT_USER_FORMAT
@Deprecated static final String TRANSIENT_USER_FORMAT
Deprecated.since 10.3.- Since:
- 8.1
- See Also:
- Constant Field Values
-
TRANSIENT_USERNAME_UNIQUE_PROP
static final String TRANSIENT_USERNAME_UNIQUE_PROP
Property that defines if a transient username should be unique no matter what base username is provided, or if a transient username should be always the same for a given base username.- Since:
- 10.3
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFirstName
String getFirstName()
Gets the first name of this principal.- Returns:
- the first name of this principal
-
getLastName
String getLastName()
Gets the last name of this principal.- Returns:
- the last name of this principal
-
getPassword
String getPassword()
Gets the password of this principal.Note: Some APIs that return principals from the database intentionally do not fill this field
- Returns:
- the password of this principal
-
getCompany
String getCompany()
Gets the company name of this principal.- Returns:
- the company name
-
getEmail
String getEmail()
Get the user email if any. Return null if not email was specified- Returns:
- the user email or null if none
-
getGroups
List<String> getGroups()
Gets the groups this principal is directly member of.- Returns:
- the list of the groups
-
getAllGroups
List<String> getAllGroups()
Gets the groups this principal directly or undirectly is member of.- Returns:
- the list of the groups
-
isMemberOf
boolean isMemberOf(String group)
Recursively test if the user is member of this group.- Parameters:
group
- The name of the group
-
setName
void setName(String name)
-
setFirstName
void setFirstName(String firstName)
-
setLastName
void setLastName(String lastName)
-
setCompany
void setCompany(String company)
-
setPassword
void setPassword(String password)
-
setEmail
void setEmail(String email)
-
getPrincipalId
String getPrincipalId()
Returns a generated id that is unique for each principal instance.- Returns:
- a unique string
-
setPrincipalId
void setPrincipalId(String principalId)
Sets the principalId.- Parameters:
principalId
- a new principalId for this instance
-
getModel
DocumentModel getModel()
-
setModel
void setModel(DocumentModel model)
-
isAdministrator
boolean isAdministrator()
Returns true if the principal is an administrator.Security checks still apply on the repository for administrator user. If user is a system user, this method will return true.
- Returns:
- true if the principal is an administrator.
-
getTenantId
String getTenantId()
- Since:
- 5.6
-
isAnonymous
boolean isAnonymous()
Checks if the principal is anonymous (guest user).- Returns:
- true if the principal is anonymous.
-
getOriginatingUser
String getOriginatingUser()
Gets the base user from which this principal was created, ornull
if this principal was not created from another user.- Returns:
- the originating user, or
null
-
setOriginatingUser
void setOriginatingUser(String originatingUser)
Sets the originating user.- Parameters:
originatingUser
- the originating user
-
getActingUser
String getActingUser()
Gets the acting user for this principal.This is the originating user (usually when this principal is a system user), or if there is none this principal's user.
- Returns:
- the acting user
- Since:
- 6.0
-
isTransient
boolean isTransient()
Returns true if the principal is a transient principal.- Since:
- 8.1
-
isTransientUsername
static boolean isTransientUsername(String username)
Returns true if the given @{code username} is a transient username.- Since:
- 8.1
-
computeTransientUsername
static String computeTransientUsername(String baseUsername)
Computes a transient username from the givenbaseUsername
.If the configuration property "nuxeo.transient.username.unique" is
true
, the transient username will be unique, otherwise it will always be the same for a givenbaseUsername
.- Since:
- 8.1
-
getCurrent
static NuxeoPrincipal getCurrent()
Returns the current logged inNuxeoPrincipal
.- Returns:
- the current logged in
NuxeoPrincipal
, ornull
if there is none - Since:
- 11.1
-
isCurrentAdministrator
static boolean isCurrentAdministrator()
Checks if the current logged inNuxeoPrincipal
is an Administrator.- Returns:
true
if the current logged inNuxeoPrincipal
is an Administrator- Since:
- 11.1
-
-