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 classLoginComponent.SystemID
-
Field Summary
Fields Modifier and Type Field Description protected static ThreadLocal<Deque<Principal>>PRINCIPAL_STACKThe thread-local principal stack.static StringSYSTEM_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 voidclearPrincipalStack()INTERNAL.<T> TgetAdapter(Class<T> adapter)Returns an object which is an instance of the given class associated with this object.static PrincipalgetCurrentPrincipal()Returns the last principal from the current principal stack.static Deque<Principal>getPrincipalStack()INTERNAL.booleanisSystemId(Principal principal)static booleanisSystemLogin(Object principal)NuxeoLoginContextlogin()System login, using a private principal that has all privileges.NuxeoLoginContextlogin(String username, Object credentials)Deprecated.NuxeoLoginContextloginAs(String username)System login, using a private principal that has all privileges.static PrincipalpopPrincipal()Pops the last principal from the current principal stack.static voidpushPrincipal(Principal principal)Pushes the principal to the current principal stack.protected NuxeoLoginContextsystemLogin(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:AdaptableReturns an object which is an instance of the given class associated with this object. Returnsnullif no such object can be found.- Specified by:
getAdapterin interfaceAdaptable- Overrides:
getAdapterin classDefaultComponent- Parameters:
adapter- the adapter class to look up- Returns:
- a object castable to the given class, or
nullif 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:LoginServiceSystem 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:
loginin interfaceLoginService- Returns:
- the login context
-
loginAs
public NuxeoLoginContext loginAs(String username)
Description copied from interface:LoginServiceSystem 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:
loginAsin 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:LoginServiceClient login using the given username and password.- Specified by:
loginin interfaceLoginService- Throws:
LoginException
-
isSystemId
public boolean isSystemId(Principal principal)
- Specified by:
isSystemIdin 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
nullif 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
nullif the stack is empty - Since:
- 11.1
-
-