我正在使用Wowza流引擎在我的项目。我成功地开始了wowza的基本身份验证。我需要用我的数据库验证wowza,因为我正在创建一个java项目。在我将jar添加到Wowza engine lib文件夹后,它将处理身份验证过程。
这是jar的源代码:
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;
}
}
}
我在conf文件中添加了:
<Module>
<Name>TestWowza</Name>
<Description>Java code for testing wowza</Description>
<Class>com.test.wowza.WowzaTesting</Class>
</Module>
然后重新启动wowza服务器引擎。
我有一些问题:
目前,我正在使用此命令进行实时流“
ffmpeg -i "rtsp://localhost:port/livetest" -vcodec copy -acodec copy -f rtsp "rtsp://username:password@localhost:port/live/livetest
发布于 2016-02-10 18:01:27
我有错过任何步骤吗?
Wowza有您需要扩展的AuthenticateUsernamePasswordProviderBase类,以便集成数据库身份验证。
如何在Wowza身份验证时调用jar文件中的方法?
RTSP身份验证目前在Wowza中的工作方式是指定在应用程序配置(文件的Root/Application/RTP/Authentication/PublishMethod部分)中使用的身份验证方法。这些发布方法是在身份验证配置中定义的。要使用自定义身份验证模块拦截这一点,您需要将Java类作为属性添加到这个Authentication.xml文件中。在Wowza的版本3中,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;
}
}
https://stackoverflow.com/questions/35288349
复制相似问题