Use the IStreamPlaybackSecurity interface for applications that want to limit the playback of streams per user or only want to provide access to streams with a given name.
An example handler that only allows access to streams that have a name starting with "liveStream" is described below
public class NamePlaybackSecurity : IStreamPlaybackSecurity
{
public bool IsPlaybackAllowed(IScope scope, String name, int start, int length, boolean flushPlaylist)
{
if (!name.StartsWith("liveStream"))
return false;
else
return true;
};
}
To register this handler in the application, add the following code in the AppStart method:
RegisterStreamPlaybackSecurity(new NamePlaybackSecurity());
Use the IStreamPublishSecurity interface for applications that want to limit the user to publish and/or record streams.
An example handler that only allows authenticated connections to publish a live stream starting with "testing" and deny all other access is described below:
public class AuthNamePublishSecurity : IStreamPublishSecurity
{
public bool IsPublishAllowed(IScope scope, String name, String mode)
{
if (!"live".Equals(mode))
{
// Not a live stream
return false;
}
IConnection connection = FluorineContext.Current.Connection;
if (!"authenticated".Equals(connection.GetAttribute("UserType")))
{
// User was not authenticated
return false;
}
if (!name.StartsWith("testing"))
return false;
else
return true;
};
}
To register this handler in the application, add the following code in the AppStart method:
RegisterStreamPublishSecurity(new AuthNamePublishSecurity());
The FluorineFx.Messaging.Api.Stream.Support.DenyAllStreamAccess class can be used to deny all access to streams.