diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala index 349c9ba9f2b2963f3a2ef8d4e90e6906942b66b7..b081cd31f62c8537b3b224ecef0e1843357329a9 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala @@ -78,6 +78,7 @@ class MeetingActor( with SendTimeRemainingUpdateHdlr with SendBreakoutTimeRemainingMsgHdlr with ChangeLockSettingsInMeetingCmdMsgHdlr + with ValidateConnAuthTokenSysMsgHdlr with SyncGetMeetingInfoRespMsgHdlr with ClientToServerLatencyTracerMsgHdlr { @@ -154,6 +155,7 @@ class MeetingActor( // its type is not BbbCommonEnvCoreMsg case m: RegisterUserReqMsg => usersApp.handleRegisterUserReqMsg(m) case m: GetAllMeetingsReqMsg => handleGetAllMeetingsReqMsg(m) + case m: ValidateConnAuthTokenSysMsg => handleValidateConnAuthTokenSysMsg(m) // Meeting case m: DestroyMeetingSysCmdMsg => handleDestroyMeetingSysCmdMsg(m) diff --git a/bbb-video/build.gradle b/bbb-video/build.gradle index ce293a0c54a7e73de2de1fcbead760f3b41d8edf..f15f48b9d6ffdcb28f187d58c318f0ff281eaeed 100755 --- a/bbb-video/build.gradle +++ b/bbb-video/build.gradle @@ -62,6 +62,7 @@ dependencies { compile 'org.apache.commons:commons-pool2:2.3' compile 'com.google.code.gson:gson:2.5' + compile 'org.apache.commons:commons-lang3:3.5' compile 'org.bigbluebutton:bbb-common-message_2.12:0.0.19-SNAPSHOT' } 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 c69c4a512c5dae22c1d650cdb47386fe279cc234..d15d72c18400fc9f6b44f8079a4f28bf661b299d 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 @@ -40,6 +40,8 @@ import org.red5.server.stream.ClientBroadcastStream; import org.slf4j.Logger; import com.google.gson.Gson; +import org.springframework.util.StringUtils; + import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -90,11 +92,26 @@ public class VideoApplication extends MultiThreadedApplicationAdapter { String userId = ((String) params[1]).toString(); String authToken = ((String) params[2]).toString(); + + if (StringUtils.isEmpty(meetingId)) { + log.error("Invalid meetingId parameter."); + return false; + } + + if (StringUtils.isEmpty(userId)) { + log.error("Invalid userId parameter."); + return false; + } + + if (StringUtils.isEmpty(authToken)) { + log.error("Invalid authToken parameter."); + return false; + } + Red5.getConnectionLocal().setAttribute("MEETING_ID", meetingId); Red5.getConnectionLocal().setAttribute("USERID", userId); Red5.getConnectionLocal().setAttribute("AUTH_TOKEN", authToken); - String connType = getConnectionType(Red5.getConnectionLocal().getType()); String sessionId = Red5.getConnectionLocal().getSessionId(); @@ -246,10 +263,13 @@ public class VideoApplication extends MultiThreadedApplicationAdapter { public void streamBroadcastStart(IBroadcastStream stream) { IConnection conn = Red5.getConnectionLocal(); String contextName = stream.getScope().getName(); - log.info("APP CONTEXT == " + contextName); if ("video".equals(contextName)) { - log.error("Publishing stream in app context."); + /** + * Prevent publishing into the /video context as all our webcams are published + * into /video/<meetingId> context. (ralam jan 22, 2018) + */ + log.error("Publishing stream in app context. Closing connection. stream={}, context={}", stream.getPublishedName(), contextName); conn.close(); return; } diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MeetingMessageHandler.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MeetingMessageHandler.java index 4d67d4475d1d5ed24129e043eaf78e274c7a05b4..e6fb817ee1054b43b5bb60a2cd886ed03b89ce08 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MeetingMessageHandler.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MeetingMessageHandler.java @@ -1,11 +1,15 @@ package org.bigbluebutton.red5.pubsub; +import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.bigbluebutton.app.video.ConnectionInvokerService; import org.bigbluebutton.red5.pubsub.message.ValidateConnTokenRespMsg; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; public class MeetingMessageHandler implements MessageHandler { + private static Logger log = Red5LoggerFactory.getLogger(MeetingMessageHandler.class, "video"); private final String HEADER = "header"; private final String NAME = "name"; @@ -17,7 +21,9 @@ public class MeetingMessageHandler implements MessageHandler { private final String USERID = "userId"; private final String AUTHZED = "authzed"; - private final String CONN = "conn"; + private final String CONN = "connId"; + private final String APP = "app"; + private final String VIDEO_APP = "VIDEO"; private final String RecordingChapterBreakSysMsg = "RecordingChapterBreakSysMsg"; private final String ValidateConnAuthTokenSysRespMsg = "ValidateConnAuthTokenSysRespMsg"; @@ -40,16 +46,25 @@ public class MeetingMessageHandler implements MessageHandler { private void handle(String name, JsonObject body) { if (ValidateConnAuthTokenSysRespMsg.equals(name)) { + Gson gson = new Gson(); + String logStr = gson.toJson(body); + + log.debug("HANDLE: {}", logStr); if (body.has(MEETING_ID) && body.has(USERID) - && body.has(AUTHZED) && body.has(CONN)) { + && body.has(AUTHZED) && body.has(CONN) && body.has(APP)) { String meetingId = body.get(MEETING_ID).getAsString(); String userId = body.get(USERID).getAsString(); Boolean authzed = body.get(AUTHZED).getAsBoolean(); String conn = body.get(CONN).getAsString(); - if (conn.equals("VIDEO")) { + String app = body.get(APP).getAsString(); + + log.debug("PROCESS: {}", name); + if (VIDEO_APP.equals(app)) { ValidateConnTokenRespMsg vctrm = new ValidateConnTokenRespMsg(meetingId, userId, authzed, conn); connInvokerService.sendMessage(vctrm); } + } else { + log.debug("INVALID MSG FORMAT: {}", logStr); } } } diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageReceiver.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageReceiver.java index 98c5973992825f8f8a5f59da9bb8eaf3529bbf9f..e0435bd5b941c8d1c7ab97ad529b427827510711 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageReceiver.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/MessageReceiver.java @@ -1,16 +1,15 @@ package org.bigbluebutton.red5.pubsub; +import org.red5.logging.Red5LoggerFactory; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPubSub; import redis.clients.jedis.exceptions.JedisConnectionException; - import java.util.concurrent.Executor; import java.util.concurrent.Executors; public class MessageReceiver { - private static Logger log = LoggerFactory.getLogger(MessageReceiver.class); + private static Logger log = Red5LoggerFactory.getLogger(MessageReceiver.class, "video"); private ReceivedMessageHandler handler; diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/ReceivedMessageHandler.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/ReceivedMessageHandler.java index 7323f093b562d5d60adf6576cb992a105e4ec900..b7473dd3f849111163441ff33fdb7cce587dabc7 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/ReceivedMessageHandler.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/ReceivedMessageHandler.java @@ -1,15 +1,14 @@ package org.bigbluebutton.red5.pubsub; +import org.red5.logging.Red5LoggerFactory; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; public class ReceivedMessageHandler { - private static Logger log = LoggerFactory.getLogger(ReceivedMessageHandler.class); + private static Logger log = Red5LoggerFactory.getLogger(ReceivedMessageHandler.class, "video"); private BlockingQueue<ReceivedMessage> receivedMessages = new LinkedBlockingQueue<ReceivedMessage>(); diff --git a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/message/ValidateConnTokenRespMsg.java b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/message/ValidateConnTokenRespMsg.java index 10e2c8b09113d2ba158a7a2b6d69d8ad0dfac453..7e0eab561c7b797b73735b64bf0c851bc060cc7a 100755 --- a/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/message/ValidateConnTokenRespMsg.java +++ b/bbb-video/src/main/java/org/bigbluebutton/red5/pubsub/message/ValidateConnTokenRespMsg.java @@ -15,6 +15,6 @@ public class ValidateConnTokenRespMsg implements ClientMessage { } public String getMessageName() { - return "ValidateConnTokenRespMsg"; + return "ValidateConnAuthTokenSysRespMsg"; } } diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as index 501e118685ca4af6e7fb0e5077078ba6a0ed4527..b571279338643d767d5874b6befc40ecf9a9ce57 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/PortTest.as @@ -23,11 +23,13 @@ package org.bigbluebutton.main.model import flash.events.TimerEvent; import flash.net.NetConnection; import flash.net.ObjectEncoding; + import flash.utils.Dictionary; import flash.utils.Timer; - import flash.utils.Dictionary; - import org.bigbluebutton.core.UsersUtil; + import org.as3commons.logging.api.ILogger; import org.as3commons.logging.api.getClassLogger; + import org.bigbluebutton.core.UsersUtil; + import org.bigbluebutton.core.model.LiveMeeting; [Bindable] /** @@ -154,7 +156,9 @@ 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, "portTestDummyAuthToken"); + 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 ec1341728c34e5e6bacc8905f4958650cd80a057..8d40cb9b5ed7a22371829de2f4173405228817e2 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoProxy.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoProxy.as @@ -36,6 +36,7 @@ package org.bigbluebutton.modules.videoconf.business import org.bigbluebutton.core.Options; import org.bigbluebutton.core.UsersUtil; import org.bigbluebutton.core.managers.ReconnectionManager; + import org.bigbluebutton.core.model.LiveMeeting; import org.bigbluebutton.main.api.JSLog; import org.bigbluebutton.main.events.BBBEvent; import org.bigbluebutton.modules.videoconf.events.ConnectedEvent; @@ -82,7 +83,8 @@ package org.bigbluebutton.modules.videoconf.business } public function connect():void { - nc.connect(_url, UsersUtil.getInternalMeetingID(), UsersUtil.getMyUserID()); + var authToken: String = "FOOOOOOO-BARRRR!!!!!!"; //LiveMeeting.inst().me.authToken; + nc.connect(_url, UsersUtil.getInternalMeetingID(), UsersUtil.getMyUserID(), authToken); } private function onAsyncError(event:AsyncErrorEvent):void{