- add authorized role to registered user

This commit is contained in:
Richard Alam 2017-04-17 21:23:17 +00:00
parent 262c7250c8
commit b8de0c9231
24 changed files with 112 additions and 162 deletions

View File

@ -60,7 +60,7 @@ libraryDependencies ++= {
"com.google.code.gson" % "gson" % "2.5",
"redis.clients" % "jedis" % "2.7.2",
"org.apache.commons" % "commons-lang3" % "3.2",
"org.bigbluebutton" % "bbb-common-message" % "0.0.18-SNAPSHOT",
"org.bigbluebutton" % "bbb-common-message" % "0.0.19-SNAPSHOT",
"io.spray" %% "spray-json" % "1.3.2"
)
}

View File

@ -32,7 +32,8 @@ public interface IBigBlueButtonInGW {
// Users
void validateAuthToken(String meetingId, String userId, String token, String correlationId, String sessionId);
void registerUser(String roomName, String userid, String username, String role, String externUserID, String authToken, String avatarURL, Boolean guest);
void registerUser(String roomName, String userid, String username, String role, String externUserID,
String authToken, String avatarURL, Boolean guest, Boolean authed);
void userEmojiStatus(String meetingId, String userId, String emojiStatus);
void shareWebcam(String meetingId, String userId, String stream);
void unshareWebcam(String meetingId, String userId, String stream);

View File

@ -12,12 +12,13 @@ import org.bigbluebutton.common.messages.KeepAliveMessage;
import org.bigbluebutton.common.messages.MessageFromJsonConverter;
import org.bigbluebutton.common.messages.MessagingConstants;
import org.bigbluebutton.common.messages.PubSubPingMessage;
import org.bigbluebutton.common.messages.RegisterUserMessage;
import org.bigbluebutton.common.messages.UserConnectedToGlobalAudio;
import org.bigbluebutton.common.messages.UserDisconnectedFromGlobalAudio;
import org.bigbluebutton.common.messages.ValidateAuthTokenMessage;
import org.bigbluebutton.core.api.IBigBlueButtonInGW;
import org.bigbluebutton.messages.CreateMeetingRequest;
import org.bigbluebutton.messages.RegisterUserMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -46,9 +47,13 @@ public class MeetingMessageReceiver implements MessageHandler {
String messageName = header.get("name").getAsString();
if (CreateMeetingRequest.NAME.equals(messageName)) {
Gson gson = new Gson();
CreateMeetingRequest msg = gson.fromJson(message,
CreateMeetingRequest.class);
CreateMeetingRequest msg = gson.fromJson(message, CreateMeetingRequest.class);
bbbGW.handleBigBlueButtonMessage(msg);
} else if (RegisterUserMessage.NAME.equals(messageName)) {
Gson gson = new Gson();
RegisterUserMessage msg = gson.fromJson(message, RegisterUserMessage.class);
bbbGW.registerUser(msg.payload.meetingId, msg.payload.userId, msg.payload.name, msg.payload.role,
msg.payload.extUserId, msg.payload.authToken, msg.payload.avatarUrl, msg.payload.guest);
}
}
}
@ -59,9 +64,6 @@ public class MeetingMessageReceiver implements MessageHandler {
if (msg instanceof EndMeetingMessage) {
EndMeetingMessage emm = (EndMeetingMessage) msg;
bbbGW.endMeeting(emm.meetingId);
} else if (msg instanceof RegisterUserMessage) {
RegisterUserMessage rum = (RegisterUserMessage) msg;
bbbGW.registerUser(rum.meetingID, rum.internalUserId, rum.fullname, rum.role, rum.externUserID, rum.authToken, rum.avatarURL, rum.guest);
} else if (msg instanceof DestroyMeetingMessage) {
DestroyMeetingMessage dmm = (DestroyMeetingMessage) msg;
bbbGW.destroyMeeting(dmm.meetingId);

View File

@ -145,9 +145,11 @@ class BigBlueButtonInGW(
eventBus.publish(BigBlueButtonEvent(meetingId, new ValidateAuthToken(meetingId, userId, token, correlationId, sessionId)))
}
def registerUser(meetingID: String, userID: String, name: String, role: String, extUserID: String, authToken: String, avatarURL: String, guest: java.lang.Boolean): Unit = {
def registerUser(meetingID: String, userID: String, name: String, role: String, extUserID: String,
authToken: String, avatarURL: String, guest: java.lang.Boolean, authed: java.lang.Boolean): Unit = {
val userRole = if (role == "MODERATOR") Role.MODERATOR else Role.VIEWER
eventBus.publish(BigBlueButtonEvent(meetingID, new RegisterUser(meetingID, userID, name, userRole, extUserID, authToken, avatarURL, guest)))
eventBus.publish(BigBlueButtonEvent(meetingID, new RegisterUser(meetingID, userID, name, userRole,
extUserID, authToken, avatarURL, guest, authed)))
}
def sendLockSettings(meetingID: String, userId: String, settings: java.util.Map[String, java.lang.Boolean]) {

View File

@ -77,7 +77,7 @@ case class GetLockSettings(meetingID: String, userId: String) extends InMessage
case class ValidateAuthToken(meetingID: String, userId: String, token: String,
correlationId: String, sessionId: String) extends InMessage
case class RegisterUser(meetingID: String, userID: String, name: String, role: Role,
extUserID: String, authToken: String, avatarURL: String, guest: Boolean) extends InMessage
extUserID: String, authToken: String, avatarURL: String, guest: Boolean, authed: Boolean) extends InMessage
case class UserJoining(meetingID: String, userID: String, authToken: String) extends InMessage
case class UserLeaving(meetingID: String, userID: String, sessionId: String) extends InMessage
case class GetUsers(meetingID: String, requesterID: String) extends InMessage

View File

@ -95,6 +95,7 @@ case class RegisteredUser(
authToken: String,
avatarURL: String,
guest: Boolean,
authed: Boolean,
waitingForAcceptance: Boolean)
case class Voice(

View File

@ -121,7 +121,8 @@ trait UsersApp {
log.info("Register user failed. Mmeeting has ended. meetingId=" + mProps.meetingID + " userId=" + msg.userID)
sendMeetingHasEnded(msg.userID)
} else {
val regUser = new RegisteredUser(msg.userID, msg.extUserID, msg.name, msg.role, msg.authToken, msg.avatarURL, msg.guest, msg.guest)
val regUser = new RegisteredUser(msg.userID, msg.extUserID, msg.name, msg.role, msg.authToken, msg.avatarURL,
msg.guest, msg.authed, msg.guest)
usersModel.addRegisteredUser(msg.authToken, regUser)
log.info("Register user success. meetingId=" + mProps.meetingID + " userId=" + msg.userID + " user=" + regUser)

View File

@ -52,7 +52,7 @@ libraryDependencies ++= {
"com.google.code.gson" % "gson" % "1.7.1",
"redis.clients" % "jedis" % "2.1.0",
"org.apache.commons" % "commons-lang3" % "3.2",
"org.bigbluebutton" % "bbb-common-message" % "0.0.18-SNAPSHOT",
"org.bigbluebutton" % "bbb-common-message" % "0.0.19-SNAPSHOT",
"org.bigbluebutton" % "bbb-fsesl-client" % "0.0.4"
)}

View File

@ -2,7 +2,7 @@ name := "bbb-common-message"
organization := "org.bigbluebutton"
version := "0.0.18-SNAPSHOT"
version := "0.0.19-SNAPSHOT"
// We want to have our jar files in lib_managed dir.
// This way we'll have the right path when we import

View File

@ -3,6 +3,7 @@ package org.bigbluebutton.common.messages;
import java.util.Map;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bigbluebutton.messages.RegisterUserMessage;
public class MessageFromJsonConverter {
@ -27,8 +28,6 @@ public class MessageFromJsonConverter {
return processKeepAlive(payload);
case ActivityResponseMessage.ACTIVITY_RESPONSE:
return processActivityResponseMessage(payload);
case RegisterUserMessage.REGISTER_USER:
return RegisterUserMessage.fromJson(message);
case ValidateAuthTokenMessage.VALIDATE_AUTH_TOKEN:
return processValidateAuthTokenMessage(header, payload);
// return ValidateAuthTokenMessage.fromJson(message);

View File

@ -1,83 +0,0 @@
package org.bigbluebutton.common.messages;
import java.util.HashMap;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class RegisterUserMessage implements IBigBlueButtonMessage {
public static final String REGISTER_USER = "register_user_request";
public final String VERSION = "0.0.1";
public final String meetingID;
public final String internalUserId;
public final String fullname;
public final String role;
public final String externUserID;
public final String authToken;
public final String avatarURL;
public final Boolean guest;
public RegisterUserMessage(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken, String avatarURL, Boolean guest) {
this.meetingID = meetingID;
this.internalUserId = internalUserId;
this.fullname = fullname;
this.role = role;
this.externUserID = externUserID;
this.authToken = authToken;
this.avatarURL = avatarURL;
this.guest = guest;
}
public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, meetingID);
payload.put(Constants.INTERNAL_USER_ID, internalUserId);
payload.put(Constants.NAME, fullname);
payload.put(Constants.ROLE, role);
payload.put(Constants.EXT_USER_ID, externUserID);
payload.put(Constants.AUTH_TOKEN, authToken);
payload.put(Constants.AVATAR_URL, avatarURL);
payload.put(Constants.GUEST, guest.toString());
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(REGISTER_USER, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static RegisterUserMessage fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");
if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (REGISTER_USER.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)
&& payload.has(Constants.NAME)
&& payload.has(Constants.ROLE)
&& payload.has(Constants.USER_ID)
&& payload.has(Constants.EXT_USER_ID)
&& payload.has(Constants.AUTH_TOKEN)
&& payload.has(Constants.GUEST)) {
String meetingID = payload.get(Constants.MEETING_ID).getAsString();
String fullname = payload.get(Constants.NAME).getAsString();
String role = payload.get(Constants.ROLE).getAsString();
String userId = payload.get(Constants.USER_ID).getAsString();
String externUserID = payload.get(Constants.EXT_USER_ID).getAsString();
String authToken = payload.get(Constants.AUTH_TOKEN).getAsString();
String avatarURL = payload.get(Constants.AVATAR_URL).getAsString();
Boolean guest = payload.get(Constants.GUEST).getAsBoolean();
return new RegisterUserMessage(meetingID, userId, fullname, role, externUserID, authToken, avatarURL, guest);
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,44 @@
package org.bigbluebutton.messages;
import java.util.HashMap;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bigbluebutton.common.messages.Constants;
import org.bigbluebutton.common.messages.IBigBlueButtonMessage;
import org.bigbluebutton.common.messages.MessageBuilder;
public class RegisterUserMessage implements IBigBlueButtonMessage {
public static final String NAME = "register_user_request";
public final Header header;
public final Payload payload;
public RegisterUserMessage(Payload payload) {
this.header = new Header(NAME);
this.payload = payload;
}
public static class Payload {
public final String meetingId;
public final String userId;
public final String name;
public final String role;
public final String extUserId;
public final String authToken;
public final String avatarUrl;
public final Boolean guest;
public final Boolean authed;
public Payload(String meetingId, String userId, String name, String role,
String extUserId, String authToken, String avatarUrl, Boolean guest, Boolean authed) {
this.meetingId = meetingId;
this.userId = userId;
this.name = name;
this.role = role;
this.extUserId = extUserId;
this.authToken = authToken;
this.avatarUrl = avatarUrl;
this.guest = guest;
this.authed = authed;
}
}
}

View File

@ -32,7 +32,8 @@ public class UserSession {
public String role = null;
public String conference = null;
public String room = null;
public String guest = "false";
public Boolean guest = false;
public Boolean authed = false;
public String voicebridge = null;
public String webvoiceconf = null;
public String mode = null;

View File

@ -13,6 +13,7 @@ package org.bigbluebutton.core.model
internal var dialNumber:String;
internal var role:String;
internal var guest:Boolean;
internal var authed:Boolean;
internal var customData:Object;
public function MeBuilder(id: String, name: String) {
@ -65,6 +66,11 @@ package org.bigbluebutton.core.model
return this;
}
public function withAuthed(value: Boolean):MeBuilder {
authed = value;
return this;
}
public function withCustomData(value: Object):MeBuilder {
customData = value;
return this;

View File

@ -133,6 +133,7 @@ package org.bigbluebutton.main.model.users
response.internalUserId = result.response.internalUserID;
response.role = result.response.role;
response.guest = result.response.guest;
response.authed = result.response.authed;
response.room = result.response.room;
response.authToken = result.response.authToken;
response.record = result.response.record;
@ -171,7 +172,8 @@ package org.bigbluebutton.main.model.users
.withExternalId(response.externUserID).withToken(response.authToken)
.withLayout(response.defaultLayout).withWelcome(response.welcome)
.withDialNumber(response.dialnumber).withRole(response.role)
.withCustomData(response.customData).withGuest(response.guest.toUpperCase() == "TRUE").build();
.withCustomData(response.customData).withGuest(response.guest)
.withAuthed(response.authed).build();
MeetingModel.getInstance().meeting = new MeetingBuilder(response.conference, response.conferenceName)
.withDefaultLayout(response.defaultLayout).withVoiceConf(response.voiceBridge)

View File

@ -99,7 +99,7 @@ package org.bigbluebutton.main.model.users
UserManager.getInstance().getConference().setMyName(result.username);
UserManager.getInstance().getConference().setMyRole(result.role);
UserManager.getInstance().getConference().setMyRoom(result.room);
UserManager.getInstance().getConference().setGuest(result.guest == "true");
UserManager.getInstance().getConference().setGuest(result.guest);
UserManager.getInstance().getConference().setMyAuthToken(result.authToken);
UserManager.getInstance().getConference().setMyCustomData(result.customdata);
UserManager.getInstance().getConference().setDefaultLayout(result.defaultLayout);
@ -124,7 +124,7 @@ package org.bigbluebutton.main.model.users
_conferenceParameters.isBreakout = result.isBreakout;
_conferenceParameters.conference = result.conference;
_conferenceParameters.username = result.username;
_conferenceParameters.guest = (result.guest.toUpperCase() == "TRUE");
_conferenceParameters.guest = (result.guest);
_conferenceParameters.role = result.role;
_conferenceParameters.room = result.room;
_conferenceParameters.authToken = result.authToken;

View File

@ -24,7 +24,7 @@ dependencies {
compile 'org.apache.poi:poi-ooxml:3.15'
compile 'com.zaxxer:nuprocess:1.1.0'
compile 'org.bigbluebutton:bbb-common-message:0.0.18-SNAPSHOT'
compile 'org.bigbluebutton:bbb-common-message:0.0.19-SNAPSHOT'
compile 'org.bigbluebutton:bbb-common-web:0.0.1-SNAPSHOT'
// Logging

View File

@ -253,11 +253,14 @@ class ApiController {
errors.missingParamError("checksum");
}
String guest;
if (!StringUtils.isEmpty(params.guest) && params.guest.equalsIgnoreCase("true")) {
guest = "true";
} else {
guest = "false";
Boolean guest = false;
if (!StringUtils.isEmpty(params.guest)) {
guest = Boolean.parseBoolean(params.guest)
}
Boolean authenticated = false;
if (!StringUtils.isEmpty(params.auth)) {
authenticated = Boolean.parseBoolean(params.auth)
}
// Do we have a name for the user joining? If none, complain.
@ -451,6 +454,7 @@ class ApiController {
us.record = meeting.isRecord()
us.welcome = meeting.getWelcomeMessage()
us.guest = guest
us.authed = authenticated
us.logoutUrl = meeting.getLogoutUrl();
us.configXML = configxml;
@ -468,7 +472,8 @@ class ApiController {
meetingService.addUserSession(sessionToken, us);
// Register user into the meeting.
meetingService.registerUser(us.meetingID, us.internalUserId, us.fullname, us.role, us.externUserID, us.authToken, us.avatarURL, us.guest)
meetingService.registerUser(us.meetingID, us.internalUserId, us.fullname, us.role, us.externUserID,
us.authToken, us.avatarURL, us.guest, us.authed)
// Validate if the maxParticipants limit has been reached based on registeredUsers. If so, complain.
// when maxUsers is set to 0, the validation is ignored

View File

@ -113,9 +113,9 @@ public class MeetingService implements MessageListener {
public void registerUser(String meetingID, String internalUserId,
String fullname, String role, String externUserID,
String authToken, String avatarURL, String guest) {
String authToken, String avatarURL, Boolean guest, Boolean authed) {
handle(new RegisterUser(meetingID, internalUserId, fullname, role,
externUserID, authToken, avatarURL, guest));
externUserID, authToken, avatarURL, guest, authed));
}
public UserSession getUserSession(String token) {
@ -367,7 +367,7 @@ public class MeetingService implements MessageListener {
private void processRegisterUser(RegisterUser message) {
messagingService.registerUser(message.meetingID,
message.internalUserId, message.fullname, message.role,
message.externUserID, message.authToken, message.avatarURL, message.guest);
message.externUserID, message.authToken, message.avatarURL, message.guest, message.authed);
}
public Meeting getMeeting(String meetingId) {

View File

@ -6,28 +6,13 @@ import org.bigbluebutton.api.messaging.converters.messages.CreateMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.DestroyMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.EndMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.KeepAliveMessage;
import org.bigbluebutton.api.messaging.converters.messages.RegisterUserMessage;
import org.bigbluebutton.api.messaging.converters.messages.PublishRecordingMessage;
import org.bigbluebutton.api.messaging.converters.messages.UnpublishRecordingMessage;
import org.bigbluebutton.api.messaging.converters.messages.DeleteRecordingMessage;
public class MessageToJson {
public static String registerUserToJson(RegisterUserMessage message) {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, message.meetingID);
payload.put(Constants.NAME, message.fullname);
payload.put(Constants.USER_ID, message.internalUserId);
payload.put(Constants.ROLE, message.role);
payload.put(Constants.EXT_USER_ID, message.externUserID);
payload.put(Constants.AUTH_TOKEN, message.authToken);
payload.put(Constants.AVATAR_URL, message.avatarURL);
payload.put(Constants.GUEST, message.guest);
java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(RegisterUserMessage.REGISTER_USER, message.VERSION, null);
return MessageBuilder.buildJson(header, payload);
}
public static String createMeetingMessageToJson(CreateMeetingMessage msg) {
HashMap<String, Object> payload = new HashMap<String, Object>();

View File

@ -40,7 +40,8 @@ public interface MessagingService {
void endMeeting(String meetingId);
void send(String channel, String message);
void sendPolls(String meetingId, String title, String question, String questionType, List<String> answers);
void registerUser(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken, String avatarURL, String guest);
void registerUser(String meetingID, String internalUserId, String fullname, String role, String externUserID,
String authToken, String avatarURL, Boolean guest, Boolean authed);
void sendKeepAlive(String system, Long timestamp);
void sendStunTurnInfo(String meetingId, String internalUserId, Set<StunServer> stuns, Set<TurnEntry> turns);
void publishRecording(String recordId, String meetingId, String externalMeetingId, String format, boolean publish);

View File

@ -28,7 +28,7 @@ import java.util.Set;
import org.bigbluebutton.api.messaging.converters.messages.DestroyMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.EndMeetingMessage;
import org.bigbluebutton.api.messaging.converters.messages.RegisterUserMessage;
import org.bigbluebutton.messages.RegisterUserMessage;
import org.bigbluebutton.api.messaging.converters.messages.PublishRecordingMessage;
import org.bigbluebutton.api.messaging.converters.messages.UnpublishRecordingMessage;
import org.bigbluebutton.api.messaging.converters.messages.DeleteRecordingMessage;
@ -71,10 +71,15 @@ public class RedisMessagingService implements MessagingService {
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}
public void registerUser(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken, String avatarURL, String guest) {
RegisterUserMessage msg = new RegisterUserMessage(meetingID, internalUserId, fullname, role, externUserID, authToken, avatarURL, guest);
String json = MessageToJson.registerUserToJson(msg);
log.info("Sending register user message to bbb-apps:[{}]", json);
public void registerUser(String meetingID, String internalUserId, String fullname, String role,
String externUserID, String authToken, String avatarURL, Boolean guest, Boolean authed) {
RegisterUserMessage.Payload payload = new RegisterUserMessage.Payload(meetingID, internalUserId, fullname, role, externUserID,
authToken, avatarURL, guest, authed);
RegisterUserMessage msg = new RegisterUserMessage(payload);
Gson gson = new Gson();
String json = gson.toJson(msg);
log.info("*****Sending register user message to bbb-apps:[{}]", json);
sender.send(MessagingConstants.TO_MEETING_CHANNEL, json);
}

View File

@ -1,26 +0,0 @@
package org.bigbluebutton.api.messaging.converters.messages;
public class RegisterUserMessage {
public static final String REGISTER_USER = "register_user_request";
public final String VERSION = "0.0.1";
public final String meetingID;
public final String internalUserId;
public final String fullname;
public final String role;
public final String externUserID;
public final String authToken;
public final String avatarURL;
public final String guest;
public RegisterUserMessage(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken, String avatarURL, String guest) {
this.meetingID = meetingID;
this.internalUserId = internalUserId;
this.fullname = fullname;
this.role = role;
this.externUserID = externUserID;
this.authToken = authToken;
this.avatarURL = avatarURL;
this.guest = guest;
}
}

View File

@ -1,5 +1,6 @@
package org.bigbluebutton.api.messaging.messages;
public class RegisterUser implements IMessage {
public final String meetingID;
@ -9,9 +10,11 @@ public class RegisterUser implements IMessage {
public final String externUserID;
public final String authToken;
public final String avatarURL;
public final String guest;
public final Boolean guest;
public final Boolean authed;
public RegisterUser(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken, String avatarURL, String guest) {
public RegisterUser(String meetingID, String internalUserId, String fullname, String role, String externUserID,
String authToken, String avatarURL, Boolean guest, Boolean authed) {
this.meetingID = meetingID;
this.internalUserId = internalUserId;
this.fullname = fullname;
@ -20,5 +23,6 @@ public class RegisterUser implements IMessage {
this.authToken = authToken;
this.avatarURL = avatarURL;
this.guest = guest;
this.authed = authed;
}
}