Package org.nuxeo.runtime.api.login
Class LoginComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.runtime.api.login.LoginComponent
-
- All Implemented Interfaces:
LoginService
,Adaptable
,Component
,Extensible
,TimestampedService
public class LoginComponent extends DefaultComponent implements LoginService
Component holding the stack of logged in principals.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LoginComponent.SystemID
-
Field Summary
Fields Modifier and Type Field Description protected static ThreadLocal<Deque<Principal>>
PRINCIPAL_STACK
The thread-local principal stack.static String
SYSTEM_USERNAME
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description LoginComponent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
clearPrincipalStack()
INTERNAL.<T> T
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.static Principal
getCurrentPrincipal()
Returns the last principal from the current principal stack.static Deque<Principal>
getPrincipalStack()
INTERNAL.boolean
isSystemId(Principal principal)
static boolean
isSystemLogin(Object principal)
NuxeoLoginContext
login()
System login, using a private principal that has all privileges.NuxeoLoginContext
login(String username, Object credentials)
Deprecated.NuxeoLoginContext
loginAs(String username)
System login, using a private principal that has all privileges.static Principal
popPrincipal()
Pops the last principal from the current principal stack.static void
pushPrincipal(Principal principal)
Pushes the principal to the current principal stack.protected NuxeoLoginContext
systemLogin(String originatingUser)
-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterContribution, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
SYSTEM_USERNAME
public static final String SYSTEM_USERNAME
- See Also:
- Constant Field Values
-
PRINCIPAL_STACK
protected static final ThreadLocal<Deque<Principal>> PRINCIPAL_STACK
The thread-local principal stack. The top of the stack (last element) contains the current principal.- Since:
- 11.1
-
-
Method Detail
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from interface:Adaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.- Specified by:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classDefaultComponent
- Parameters:
adapter
- the adapter class to look up- Returns:
- a object castable to the given class, or
null
if this object does not have an adapter for the given class
-
systemLogin
protected NuxeoLoginContext systemLogin(String originatingUser)
-
login
public NuxeoLoginContext login()
Description copied from interface:LoginService
System login, using a private principal that has all privileges. This principal is not stored in any database and cannot be accessed by user.- Specified by:
login
in interfaceLoginService
- Returns:
- the login context
-
loginAs
public NuxeoLoginContext loginAs(String username)
Description copied from interface:LoginService
System login, using a private principal that has all privileges. This principal is not stored in any database and cannot be accessed by user.- Specified by:
loginAs
in interfaceLoginService
- Parameters:
username
- the username that originated the system login- Returns:
- the login context
-
login
@Deprecated public NuxeoLoginContext login(String username, Object credentials) throws LoginException
Deprecated.Description copied from interface:LoginService
Client login using the given username and password.- Specified by:
login
in interfaceLoginService
- Throws:
LoginException
-
isSystemId
public boolean isSystemId(Principal principal)
- Specified by:
isSystemId
in interfaceLoginService
-
isSystemLogin
public static boolean isSystemLogin(Object principal)
-
clearPrincipalStack
public static void clearPrincipalStack()
INTERNAL.- Since:
- 11.1
-
pushPrincipal
public static void pushPrincipal(Principal principal)
Pushes the principal to the current principal stack.- Parameters:
principal
- the principal- Since:
- 11.1
-
popPrincipal
public static Principal popPrincipal()
Pops the last principal from the current principal stack.- Returns:
- the last principal, or
null
if the stack is empty - Since:
- 11.1
-
getCurrentPrincipal
public static Principal getCurrentPrincipal()
Returns the last principal from the current principal stack.- Returns:
- the last principal, or
null
if the stack is empty - Since:
- 11.1
-
-