@Component(value="cuba_Connection") @Scope(value="vaadin") public class ConnectionImpl extends java.lang.Object implements Connection
Connection
implementation for web-client.Connection.StateChangeEvent, Connection.UserSubstitutedEvent
Modifier and Type | Field and Description |
---|---|
protected AuthenticationService |
authenticationService |
protected BackgroundWorker |
backgroundWorker |
protected EventHub |
eventHub |
protected Events |
events |
protected GlobalConfig |
globalConfig |
protected java.util.List<LoginProvider> |
loginProviders |
protected Messages |
messages |
protected java.lang.String |
userRemoteAddress |
protected UserSessionService |
userSessionService |
NAME
Constructor and Description |
---|
ConnectionImpl() |
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.
|
protected ClientUserSession |
createSession(UserSession userSession) |
protected java.util.TimeZone |
detectTimeZone() |
protected void |
fireStateChangeListeners(UserSession previousSession,
UserSession newSession) |
protected void |
fireSubstitutionListeners() |
protected java.util.List<LoginProvider> |
getProviders() |
UserSession |
getSession()
Get current user session.
|
protected ClientUserSession |
getSessionInternal() |
protected java.lang.String |
getUserRemoteAddress() |
protected com.vaadin.server.WebBrowser |
getWebBrowserDetails() |
protected void |
init() |
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.
|
protected AuthenticationDetails |
loginInternal(Credentials credentials) |
void |
logout()
Log out of the system.
|
protected java.lang.String |
makeClientInfo() |
protected void |
preprocessCredentials(Credentials credentials) |
protected void |
publishAfterLoginEvent(Credentials credentials,
AuthenticationDetails authenticationDetails) |
protected void |
publishBeforeLoginEvent(Credentials credentials) |
protected void |
publishDisconnectedEvent(UserSession previousSession) |
protected void |
publishLoginFailed(Credentials credentials,
LoginProvider provider,
LoginException e) |
protected void |
publishUserConnectedEvent(Credentials credentials) |
protected void |
publishUserSessionFinishedEvent(UserSession session) |
protected void |
publishUserSessionStartedEvent(Credentials credentials,
AuthenticationDetails authenticationDetails) |
protected void |
publishUserSessionSubstitutedEvent(UserSession previousSession,
UserSession session) |
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.
|
protected void |
setSessionInternal(ClientUserSession userSession) |
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
@Inject protected AuthenticationService authenticationService
@Inject protected UserSessionService userSessionService
@Inject protected java.util.List<LoginProvider> loginProviders
@Inject protected Events events
@Inject protected Messages messages
@Inject protected BackgroundWorker backgroundWorker
@Inject protected GlobalConfig globalConfig
protected java.lang.String userRemoteAddress
protected EventHub eventHub
public void login(Credentials credentials) throws LoginException
Connection
login
in interface Connection
credentials
- credentialsLoginException
- if authentication failsprotected ClientUserSession createSession(UserSession userSession)
protected void preprocessCredentials(Credentials credentials)
@Nullable protected java.lang.String getUserRemoteAddress()
protected java.lang.String makeClientInfo()
protected java.util.TimeZone detectTimeZone()
protected com.vaadin.server.WebBrowser getWebBrowserDetails()
protected AuthenticationDetails loginInternal(Credentials credentials) throws LoginException
LoginException
protected void fireStateChangeListeners(@Nullable UserSession previousSession, @Nullable UserSession newSession)
protected void fireSubstitutionListeners()
protected void publishUserConnectedEvent(Credentials credentials)
protected void publishBeforeLoginEvent(Credentials credentials) throws LoginException
LoginException
protected void publishAfterLoginEvent(Credentials credentials, @Nullable AuthenticationDetails authenticationDetails)
protected void publishLoginFailed(Credentials credentials, LoginProvider provider, LoginException e) throws LoginException
LoginException
protected void publishUserSessionStartedEvent(Credentials credentials, AuthenticationDetails authenticationDetails)
@Nullable protected ClientUserSession getSessionInternal()
protected void setSessionInternal(@Nullable ClientUserSession userSession)
public void logout()
Connection
logout
in interface Connection
protected void publishUserSessionFinishedEvent(UserSession session)
protected void publishUserSessionSubstitutedEvent(UserSession previousSession, UserSession session)
protected void publishDisconnectedEvent(@Nullable UserSession previousSession)
@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
protected java.util.List<LoginProvider> getProviders()
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@PostConstruct protected void init()