mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: same public ID in Token and Connection for insecure participants
parent
ed82ab1241
commit
fe749d40c0
|
@ -227,11 +227,14 @@ public class SessionEventsHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (participant.isRecorderOrSttParticipant()) {
|
||||
// Return if recorder participant
|
||||
if (participant.isRecorderParticipant()) {
|
||||
this.rpcNotificationService.immediatelyCloseRpcSession(participant.getParticipantPrivateId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!participant.isSttParticipant()) {
|
||||
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_NAME_PARAM, participant.getParticipantPublicId());
|
||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_REASON_PARAM, reason != null ? reason.name() : "");
|
||||
|
@ -241,6 +244,10 @@ public class SessionEventsHandler {
|
|||
ProtocolElements.PARTICIPANTLEFT_METHOD, params);
|
||||
}
|
||||
|
||||
CDR.recordParticipantLeft(participant, sessionId, reason);
|
||||
|
||||
}
|
||||
|
||||
if (transactionId != null) {
|
||||
// No response when the participant is forcibly evicted instead of voluntarily
|
||||
// leaving the session
|
||||
|
@ -254,7 +261,6 @@ public class SessionEventsHandler {
|
|||
this.rpcNotificationService.scheduleCloseRpcSession(participant.getParticipantPrivateId(), 10000);
|
||||
}
|
||||
|
||||
CDR.recordParticipantLeft(participant, sessionId, reason);
|
||||
}
|
||||
|
||||
public void onPublishMedia(Participant participant, String streamId, Long createdAt, String sessionId,
|
||||
|
|
|
@ -364,10 +364,13 @@ public abstract class SessionManager {
|
|||
return tokenObj;
|
||||
}
|
||||
|
||||
public Token newTokenForInsecureUser(Session session, String token, ConnectionProperties connectionProperties)
|
||||
throws Exception {
|
||||
public Token newTokenForInsecureUser(Session session, String token, ConnectionProperties connectionProperties,
|
||||
String connectionId) throws Exception {
|
||||
Token tokenObj = new Token(token, session.getSessionId(), connectionProperties,
|
||||
this.coturnCredentialsService.createUser());
|
||||
if (connectionId != null) {
|
||||
tokenObj.setConnectionId(connectionId);
|
||||
}
|
||||
session.storeToken(tokenObj);
|
||||
return tokenObj;
|
||||
}
|
||||
|
@ -444,7 +447,8 @@ public abstract class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
public Participant newSttParticipant(Session session, String participantPrivateId, Token token, String clientMetadata) {
|
||||
public Participant newSttParticipant(Session session, String participantPrivateId, Token token,
|
||||
String clientMetadata) {
|
||||
String sessionId = session.getSessionId();
|
||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||
return newParticipantAux(sessionId, session.getUniqueSessionId(), null, participantPrivateId,
|
||||
|
|
|
@ -1161,7 +1161,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
String token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
|
||||
+ RandomStringUtils.randomAlphanumeric(15);
|
||||
|
||||
this.newTokenForInsecureUser(session, token, connectionProperties);
|
||||
this.newTokenForInsecureUser(session, token, connectionProperties, null);
|
||||
final Token tokenObj = session.consumeToken(token);
|
||||
|
||||
Participant ipcamParticipant = this.newIpcamParticipant(session, rtspConnectionId, tokenObj, location,
|
||||
|
|
|
@ -277,12 +277,6 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
|
||||
if (openviduConfig.isOpenViduSecret(secret)) {
|
||||
|
||||
if (recorder) {
|
||||
generateRecorderParticipant = true;
|
||||
} else if (stt) {
|
||||
generateSttParticipant = true;
|
||||
}
|
||||
|
||||
sessionManager.newInsecureParticipant(participantPrivateId);
|
||||
|
||||
token = IdentifierPrefixes.TOKEN_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
|
||||
|
@ -290,8 +284,17 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
ConnectionProperties connectionProperties = new ConnectionProperties.Builder().type(ConnectionType.WEBRTC)
|
||||
.role(OpenViduRole.SUBSCRIBER).build();
|
||||
|
||||
String connectionId = null;
|
||||
if (recorder) {
|
||||
generateRecorderParticipant = true;
|
||||
connectionId = ProtocolElements.RECORDER_PARTICIPANT_PUBLICID;
|
||||
} else if (stt) {
|
||||
generateSttParticipant = true;
|
||||
connectionId = ProtocolElements.STT_PARTICIPANT_PUBLICID;
|
||||
}
|
||||
|
||||
try {
|
||||
sessionManager.newTokenForInsecureUser(session, token, connectionProperties);
|
||||
sessionManager.newTokenForInsecureUser(session, token, connectionProperties, connectionId);
|
||||
} catch (Exception e) {
|
||||
throw new OpenViduException(Code.TOKEN_CANNOT_BE_CREATED_ERROR_CODE,
|
||||
"Unable to create token for session " + sessionId + ": " + e.getMessage());
|
||||
|
@ -890,9 +893,10 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
// Sanity check: don't call RPC method unless the id checks out
|
||||
Participant participant = sessionManager.getParticipant(sessionId, participantPrivateId);
|
||||
if (participant != null) {
|
||||
errorMsg = "Participant " + participant.getParticipantPublicId() + " is calling method '" + methodName
|
||||
+ "' in session " + sessionId;
|
||||
log.info(errorMsg);
|
||||
if (methodName != "videoData") {
|
||||
log.info("Participant {} is calling method '{}' in session {}",
|
||||
participant.getParticipantPublicId(), methodName, sessionId);
|
||||
}
|
||||
return participant;
|
||||
} else {
|
||||
errorMsg = "Participant with private id " + participantPrivateId + " not found in session " + sessionId
|
||||
|
|
Loading…
Reference in New Issue