Implementing Stream Security in Red5
to implement security an application needs to do the folowing :
- Capture client parameters
- Implement the IStreamPlaybackSecurity and/or IStreamPublishSecurity interfaces to intercept playback and publish
- Within the intercepting methods of the implementations access client parameters and validate the action (publish/subscribe)
The entire process is explained in details in the following links. It is recommended that you read through before attempting to install this application.
Build & Deploy
To build this application : open a shell prompt in the application's project directory (where the pom.xml file resides). run the following maven command in your shell ->
mvn clean package
The above command will generate a
war file in the
target directory inside the project directory.
To deploy the war to red5 pro server :
Stop server if it is running.
Extract the content of the
war fileto directory by war name.
The java war file is simply a
archive filesimilar to
zipformat. you can extract it using a archive tool such as 7zip, Winrar trial etc
Copy the folder into
How To Use Example
To see this example in action, deploy this application (stream-security-demo) on your server. Connect to the wb application and attempt to publish / subscribe.
- To publish to a stream successfully, your client must pass a parameter called 'token' with the value of 'red5pro#publisher'.
Code link: https://github.com/rajdeeprath/red5-development-series/blob/master/code-examples/server-side/red5-stream-examples/stream-security-demo/src/main/java/org/red5/streams/examples/security/PublishSecurity.java
- To subscribe to a stream successfully, your client must pass a parameter called 'token' with the value of 'red5pro#subscriber'.
Code link: https://github.com/rajdeeprath/red5-development-series/blob/master/code-examples/server-side/red5-stream-examples/stream-security-demo/src/main/java/org/red5/streams/examples/security/PlaybackSecurity.java
Check out Capturing client params, to see how to pass parameters to the application for RTMP/RTSP/WebRTC.
You can edit the server side code in your eclipse JEE IDE such as Luna, Mars, Neon etc. To import the code into your IDE:
- Navigate to the repository folder
- Execute maven command
mvn eclipse:eclipse. This will generate files necessary for eclipse to read the maven project properly.
- In eclipse go to
File -> Import -> Existing Maven Projectsand click
- Browse and select
the project rootand Click
Finishto import the project.