public interface Connection
Modifier and Type | Interface and Description |
---|---|
static class |
Connection.SessionMode |
static class |
Connection.UserSessionInitEvent
Event that is used for additional initialization during
update(UserSession, SessionMode, Consumer) . |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(ConnectionListener listener)
Add a connection listener.
|
void |
addSubstitutionListener(UserSubstitutionListener listener)
Add a user substitution listener.
|
default boolean |
checkRememberMe(java.lang.String login,
java.lang.String rememberMeToken)
Deprecated.
|
UserSession |
getSession()
Get current user session.
|
boolean |
isAlive()
Check if session is alive on middleware
|
boolean |
isAuthenticated()
Check if the client was authenticated.
|
boolean |
isConnected()
Check if the client is connected to the middleware.
|
void |
login(java.lang.String login,
java.lang.String password,
java.util.Locale locale)
Log in to the system.
|
void |
loginAnonymous(java.util.Locale locale)
Log in to the system.
|
void |
loginByRememberMe(java.lang.String login,
java.lang.String rememberMeToken,
java.util.Locale locale)
Log in to the system.
|
void |
logout()
Log out of the system.
|
void |
removeConnectionListener(ConnectionListener listener)
Remove a connection listener.
|
void |
removeSubstitutionListener(UserSubstitutionListener listener)
Remove a user substitution listener.
|
void |
substituteUser(User substitutedUser)
Substitute a user in the current session with another user.
|
void |
update(UserSession session,
Connection.SessionMode sessionMode)
Update internal state with the passed user session object.
|
void |
update(UserSession session,
Connection.SessionMode sessionMode,
java.util.function.Consumer<Connection.UserSessionInitEvent> sessionInitializer)
Update internal state with the passed user session object.
|
static final java.lang.String NAME
void login(java.lang.String login, java.lang.String password, java.util.Locale locale) throws LoginException
login
- user login namepassword
- encrypted user passwordlocale
- user localeLoginException
- in case of unsuccessful login due to wrong credentials or other issuesvoid loginAnonymous(java.util.Locale locale) throws LoginException
locale
- user localeLoginException
- in case of unsuccessful login due to wrong credentials or other issuesvoid loginByRememberMe(java.lang.String login, java.lang.String rememberMeToken, java.util.Locale locale) throws LoginException
login
- user login namerememberMeToken
- remember me tokenlocale
- user localeLoginException
- in case of unsuccessful login due to wrong credentials or other issuesvoid logout()
void substituteUser(User substitutedUser)
New user is usually obtained from the current user's substitution list:
see User.getSubstitutions()
substitutedUser
- new userboolean isConnected()
boolean isAuthenticated()
boolean isAlive()
@Deprecated default boolean checkRememberMe(java.lang.String login, java.lang.String rememberMeToken)
login
- user loginrememberMeToken
- remember me token@Nullable UserSession getSession()
void update(UserSession session, Connection.SessionMode sessionMode) throws LoginException
session
- new UserSession objectLoginException
- in case of unsuccessful updatevoid update(UserSession session, Connection.SessionMode sessionMode, @Nullable java.util.function.Consumer<Connection.UserSessionInitEvent> sessionInitializer) throws LoginException
session
- new UserSession objectsessionInitializer
- optional callback that will be triggered after session setup and before triggering
connection state change listenersLoginException
- in case of unsuccessful updatevoid addConnectionListener(ConnectionListener listener)
listener
- listener to addvoid removeConnectionListener(ConnectionListener listener)
listener
- listener to removevoid addSubstitutionListener(UserSubstitutionListener listener)
listener
- listener to addvoid removeSubstitutionListener(UserSubstitutionListener listener)
listener
- listener to remove