Class RestProxyFilter

java.lang.Object
io.antmedia.filter.AbstractFilter
io.antmedia.filter.RestProxyFilter
All Implemented Interfaces:
jakarta.servlet.Filter

public class RestProxyFilter extends AbstractFilter
This filter forwards incoming requests to the origin node that is responsible for that stream. It adds JWT token for security check
Author:
mekya
  • Field Details

    • log

      protected static org.slf4j.Logger log
  • Constructor Details

    • RestProxyFilter

      public RestProxyFilter()
  • Method Details

    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Throws:
      IOException
      jakarta.servlet.ServletException
    • isHostRunning

      public boolean isHostRunning(String address, int port)
    • forwardRequestToNode

      public void forwardRequestToNode(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String registeredNodeIp) throws IOException, jakarta.servlet.ServletException
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getServletConfig

      public static jakarta.servlet.ServletConfig getServletConfig(String targetUri)
    • getStreamId

      public String getStreamId(String reqURI)
    • getSubscriberId

      private String getSubscriberId(String reqURI)
      REST method is in this format "/{id}/subscribers/{sid}/block" -> BroadcastRestService#blockSubscriber(String, String, Subscriber) We're going to get the {sid} from the url
      Parameters:
      reqURI -
      Returns:
    • isSubscriberBlockReq

      public boolean isSubscriberBlockReq(String requestUri)
    • isRequestDestinedForThisNode

      public boolean isRequestDestinedForThisNode(String requestAddress, String nodeAddress)
      Check if the request should be handled in this node
      Parameters:
      requestAddress -
      nodeAddress -
      Returns:
      true if this node should handle this request or return false
    • isNodeCommunicationTokenValid

      public static boolean isNodeCommunicationTokenValid(String jwtInternalCommunicationToken, String jwtSecretKey, String requestURI)
      This method checks if there is a token in the header for internal node communication and if it exists, checks its validity
      Parameters:
      httpRequest -
      Returns:
      true if there is a token and it's valid. Otherwise it returns false.