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
FieldsFields inherited from class io.antmedia.filter.AbstractFilter
BROADCAST_OBJECT, config, logger, streamStats -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) voidforwardRequestToNode(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String registeredNodeIp) static jakarta.servlet.ServletConfiggetServletConfig(String targetUri) getStreamId(String reqURI) private StringgetSubscriberId(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 urlbooleanisHostRunning(String address, int port) static booleanisNodeCommunicationTokenValid(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 validitybooleanisRequestDestinedForThisNode(String requestAddress, String nodeAddress) Check if the request should be handled in this nodebooleanisSubscriberBlockReq(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:
IOExceptionjakarta.servlet.ServletException
-
isHostRunning
-
forwardRequestToNode
public void forwardRequestToNode(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String registeredNodeIp) throws IOException, jakarta.servlet.ServletException - Throws:
IOExceptionjakarta.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.
-