Wowza authontication using an external can

I use the Wowza streaming engine in my project. I successfully started wowza with basic authentication. I need to authenticate wowza with my database because I am creating a java project. It will process the authentication process after I add the jar to the Wowza driver folder.

This is the jar source code:

 public class WowzaTesting {
    boolean authStatus = false;
    public boolean authenticationTest(String username, String password) {
        System.out.println("Authentication Process started");

        // authentication code here
        // if authentication is done authStatus=true; else authStatus=false;

        if (authStatus) {
            return true;
        } else {
            return false;
        }
    }
}

And I added to the conf file:

<Module>
  <Name>TestWowza</Name>
  <Description>Java code for testing wowza</Description>
  <Class>com.test.wowza.WowzaTesting</Class>
</Module>

Then restarted the wowza server engine.

I have a few questions:

  • Did I skip any steps?
  • How to call a method in a jar file during a Wowza check?

I am currently using this command to broadcast live "

ffmpeg -i "rtsp://localhost:port/livetest" -vcodec copy -acodec copy -f rtsp "rtsp://username:password@localhost:port/live/livetest
  1. How to get username and password from the above command for my method?
+4
1

- ?

API Wowza AuthenticateUsernamePasswordProviderBase, , .

jar Wowza?

RTSP Wowza , , ( Root/Application/RTP/Authentication/PublishMethod ). . , Java Authentication.xml . 3 Wowza Authentication.xml conf/ , 4 com.wowza.wms.conf( conf/, , ). , Wowza , , .

?

Wowza RTSP, / Java- .

, :

package com.wowza.wms.example.authenticate;

import com.wowza.wms.authentication.*;
import com.wowza.wms.logging.WMSLoggerFactory; 
import java.sql.*;

public class AuthenticateUsernamePasswordProviderExample extends AuthenticateUsernamePasswordProviderBase
{
public String getPassword(String username)
{
    // return password for given username       
    String pwd = null;

    WMSLoggerFactory.getLogger(null).info("Authenticate getPassword username: " + username);

    Connection conn = null;
    try 
    {
        conn = DriverManager.getConnection("jdbc:mysql://localhost/wowza?user=root&password=mypassword");

        Statement stmt = null;
        ResultSet rs = null;

        try 
        {
            stmt = conn.createStatement();
            rs = stmt.executeQuery("SELECT pwd FROM users where username = '"+username+"'");
            while (rs.next())
            {
                pwd = rs.getString("pwd");
            }

        } 
        catch (SQLException sqlEx) 
        {
            WMSLoggerFactory.getLogger(null).error("sqlexecuteException: " + sqlEx.toString());
        } 
        finally 
        {
            if (rs != null) 
            {
                try 
                {
                    rs.close();
                } 
                catch (SQLException sqlEx) 
                {

                    rs = null;
                }
            }

            if (stmt != null) 
            {
                try 
                {
                    stmt.close();
                } 
                catch (SQLException sqlEx) 
                {
                    stmt = null;
                }
            }
        }

        conn.close();
    } 
    catch (SQLException ex) 
    {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
    }

    return pwd;
}

public boolean userExists(String username)
{
    // return true is user exists
    return false;
}
}
0

Source: https://habr.com/ru/post/1627925/


All Articles