From 4e8f2abbb33693791698cc50d72300ec8d62aef4 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 1 Nov 2017 14:55:48 -0700 Subject: [PATCH] - pass token on video connect --- .../senders/ReceivedJsonMsgHandlerActor.scala | 4 ++++ .../common2/msgs/SystemMsgs.scala | 13 ++++++++++++- .../app/video/VideoApplication.java | 5 +++++ .../red5/pubsub/MessagePublisher.java | 18 +++++++++++++++++- .../red5/pubsub/MessageSender.java | 2 ++ .../org/bigbluebutton/main/model/PortTest.as | 3 ++- .../modules/videoconf/business/VideoProxy.as | 6 +++--- 7 files changed, 45 insertions(+), 6 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala index c730c55e5b..d82dcab66c 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala @@ -297,6 +297,10 @@ class ReceivedJsonMsgHandlerActor( case CreateGroupChatReqMsg.NAME => routeGenericMsg[CreateGroupChatReqMsg](envelope, jsonNode) + case ValidateConnAuthTokenSysMsg.NAME => + println("************** RECEIVED ValidateConnAuthTokenSysMsg.NAME") + routeGenericMsg[ValidateConnAuthTokenSysMsg](envelope, jsonNode) + case _ => log.error("Cannot route envelope name " + envelope.name) // do nothing diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala index fb1dc6af3b..333c95a5d8 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala @@ -128,4 +128,15 @@ case class CheckAlivePongSysMsgBody(system: String, timestamp: Long) object RecordingChapterBreakSysMsg { val NAME = "RecordingChapterBreakSysMsg" } case class RecordingChapterBreakSysMsg(header: BbbCoreHeaderWithMeetingId, body: RecordingChapterBreakSysMsgBody) extends BbbCoreMsg -case class RecordingChapterBreakSysMsgBody(meetingId: String, timestamp: Long) \ No newline at end of file +case class RecordingChapterBreakSysMsgBody(meetingId: String, timestamp: Long) + +object ValidateConnAuthTokenSysMsg { val NAME = "ValidateConnAuthTokenSysMsg" } +case class ValidateConnAuthTokenSysMsg(header: BbbClientMsgHeader, + body: ValidateConnAuthTokenSysMsgBody) extends StandardMsg +case class ValidateConnAuthTokenSysMsgBody(meetingId: String, userId: String, authToken: String, conn: String) + +object ValidateConnAuthTokenSysRespMsg { val NAME = "ValidateConnAuthTokenSysRespMsg" } +case class ValidateConnAuthTokenSysRespMsg(header: BbbCoreHeaderWithMeetingId, + body: ValidateConnAuthTokenSysRespMsgBody) extends BbbCoreMsg +case class ValidateConnAuthTokenSysRespMsgBody(meetingId: String, userId: String, + authToken: String, conn: String, authzed: Boolean) \ No newline at end of file diff --git a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoApplication.java b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoApplication.java index e5232265cd..70675b92dd 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoApplication.java +++ b/bbb-video/src/main/java/org/bigbluebutton/app/video/VideoApplication.java @@ -88,13 +88,18 @@ public class VideoApplication extends MultiThreadedApplicationAdapter { params = new Object[2]; params[0] = "UNKNOWN-MEETING-ID"; params[1] = "UNKNOWN-USER-ID"; + params[2] = "UNKNOWN-AUTH-TOKEN"; } String meetingId = ((String) params[0]).toString(); String userId = ((String) params[1]).toString(); + String authToken = ((String) params[2]).toString(); Red5.getConnectionLocal().setAttribute("MEETING_ID", meetingId); Red5.getConnectionLocal().setAttribute("USERID", userId); + Red5.getConnectionLocal().setAttribute("AUTH_TOKEN", authToken); + + publisher.validateConnAuthToken(meetingId, userId, authToken); String connType = getConnectionType(Red5.getConnectionLocal().getType()); String sessionId = Red5.getConnectionLocal().getSessionId(); diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java index 5b6de28e98..7912b1e916 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessagePublisher.java @@ -8,6 +8,9 @@ import java.util.HashMap; import java.util.Map; import com.google.gson.Gson; +import org.bigbluebutton.common2.msgs.BbbClientMsgHeader; +import org.bigbluebutton.common2.msgs.ValidateConnAuthTokenSysMsg; +import org.bigbluebutton.common2.msgs.ValidateConnAuthTokenSysMsgBody; public class MessagePublisher { @@ -16,7 +19,20 @@ public class MessagePublisher { public void setMessageSender(MessageSender sender) { this.sender = sender; } - + + public void validateConnAuthToken(String meetingId, String userId, String authToken) { + BbbClientMsgHeader header = new BbbClientMsgHeader("ValidateConnAuthTokenSysMsg", meetingId, userId); + ValidateConnAuthTokenSysMsgBody body = new ValidateConnAuthTokenSysMsgBody(meetingId, + userId, authToken, "VIDEO"); + ValidateConnAuthTokenSysMsg msg = new ValidateConnAuthTokenSysMsg(header, body); + Gson gson = new Gson(); + String json = gson.toJson(msg); + + System.out.println("**** SENDING " + json); + + sender.send("to-akka-apps-redis-channel", json); + } + // Polling public void userSharedWebcamMessage(String meetingId, String userId, String streamId) { UserSharedWebcamMessage msg = new UserSharedWebcamMessage(meetingId, userId, streamId); diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageSender.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageSender.java index f650ea3137..307a08244b 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageSender.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageSender.java @@ -79,6 +79,8 @@ public class MessageSender { public void run() { Jedis jedis = redisPool.getResource(); try { + + System.out.println("**** PUBLISH TO " + channel + " msg=" + message); jedis.publish(channel, message); } catch(Exception e){ log.warn("Cannot publish the message to redis", e); diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as index 501e118685..f6b1b6877f 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as @@ -154,7 +154,8 @@ package org.bigbluebutton.main.model var curTime:Number = new Date().getTime(); // Create connection with the server. - nc.connect( this.baseURI, "portTestMeetingId-" + curTime, "portTestDummyUserId-" + curTime); + nc.connect( this.baseURI, "portTestMeetingId-" + curTime, + "portTestDummyUserId-" + curTime, "portTestDummyToken-" + curTime); status = "Connecting..."; } catch( e : ArgumentError ) { // Invalid parameters. diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoProxy.as b/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoProxy.as index ec1341728c..58c7b4c8c1 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoProxy.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoProxy.as @@ -29,14 +29,13 @@ package org.bigbluebutton.modules.videoconf.business import flash.media.H264VideoStreamSettings; import flash.net.NetConnection; import flash.net.NetStream; - import org.as3commons.logging.api.ILogger; import org.as3commons.logging.api.getClassLogger; import org.bigbluebutton.core.BBB; import org.bigbluebutton.core.Options; import org.bigbluebutton.core.UsersUtil; import org.bigbluebutton.core.managers.ReconnectionManager; - import org.bigbluebutton.main.api.JSLog; + import org.bigbluebutton.core.model.LiveMeeting; import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.modules.videoconf.events.ConnectedEvent; import org.bigbluebutton.modules.videoconf.events.StartBroadcastEvent; @@ -82,7 +81,8 @@ package org.bigbluebutton.modules.videoconf.business } public function connect():void { - nc.connect(_url, UsersUtil.getInternalMeetingID(), UsersUtil.getMyUserID()); + nc.connect(_url, UsersUtil.getInternalMeetingID(), + UsersUtil.getMyUserID(), LiveMeeting.inst().me.authToken); } private function onAsyncError(event:AsyncErrorEvent):void{