Package io.mats3.matssocket
Class MatsSocketServer.ActiveMatsSocketSessionDto
java.lang.Object
io.mats3.matssocket.MatsSocketServer.MatsSocketSessionDto
io.mats3.matssocket.MatsSocketServer.ActiveMatsSocketSessionDto
- All Implemented Interfaces:
MatsSocketServer.ActiveMatsSocketSession
,MatsSocketServer.MatsSocketSession
- Enclosing interface:
- MatsSocketServer
public static class MatsSocketServer.ActiveMatsSocketSessionDto
extends MatsSocketServer.MatsSocketSessionDto
implements MatsSocketServer.ActiveMatsSocketSession
Implementation of
MatsSocketServer.ActiveMatsSocketSession
, which is serializable both for MatsSocket and Mats, i.e.
serialization mechanisms using field-based serialization.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.mats3.matssocket.MatsSocketServer.ActiveMatsSocketSession
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState
-
Field Summary
Modifier and TypeFieldDescriptionlong
long
long
long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionTheAuthenticationPlugin
can set the originating remote IP address - which must be derived by headers likeX-Forwarded-For
(Wikipedia).If we have a way to find the connected (remote) address, it will be exposed here.Methods inherited from class io.mats3.matssocket.MatsSocketServer.MatsSocketSessionDto
getAppName, getAppVersion, getClientLibAndVersions, getMatsSocketSessionId, getNodeName, getSessionCreatedTimestamp, getSessionLivelinessTimestamp, getUserId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.mats3.matssocket.MatsSocketServer.MatsSocketSession
getAppName, getAppVersion, getClientLibAndVersions, getMatsSocketSessionId, getNodeName, getSessionCreatedTimestamp, getSessionLivelinessTimestamp, getUserId
-
Field Details
-
auth
-
pn
-
rip
-
ocrip
-
subs
-
sets
public long sets -
lauthts
public long lauthts -
lcpts
public long lcpts -
lactts
public long lactts -
msgs
-
-
Constructor Details
-
ActiveMatsSocketSessionDto
public ActiveMatsSocketSessionDto()
-
-
Method Details
-
getAuthorization
- Specified by:
getAuthorization
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- the active Authorization value, only available when
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.
-
getPrincipalName
- Specified by:
getPrincipalName
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- The name of the Principal, as returned by
Principal.getName()
, only available whenMatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.
-
getRemoteAddr
Description copied from interface:MatsSocketServer.ActiveMatsSocketSession
If we have a way to find the connected (remote) address, it will be exposed here. It can be set/overridden in theAuthenticationPlugin
. Be advised that when the WebSocket Server (i.e. Servlet Container) is behind a proxy, you will get the proxy's address, not the end client's address, aka originating IP address. This can, if you add the functionality to theAuthenticationPlugin
, be gotten byMatsSocketServer.ActiveMatsSocketSession.getOriginatingRemoteAddr()
. Note: The remote address is not exposed by the JSR 356 Java API for WebSockets - but there are hacks for different Servlet Containers to get it anyway. Check out classRemoteAddressContainerHacks
.- Specified by:
getRemoteAddr
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- the remote address if available (should be an IP address).
-
getOriginatingRemoteAddr
Description copied from interface:MatsSocketServer.ActiveMatsSocketSession
TheAuthenticationPlugin
can set the originating remote IP address - which must be derived by headers likeX-Forwarded-For
(Wikipedia). Note the problems with this header: Since the originating client can set whatever he wants as initial value, you cannot rely on the "first IP address in the list", as this might well be bogus. You must go from the last and work your way up, and only trust the information given by proxies you are in control of: The first IP address in the list that you do not know, is what you should set as originating remote address. Each proxy adds the remote address that he sees (i.e. who is the remote address for him). This means that the last proxy's ip address is not in the list - this must be gotten byMatsSocketServer.ActiveMatsSocketSession.getRemoteAddr()
.- Specified by:
getOriginatingRemoteAddr
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- the originating remote address if
AuthenticationPlugin
has set it (should be an IP address).
-
getTopicSubscriptions
- Specified by:
getTopicSubscriptions
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- which Topics this session has subscribed to.
-
getSessionEstablishedTimestamp
- Specified by:
getSessionEstablishedTimestamp
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- when this MatsSocketSession was established - this timestamp is "reset" on every
RECONNECT
(and of course set on initial connect, i.e.NEW
), as opposed toMatsSocketServer.MatsSocketSession.getSessionCreatedTimestamp()
which is set a single time when the session if first created.
-
getLastAuthenticatedTimestamp
- Specified by:
getLastAuthenticatedTimestamp
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- timestamp (millis-since-epoch) of when we the client was last authenticated: When
AuthenticationPlugin.SessionAuthenticator.initialAuthentication(AuthenticationContext, String)
returnedAuthenticationPlugin.AuthenticationContext.authenticated(Principal, String)
, or whenAuthenticationPlugin.SessionAuthenticator.reevaluateAuthentication(AuthenticationContext, String, Principal)
returnedAuthenticationPlugin.AuthenticationContext.authenticated(Principal, String)
orAuthenticationPlugin.AuthenticationContext.stillValid()
.
-
getLastClientPingTimestamp
- Specified by:
getLastClientPingTimestamp
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- timestamp (millis-since-epoch) of when we last received a PING message from the Client.
-
getLastActivityTimestamp
- Specified by:
getLastActivityTimestamp
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- timestamp (millis-since-epoch) of when the Server last received an information bearing message (SEND, REQUEST, RESOLVE or REJECT) from the Client, or when the Server last sent an information bearing message (SEND, REQUEST, RESOLVE, REJECT or PUB) to the Client
-
getLastEnvelopes
- Specified by:
getLastEnvelopes
in interfaceMatsSocketServer.ActiveMatsSocketSession
- Returns:
- snapshot (i.e. newly created ArrayList) of last 200 (per default) envelopes going between client and server in both directions.
-