diff --git a/jicofo/src/main/java/org/jitsi/jicofo/jibri/Utils.java b/jicofo/src/main/java/org/jitsi/jicofo/jibri/Utils.java deleted file mode 100644 index 34a931bcc0..0000000000 --- a/jicofo/src/main/java/org/jitsi/jicofo/jibri/Utils.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright @ 2018-Present 8x8, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jitsi.jicofo.jibri; - -import java.util.*; - -/** - * @author bbaldino - */ -class Utils -{ - /** - * Generated a session id of the given length - * @param length the desired length, in characters, for the session ID - * @return the generated session ID - */ - static String generateSessionId(int length) - { - int leftLimit = 97; // letter 'a' - int rightLimit = 122; // letter 'z' - Random random = new Random(); - StringBuilder buffer = new StringBuilder(length); - for (int i = 0; i < length; i++) { - int randomLimitedInt = leftLimit + (int) - (random.nextFloat() * (rightLimit - leftLimit + 1)); - buffer.append((char) randomLimitedInt); - } - return buffer.toString(); - } -} diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt index 5f16d75f35..434c7c68d1 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/BaseJibri.kt @@ -198,15 +198,6 @@ abstract class BaseJibri internal constructor( else -> StanzaError.getBuilder(StanzaError.Condition.not_allowed).build() } } - - protected fun generateSessionId(): String = Utils.generateSessionId(SESSION_ID_LENGTH) - - companion object { - /** - * The length of the session id field we generate to uniquely identify a Jibri session. - */ - const val SESSION_ID_LENGTH = 16 - } } typealias JibriRequest = IqRequest diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt index 81f54ff58f..e58caabfc1 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriRecorder.kt @@ -32,6 +32,7 @@ import org.jitsi.xmpp.extensions.jibri.RecordingStatus import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jivesoftware.smack.packet.StanzaError +import java.util.* import org.jitsi.jicofo.util.ErrorResponse.create as error /** @@ -101,7 +102,7 @@ class JibriRecorder( // Stream ID should not be provided with requests to record to a file. error(iq, StanzaError.Condition.bad_request, "Stream ID is provided for a FILE recording.") } else { - val sessionId = generateSessionId() + val sessionId = UUID.randomUUID().toString() try { val jibriSession = JibriSession( this, diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt index b013294919..6d98c621c2 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jibri/JibriSipGateway.kt @@ -29,6 +29,7 @@ import org.jitsi.xmpp.extensions.jibri.SipCallState import org.jitsi.xmpp.util.XmlStringBuilderUtil.Companion.toStringOpt import org.jivesoftware.smack.packet.IQ import org.jivesoftware.smack.packet.StanzaError +import java.util.UUID import kotlin.collections.HashMap import org.jitsi.jicofo.util.ErrorResponse.create as error @@ -72,7 +73,7 @@ class JibriSipGateway( get() = ArrayList(sipSessions.values) override fun handleStartRequest(iq: JibriIq): IQ = if (StringUtils.isNotBlank(iq.sipAddress)) { - val sessionId = generateSessionId() + val sessionId = UUID.randomUUID().toString() val jibriSession = JibriSession( this, conference.roomName,