public class TestConnection extends java.lang.Object implements Connection
Connection.StateChangeEvent, Connection.UserSubstitutedEvent
NAME
Constructor and Description |
---|
TestConnection() |
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.
|
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.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSessionNN, login, loginAnonymous, loginByRememberMe
public void login(Credentials credentials) throws LoginException
Connection
login
in interface Connection
credentials
- credentialsLoginException
- if authentication failspublic void logout()
Connection
logout
in interface Connection
@Nullable public UserSession getSession()
Connection
getSession
in interface Connection
public void substituteUser(User substitutedUser)
Connection
New user is usually obtained from the current user's substitution list:
see User.getSubstitutions()
substituteUser
in interface Connection
substitutedUser
- new userpublic boolean isConnected()
Connection
isConnected
in interface Connection
public boolean isAuthenticated()
Connection
isAuthenticated
in interface Connection
public boolean isAlive()
Connection
isAlive
in interface Connection
public void addStateChangeListener(java.util.function.Consumer<Connection.StateChangeEvent> listener)
Connection
addStateChangeListener
in interface Connection
listener
- listener to addpublic void removeStateChangeListener(java.util.function.Consumer<Connection.StateChangeEvent> listener)
Connection
removeStateChangeListener
in interface Connection
listener
- listener to removepublic void addUserSubstitutionListener(java.util.function.Consumer<Connection.UserSubstitutedEvent> listener)
Connection
addUserSubstitutionListener
in interface Connection
listener
- listener to addpublic void removeUserSubstitutionListener(java.util.function.Consumer<Connection.UserSubstitutedEvent> listener)
Connection
removeUserSubstitutionListener
in interface Connection
listener
- listener to remove