openvidu-server: KmsManager#generateKmsId

pull/494/head
pabloFuente 2020-05-31 12:40:25 +02:00
parent d1aa03354e
commit 668c879462
2 changed files with 8 additions and 2 deletions

View File

@ -61,8 +61,7 @@ public class FixedOneKmsManager extends KmsManager {
try { try {
List<KmsProperties> kmsProps = new ArrayList<>(); List<KmsProperties> kmsProps = new ArrayList<>();
for (String kmsUri : this.openviduConfig.getKmsUris()) { for (String kmsUri : this.openviduConfig.getKmsUris()) {
String kmsId = IdentifierPrefixes.KMS_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase() String kmsId = KmsManager.generateKmsId();
+ RandomStringUtils.randomAlphanumeric(7);
kmsProps.add(new KmsProperties(kmsId, kmsUri)); kmsProps.add(new KmsProperties(kmsId, kmsUri));
} }
this.initializeKurentoClients(kmsProps, true); this.initializeKurentoClients(kmsProps, true);

View File

@ -34,6 +34,7 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.apache.commons.lang3.RandomStringUtils;
import org.kurento.client.KurentoConnectionListener; import org.kurento.client.KurentoConnectionListener;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -42,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.IdentifierPrefixes;
import io.openvidu.server.utils.MediaNodeStatusManager; import io.openvidu.server.utils.MediaNodeStatusManager;
public abstract class KmsManager { public abstract class KmsManager {
@ -309,4 +311,9 @@ public abstract class KmsManager {
}); });
} }
public static String generateKmsId() {
return IdentifierPrefixes.KMS_ID + RandomStringUtils.randomAlphabetic(1).toUpperCase()
+ RandomStringUtils.randomAlphanumeric(7);
}
} }