Package io.antmedia.filter
Class RestProxyFilter
java.lang.Object
io.antmedia.filter.AbstractFilter
io.antmedia.filter.RestProxyFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
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 Summary
Fields inherited from class io.antmedia.filter.AbstractFilter
BROADCAST_OBJECT, config, logger, streamStats
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doFilter
(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) void
forwardRequestToNode
(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String registeredNodeIp) static jakarta.servlet.ServletConfig
getServletConfig
(String targetUri) getStreamId
(String reqURI) 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 urlboolean
isHostRunning
(String address, int port) 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 validityboolean
isRequestDestinedForThisNode
(String requestAddress, String nodeAddress) Check if the request should be handled in this nodeboolean
isSubscriberBlockReq
(String requestUri) Methods inherited from class io.antmedia.filter.AbstractFilter
checkCIDRList, destroy, getAntMediaApplicationAdapter, getAppContext, getAppSettings, getBroadcast, getConfig, getDataStore, getServerSettings, getStreamStats, getTokenService, getWebApplicationContext, init, setConfig, setTokenService
-
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
-
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
-
getStreamId
-
getSubscriberId
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
-
isRequestDestinedForThisNode
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.
-