How to control access to HTTP streams (cupertinostreaming, sanjosestreaming, smoothstreaming, mpegdashstreaming)

The following shows a basic API for controlling access to Apple HLS (cupertinostreaming), Adobe HDS (sanjosestreaming), Microsoft Smooth (smoothstreaming), and MPEG-DASH (mpegdashstreaming) streams in one module:

package com.wowza.wms.example.module;

import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession;
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;

public class ModuleAccessControlHTTPStreaming extends ModuleBase
{
	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
	{
		boolean isGood = true;

		String ipAddressClient = httpSession.getIpAddress();
		String ipAddressServer = httpSession.getServerIp();
		String queryStr = httpSession.getQueryStr();
		String referrer = httpSession.getReferrer();
		String cookieStr = httpSession.getCookieStr();
		String userAgent = httpSession.getUserAgent();

		IApplicationInstance appInstance = httpSession.getAppInstance();
		String streamName = httpSession.getStreamName();

		// Here you can use the request and session information above to determine 
		// if you want to reject the connection
		// isGood = true/false;

		getLogger().info("ModuleAccessControlHTTPStreaming.onHTTPSessionCreate["+appInstance.getContextStr()+":"+streamName+"]: accept:"+isGood);

		if (!isGood)
			httpSession.rejectSession();
	}
}

Build this module using the Wowza IDE and add it last in the <Modules> section in /conf/[app-name]/Application.xml:

<Module>
	<Name>ModuleAccessControlHTTPStreaming</Name>
	<Description>Access control for HTTP streams</Description>
	<Class>com.wowza.wms.example.module.ModuleAccessControlHTTPStreaming</Class>
</Module>

Originally Published: 03-29-2011.
Updated: For Wowza Streaming Engine on 01-07-2015.

If you're having problems or want to discuss this article, post in our forum.