public static class MatsSocketServer.ActiveMatsSocketSessionDto extends MatsSocketServer.MatsSocketSessionDto implements MatsSocketServer.ActiveMatsSocketSession
MatsSocketServer.ActiveMatsSocketSession
, which is serializable both for MatsSocket and Mats, i.e.
serialization mechanisms using field-based serialization.MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState
Modifier and Type | Field and Description |
---|---|
java.lang.String |
auth |
long |
lactts |
long |
lauthts |
long |
lcpts |
java.util.List<MatsSocketServer.MatsSocketEnvelopeWithMetaDto> |
msgs |
java.lang.String |
ocrip |
java.lang.String |
pn |
java.lang.String |
rip |
long |
sets |
java.util.SortedSet<java.lang.String> |
subs |
Constructor and Description |
---|
ActiveMatsSocketSessionDto() |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<java.lang.String> |
getAuthorization() |
java.time.Instant |
getLastActivityTimestamp() |
java.time.Instant |
getLastAuthenticatedTimestamp() |
java.time.Instant |
getLastClientPingTimestamp() |
java.util.List<MatsSocketServer.MatsSocketEnvelopeWithMetaDto> |
getLastEnvelopes() |
java.util.Optional<java.lang.String> |
getOriginatingRemoteAddr()
The
AuthenticationPlugin can set the originating remote IP address - which must be derived by headers
like X-Forwarded-For (Wikipedia). |
java.util.Optional<java.lang.String> |
getPrincipalName() |
java.util.Optional<java.lang.String> |
getRemoteAddr()
If we have a way to find the connected (remote) address, it will be exposed here.
|
java.time.Instant |
getSessionEstablishedTimestamp() |
java.util.SortedSet<java.lang.String> |
getTopicSubscriptions() |
getAppName, getAppVersion, getClientLibAndVersions, getMatsSocketSessionId, getNodeName, getSessionCreatedTimestamp, getSessionLivelinessTimestamp, getUserId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAppName, getAppVersion, getClientLibAndVersions, getMatsSocketSessionId, getNodeName, getSessionCreatedTimestamp, getSessionLivelinessTimestamp, getUserId
public java.lang.String auth
public java.lang.String pn
public java.lang.String rip
public java.lang.String ocrip
public java.util.SortedSet<java.lang.String> subs
public long sets
public long lauthts
public long lcpts
public long lactts
public java.util.List<MatsSocketServer.MatsSocketEnvelopeWithMetaDto> msgs
public java.util.Optional<java.lang.String> getAuthorization()
getAuthorization
in interface MatsSocketServer.ActiveMatsSocketSession
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.public java.util.Optional<java.lang.String> getPrincipalName()
getPrincipalName
in interface MatsSocketServer.ActiveMatsSocketSession
Principal.getName()
, only available when
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.public java.util.Optional<java.lang.String> getRemoteAddr()
MatsSocketServer.ActiveMatsSocketSession
AuthenticationPlugin
. 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 the AuthenticationPlugin
, be gotten by
MatsSocketServer.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 class RemoteAddressContainerHacks
.getRemoteAddr
in interface MatsSocketServer.ActiveMatsSocketSession
public java.util.Optional<java.lang.String> getOriginatingRemoteAddr()
MatsSocketServer.ActiveMatsSocketSession
AuthenticationPlugin
can set the originating remote IP address - which must be derived by headers
like X-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 by MatsSocketServer.ActiveMatsSocketSession.getRemoteAddr()
.getOriginatingRemoteAddr
in interface MatsSocketServer.ActiveMatsSocketSession
AuthenticationPlugin
has set it (should be an IP
address).public java.util.SortedSet<java.lang.String> getTopicSubscriptions()
getTopicSubscriptions
in interface MatsSocketServer.ActiveMatsSocketSession
public java.time.Instant getSessionEstablishedTimestamp()
getSessionEstablishedTimestamp
in interface MatsSocketServer.ActiveMatsSocketSession
RECONNECT
(and of course set on initial connect, i.e.
NEW
), as opposed to MatsSocketServer.MatsSocketSession.getSessionCreatedTimestamp()
which is set a single time when the session if first created.public java.time.Instant getLastAuthenticatedTimestamp()
getLastAuthenticatedTimestamp
in interface MatsSocketServer.ActiveMatsSocketSession
SessionAuthenticator#initialAuthentication(AuthenticationContext, String)
returned
AuthenticationPlugin.AuthenticationContext.authenticated(Principal, String)
, or when
SessionAuthenticator#reevaluateAuthentication(AuthenticationContext, String, Principal)
returned AuthenticationPlugin.AuthenticationContext.authenticated(Principal, String)
or
AuthenticationPlugin.AuthenticationContext.stillValid()
.public java.time.Instant getLastClientPingTimestamp()
getLastClientPingTimestamp
in interface MatsSocketServer.ActiveMatsSocketSession
public java.time.Instant getLastActivityTimestamp()
getLastActivityTimestamp
in interface MatsSocketServer.ActiveMatsSocketSession
public java.util.List<MatsSocketServer.MatsSocketEnvelopeWithMetaDto> getLastEnvelopes()
getLastEnvelopes
in interface MatsSocketServer.ActiveMatsSocketSession