public interface Connection
| Modifier and Type | Interface and Description |
|---|---|
static class |
Connection.StateChangeEvent |
static class |
Connection.UserSubstitutedEvent |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NAME |
| Modifier and Type | Method and Description |
|---|---|
void |
addStateChangeListener(java.util.function.Consumer<Connection.StateChangeEvent> listener)
Add a connection listener.
|
void |
addUserSubstitutionListener(java.util.function.Consumer<Connection.UserSubstitutedEvent> listener)
Add a user substitution listener.
|
UserSession |
getSession()
Get current user session.
|
default UserSession |
getSessionNN()
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(Credentials credentials)
Authenticates a user, starts session and changes state of the connection.
|
default void |
login(java.lang.String login,
java.lang.String password,
java.util.Locale locale)
Deprecated.
|
default void |
loginAnonymous(java.util.Locale locale)
Deprecated.
|
default void |
loginByRememberMe(java.lang.String login,
java.lang.String rememberMeToken,
java.util.Locale locale)
Deprecated.
|
void |
logout()
Log out of the system.
|
void |
removeStateChangeListener(java.util.function.Consumer<Connection.StateChangeEvent> listener)
Remove a connection listener.
|
void |
removeUserSubstitutionListener(java.util.function.Consumer<Connection.UserSubstitutedEvent> listener)
Remove a user substitution listener.
|
void |
substituteUser(User substitutedUser)
Substitute a user in the current session with another user.
|
static final java.lang.String NAME
void login(Credentials credentials) throws LoginException
credentials - credentialsLoginException - if authentication failsvoid logout()
@Nullable UserSession getSession()
@Nonnull default UserSession getSessionNN()
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()
void addStateChangeListener(java.util.function.Consumer<Connection.StateChangeEvent> listener)
listener - listener to addvoid removeStateChangeListener(java.util.function.Consumer<Connection.StateChangeEvent> listener)
listener - listener to removevoid addUserSubstitutionListener(java.util.function.Consumer<Connection.UserSubstitutedEvent> listener)
listener - listener to addvoid removeUserSubstitutionListener(java.util.function.Consumer<Connection.UserSubstitutedEvent> listener)
listener - listener to remove@Deprecated
default 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 issues@Deprecated
default void loginAnonymous(java.util.Locale locale)
throws LoginException
locale - user localeLoginException - in case of unsuccessful login due to wrong credentials or other issues@Deprecated
default void 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 issues