java – 使用外部jar的wowza authontication
我在我的项目中使用Wowza流引擎.我用基本身份验证成功启动了wowza.我需要使用我的数据库验证wowza,因为我正在创建一个
java项目.将jar添加到Wowza引擎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 >如何从上面的命令获取用户名和密码到我的方法? 解决方法
Wowza API具有AuthenticateUsernamePasswordProviderBase类,您需要扩展该类以集成数据库身份验证.
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; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 图形没有在JLayeredPane中显示(java swing)
- the resource is not on the build path of a java project
- Spring常用配置及解析类说明
- java – JPA POJO作为数据对象
- java – List无法转换为ArrayList
- java – Rancher模板 – Hadoop主机名中的非法字符
- 是否有免费的工具来描述Java方法的执行时间?
- java – Hibernate @MapKeyColumn和表继承导致Unknown列类型
- java – 使用部署在其中的Web应用程序关闭tomcat
- java – 在构造函数中访问实例成员