Class CloudSession.SessionAgentListener

java.lang.Object
com.ultikits.ultitools.utils.CloudSession.SessionAgentListener
All Implemented Interfaces:
AgentConnection.Listener
Enclosing class:
CloudSession

private final class CloudSession.SessionAgentListener extends Object implements AgentConnection.Listener
  • Field Details

    • connection

      private AgentConnection connection
    • attemptCredentialId

      private String attemptCredentialId
    • rejectionReported

      private boolean rejectionReported
    • upgradeReported

      private boolean upgradeReported
    • supersededReported

      private boolean supersededReported
    • mismatchReported

      private boolean mismatchReported
  • Constructor Details

    • SessionAgentListener

      private SessionAgentListener()
  • Method Details

    • live

      private boolean live()
    • adoptRotation

      private void adoptRotation(String retiredId, String rotatedId)
      Re-points the credential a rejection of this connection deletes once a credential.rotate it carried is durable (called under this session's monitor by CloudSession.rotateCredential(java.lang.String, java.lang.String)). The gateway now knows this server by the rotated credential, so a later 4401 on this attempt rejects that one: deleting only the handshake-time id would find the rotated id on disk, skip the delete and leave a revoked credential that keeps status() linked and blocks /ulticloud login. An attempt id that is not the retired one (a newer credential saved meanwhile) is left as it is, so the compare-and-delete still never removes a credential this attempt did not hold.
      Parameters:
      retiredId - the id the rotation replaced
      rotatedId - the id now on disk and in CloudSession.credential
    • readBearer

      private String readBearer()
      The bearer of the next attempt: the session's own CloudSession.credential, the one owner of the current credential (plan 22-21 fix), so an attempt after a rotation authenticates with the rotated secret and attemptCredentialId names the credential this attempt really used.
    • onOpened

      public void onOpened()
      The upgrade was accepted: a fresh protocol layer sends hello. The connection is established -- counters reset, heartbeat started, "connected" -- only when the protocol accepts the welcome (plan 22-20, D-12), not here.
      Specified by:
      onOpened in interface AgentConnection.Listener
    • onCredentialRejected

      public void onCredentialRejected(int code, String requestId)
      Specified by:
      onCredentialRejected in interface AgentConnection.Listener
      Parameters:
      code - 401 or 4401
      requestId - the refused response's request id
    • onUpgradeRequired

      public void onUpgradeRequired(String minFramework, String requestId)
      Specified by:
      onUpgradeRequired in interface AgentConnection.Listener
      Parameters:
      minFramework - the minimum framework the gateway accepts, sanitised
      requestId - the refused response's request id
    • onSuperseded

      public void onSuperseded()
      Description copied from interface: AgentConnection.Listener
      Too many consecutive supersessions; retrying stopped, credential kept.
      Specified by:
      onSuperseded in interface AgentConnection.Listener
    • onPlanLimited

      public void onPlanLimited(UpgradeRejection notice)
      Specified by:
      onPlanLimited in interface AgentConnection.Listener
      Parameters:
      notice - the first 402 response of a plan-limit episode; once per episode
    • onServerIdMismatch

      public void onServerIdMismatch()
      Description copied from interface: AgentConnection.Listener
      The welcome named another server id; retrying stopped, credential kept.
      Specified by:
      onServerIdMismatch in interface AgentConnection.Listener
    • onStateChanged

      public void onStateChanged(AgentConnection.State state)
      Specified by:
      onStateChanged in interface AgentConnection.Listener
      Parameters:
      state - the new state, once per real transition
    • onText

      public void onText(String text)
      Hands the frame to the current protocol layer, outside the session monitor.
      Specified by:
      onText in interface AgentConnection.Listener
      Parameters:
      text - an inbound text frame other than the heartbeat reply