Class CommunicationsInterceptor

java.lang.Object
net.targetr.rc.monitoring.logs.CommunicationsInterceptor
All Implemented Interfaces:
HttpInterceptor, WebSocketFrameInterceptor

public class CommunicationsInterceptor extends Object implements HttpInterceptor, WebSocketFrameInterceptor
Interceptor for monitoring RCWeb HTTP requests and WebSocket frames.
  • Constructor Details

    • CommunicationsInterceptor

      public CommunicationsInterceptor()
      Constructs a new RCWebInterceptor.
  • Method Details

    • startRequest

      public void startRequest(SuperSocket client) throws IOException
      Description copied from interface: HttpInterceptor
      HttpHandler has received a new connectionabout about to start communications.
      Specified by:
      startRequest in interface HttpInterceptor
      Parameters:
      client - socket connected to the client.
      Throws:
      IOException - an exception occurred starting the interception.
    • startResponse

      public void startResponse(HttpRequest request, HttpResponse response) throws IOException
      Description copied from interface: HttpInterceptor
      The request has be read and response is ready to write.

      Used for aborting interception based on request.

      Specified by:
      startResponse in interface HttpInterceptor
      Parameters:
      request - completed request
      response - generated response to intercept
      Throws:
      IOException - an exception occurred during the interception.
    • frameIn

      public void frameIn(WebSocketFrame frame)
      Description copied from interface: WebSocketFrameInterceptor
      Called when a frame is received from the client.
      Specified by:
      frameIn in interface WebSocketFrameInterceptor
      Parameters:
      frame - the received frame
    • frameOut

      public void frameOut(WebSocketFrame frame)
      Description copied from interface: WebSocketFrameInterceptor
      Called when a frame is sent to the client.
      Specified by:
      frameOut in interface WebSocketFrameInterceptor
      Parameters:
      frame - the sent frame
    • finish

      public void finish() throws IOException
      Description copied from interface: HttpInterceptor
      Called when handling the request and writing the response has finished.
      Specified by:
      finish in interface HttpInterceptor
      Throws:
      IOException - an exception occurred after the interception.
    • sanitize

      public String sanitize(String key, List<String> value)
      Sanitizes a header value based on the header key.
      Parameters:
      key - The header key
      value - The header value
      Returns:
      The sanitized header value
    • sanitizeIpValue

      public String sanitizeIpValue(String ip)
      Replaces the final number of an IP address string with an asterisk.
      Parameters:
      ip - The input IP address (e.g., "10.0.0.1")
      Returns:
      The masked IP string (e.g., "10.0.0.*")