public static interface MatsSocketServer.ActiveMatsSocketSession extends MatsSocketServer.MatsSocketSession
Modifier and Type | Interface and Description |
---|---|
static class |
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState
The state of ActiveMatsSocketSession.
|
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
java.util.Optional<java.lang.String> getAuthorization()
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.java.util.Optional<java.lang.String> getPrincipalName()
Principal.getName()
, only available when
MatsSocketServer.ActiveMatsSocketSession.MatsSocketSessionState.SESSION_ESTABLISHED
.java.util.Optional<java.lang.String> getRemoteAddr()
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
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
.java.util.Optional<java.lang.String> getOriginatingRemoteAddr()
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 getRemoteAddr()
.AuthenticationPlugin
has set it (should be an IP
address).java.util.SortedSet<java.lang.String> getTopicSubscriptions()
java.time.Instant getSessionEstablishedTimestamp()
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.java.time.Instant getLastAuthenticatedTimestamp()
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()
.java.time.Instant getLastClientPingTimestamp()
java.time.Instant getLastActivityTimestamp()
java.util.List<MatsSocketServer.MatsSocketEnvelopeWithMetaDto> getLastEnvelopes()