Skip to content

Commit

Permalink
Prepare v4.10.0 release (#240)
Browse files Browse the repository at this point in the history
* Minor fixes in build.gradle

* Added support for MultiBroadcastTag and MultiArchiveTag (#226)

* Added multiArchiveTag

* Added multiBroadcastTag

* Updated docs

* Removed getMulti*Tag from responses

* Revert "Removed getMulti*Tag from responses"

This reverts commit 6e7f123.

* Docs edits re multiArchive/BroadcastTag.

Co-authored-by: Jeff Swartz <[email protected]>

* Add Experience Composer API (#227)

* Added startRender

* Added listRenders

* Deserialize listRenders response to native List

* Added stopRender & getRender

* Use enum for Render status

* Improved RenderProperties

* Experience composer docs edits ...

And other docs corrections

Co-authored-by: Jeff Swartz <[email protected]>

* Bump dependency versions

* Improved release process.

bump2version is now manual, but release to Nexus is fully automated.

* Ensure version is passed in bumpversion.sh

* Bumped dependencies (including WireMock)

* Bump version: v4.8.0 → v4.8.1

* Update copyright year

* Use wiremock-jre8

* Boost coverage

* Boost coverage

* Disable codecov temporarily

* Revert "Disable codecov temporarily"

This reverts commit 613bff0.

* Add Audio Streamer (lite) API endpoint (#215)

* Added Audio Streamer (lite) endpoint

* Don't include headers or streams if empty in connect request

* Renamed Connect for clarity

* Addressed PR comments

* Fixed failing test

* URI in AudioStreamerConnectionProperties constructor

* Docs edits

* Bumped dependencies (notably WireMock to 2.x)

* Bumped dependencies

* Bump dependency versions (#233)

Improved release process, bumped dependency versions (including WireMock), slightly improved test coverage, updated copyright year, merged main, ready for release v4.8.1.

* Renamed to Audio Connector

* Bumped dependencies

* Added audio connector to README

* Minor docs edits

---------

Co-authored-by: Jeff Swartz <[email protected]>

* Bump version: v4.8.1 → v4.9.0

* Minor docs edit

* Enable custom User-Agent (#238)

* Add end-to-end encryption support (#237)

* Added e2ee support

* Added validation for SessionProperties

* Only include e2ee if true

* Update SessionProperties javadoc

Co-authored-by: Jeff Swartz <[email protected]>

* Minor docs edit

---------

Co-authored-by: Jeff Swartz <[email protected]>

* Bump jackson version

* Bump version: v4.9.0 → v4.10.0

---------

Co-authored-by: Jeff Swartz <[email protected]>
  • Loading branch information
SMadani and jeffswartz authored May 9, 2023
1 parent 74abd63 commit 9e897d1
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
commit = True
tag = False
current_version = v4.9.0
current_version = v4.10.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
serialize =
{major}.{minor}.{patch}-{release}{build}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When you use Maven as your build tool, you can manage dependencies in the `pom.x
<dependency>
<groupId>com.tokbox</groupId>
<artifactId>opentok-server-sdk</artifactId>
<version>4.9.0</version>
<version>4.10.0</version>
</dependency>
```

Expand All @@ -44,7 +44,7 @@ When you use Gradle as your build tool, you can manage dependencies in the `buil

```groovy
dependencies {
compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.9.0'
compile group: 'com.tokbox', name: 'opentok-server-sdk', version: '4.10.0'
}
```

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {

group = 'com.tokbox'
archivesBaseName = 'opentok-server-sdk'
version = '4.9.0'
version = '4.10.0'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"

Expand All @@ -27,7 +27,7 @@ dependencies {
implementation 'commons-lang:commons-lang:2.6'
implementation 'commons-validator:commons-validator:1.7'
implementation 'org.asynchttpclient:async-http-client:2.12.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.0'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bitbucket.b_c:jose4j:0.9.3'
implementation 'io.netty:netty-handler:4.1.89.Final'
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/com/opentok/OpenTok.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.opentok.constants.DefaultUserAgent;
import com.opentok.exception.InvalidArgumentException;
import com.opentok.exception.OpenTokException;
import com.opentok.exception.RequestException;
Expand Down Expand Up @@ -63,9 +64,7 @@ public class OpenTok {
* @param apiSecret Your OpenTok API secret. (See your <a href="https://tokbox.com/account">Vonage Video API account page</a>.)
*/
public OpenTok(int apiKey, String apiSecret) {
this.apiKey = apiKey;
this.apiSecret = apiSecret.trim();
this.client = new HttpClient.Builder(apiKey, apiSecret).build();
this(apiKey, apiSecret, new HttpClient.Builder(apiKey, apiSecret).build());
}

private OpenTok(int apiKey, String apiSecret, HttpClient httpClient) {
Expand Down Expand Up @@ -243,7 +242,7 @@ public String generateToken(String sessionId) throws OpenTokException {
*/
public Session createSession(SessionProperties properties) throws OpenTokException {
final SessionProperties _properties = properties != null ? properties : new SessionProperties.Builder().build();
final Map<String, Collection<String>> params = _properties.toMap();
final Map<String, List<String>> params = _properties.toMap();
final String response = client.createSession(params);

try {
Expand Down Expand Up @@ -991,6 +990,7 @@ public static class Builder {
private int apiKey;
private String apiSecret;
private String apiUrl;
private String appendUserAgent;
private Proxy proxy;
private ProxyAuthScheme proxyAuthScheme;
private String principal;
Expand Down Expand Up @@ -1045,6 +1045,18 @@ public Builder proxy(Proxy proxy, ProxyAuthScheme proxyAuthScheme, String princi
return this;
}

/**
* Append a custom string to the client's User-Agent. This is to enable tracking for custom integrations.
*
* @param appendUserAgent The string to append to the user agent.
*
* @return This Builder with the additional user agent string.
*/
public Builder appendToUserAgent(String appendUserAgent) {
this.appendUserAgent = appendUserAgent;
return this;
}

/**
* Builds the OpenTok object with the settings provided to this
* Builder object.
Expand All @@ -1063,6 +1075,9 @@ public OpenTok build() {
if (requestTimeout != 0) {
clientBuilder.requestTimeoutMS(requestTimeout);
}
if (appendUserAgent != null && !appendUserAgent.trim().isEmpty()) {
clientBuilder.userAgent(DefaultUserAgent.DEFAULT_USER_AGENT+" "+appendUserAgent);
}

return new OpenTok(apiKey, apiSecret, clientBuilder.build());
}
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/opentok/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,13 @@
* to get the session ID.
*/
public class Session {

private String sessionId;
private int apiKey;
private String apiSecret;
private SessionProperties properties;

protected Session(String sessionId, int apiKey, String apiSecret) {
this.sessionId = sessionId;
this.apiKey = apiKey;
this.apiSecret = apiSecret;
this.properties = new SessionProperties.Builder().build();
this(sessionId, apiKey, apiSecret, new SessionProperties.Builder().build());
}

protected Session(String sessionId, int apiKey, String apiSecret, SessionProperties properties) {
Expand Down Expand Up @@ -83,7 +79,6 @@ public SessionProperties getProperties() {
* @see #generateToken(TokenOptions tokenOptions)
*/
public String generateToken() throws OpenTokException {
// NOTE: maybe there should be a static object for the defaultTokenOptions?
return this.generateToken(new TokenOptions.Builder().build());
}

Expand Down
75 changes: 57 additions & 18 deletions src/main/java/com/opentok/SessionProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import com.opentok.exception.InvalidArgumentException;
import org.apache.commons.validator.routines.InetAddressValidator;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.*;


/**
Expand All @@ -23,16 +20,16 @@
* @see OpenTok#createSession(com.opentok.SessionProperties properties)
*/
public class SessionProperties {


private String location;
private MediaMode mediaMode;
private ArchiveMode archiveMode;
private boolean e2ee;

private SessionProperties(Builder builder) {
this.location = builder.location;
this.mediaMode = builder.mediaMode;
this.archiveMode = builder.archiveMode;
this.e2ee = builder.e2ee;
}

/**
Expand All @@ -41,10 +38,10 @@ private SessionProperties(Builder builder) {
* @see SessionProperties
*/
public static class Builder {
private String location = null;
private String location;
private MediaMode mediaMode = MediaMode.RELAYED;
private ArchiveMode archiveMode = ArchiveMode.MANUAL;

private boolean e2ee = false;

/**
* Call this method to set an IP address that the OpenTok servers will use to
Expand Down Expand Up @@ -108,7 +105,7 @@ public Builder mediaMode(MediaMode mediaMode) {
/**
* Call this method to determine whether the session will be automatically archived (<code>ArchiveMode.ALWAYS</code>)
* or not (<code>ArchiveMode.MANUAL</code>).
*
* <p>
* Using an always archived session also requires the routed media mode (<code>MediaMode.ROUTED</code>).
*
* @param archiveMode The Archive mode.
Expand All @@ -120,19 +117,43 @@ public Builder archiveMode(ArchiveMode archiveMode) {
return this;
}

/**
* Enables <a href="https://tokbox.com/developer/guides/end-to-end-encryption">end-to-end encryption</a> for a routed session.
* You must also set {@link #mediaMode(MediaMode)} to {@linkplain MediaMode#ROUTED} when
* calling this method.
*
* @return The SessionProperties.Builder object with the e2ee property set to {@code true}.
*/
public Builder endToEndEncryption() {
this.e2ee = true;
return this;
}

/**
* Builds the SessionProperties object.
*
* @return The SessionProperties object.
*/
public SessionProperties build() {
// Would throw in this case, but would introduce a backwards incompatible change.
//if (this.archiveMode == ArchiveMode.ALWAYS && this.mediaMode != MediaMode.ROUTED) {
// throw new InvalidArgumentException("A session with always archive mode must also have the routed media mode.");
//}
if (this.archiveMode == ArchiveMode.ALWAYS && this.mediaMode != MediaMode.ROUTED) {
throw new IllegalStateException(
"A session with ALWAYS archive mode must also have the ROUTED media mode."
);
}
if (e2ee && mediaMode != MediaMode.ROUTED) {
throw new IllegalStateException(
"A session with RELAYED media mode cannot have end-to-end encryption enabled."
);
}
if (e2ee && archiveMode == ArchiveMode.ALWAYS) {
throw new IllegalStateException(
"A session with ALWAYS archive mode cannot have end-to-end encryption enabled."
);
}
return new SessionProperties(this);
}
}

/**
* The location hint IP address. See {@link SessionProperties.Builder#location(String location)}.
*/
Expand All @@ -158,25 +179,43 @@ public ArchiveMode archiveMode() {
return archiveMode;
}

/**
* Defines whether the session will use
* <a href="https://tokbox.com/developer/guides/end-to-end-encryption">end-to-end encryption</a>.
* See {@link com.opentok.SessionProperties.Builder#endToEndEncryption()}.
*
*
* @return {@code true} if end-to-end encryption is enabled, {@code false} otherwise.
*/
public boolean isEndToEndEncrypted() {
return e2ee;
}

/**
* Returns the session properties as a Map.
*/
public Map<String, Collection<String>> toMap() {
Map<String, Collection<String>> params = new HashMap<>();
public Map<String, List<String>> toMap() {
Map<String, List<String>> params = new HashMap<>();
if (null != location) {
ArrayList<String> valueList = new ArrayList<>();
ArrayList<String> valueList = new ArrayList<>(1);
valueList.add(location);
params.put("location", valueList);
}

ArrayList<String> mediaModeValueList = new ArrayList<>();
ArrayList<String> mediaModeValueList = new ArrayList<>(1);
mediaModeValueList.add(mediaMode.toString());
params.put("p2p.preference", mediaModeValueList);

ArrayList<String> archiveModeValueList = new ArrayList<>();
ArrayList<String> archiveModeValueList = new ArrayList<>(1);
archiveModeValueList.add(archiveMode.toString());
params.put("archiveMode", archiveModeValueList);

if (e2ee) {
ArrayList<String> e2eeValueList = new ArrayList<>(1);
e2eeValueList.add("" + e2ee);
params.put("e2ee", e2eeValueList);
}

return params;
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/opentok/constants/DefaultUserAgent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* OpenTok Java SDK
* Copyright (C) 2023 Vonage.
* http://www.tokbox.com
*
* Licensed under The MIT License (MIT). See LICENSE file for more information.
*/
package com.opentok.constants;

public class DefaultUserAgent {
public static final String DEFAULT_USER_AGENT =
"Opentok-Java-SDK/"+Version.VERSION+" JRE/"+System.getProperty("java.version");
}
2 changes: 1 addition & 1 deletion src/main/java/com/opentok/constants/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
package com.opentok.constants;

public class Version {
public static final String VERSION = "4.9.0";
public static final String VERSION = "4.10.0";
}
32 changes: 18 additions & 14 deletions src/main/java/com/opentok/util/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.opentok.*;
import com.opentok.constants.DefaultApiUrl;
import com.opentok.constants.DefaultUserAgent;
import com.opentok.constants.Version;
import com.opentok.exception.InvalidArgumentException;
import com.opentok.exception.OpenTokException;
Expand All @@ -38,7 +39,6 @@
import java.util.concurrent.Future;

public class HttpClient extends DefaultAsyncHttpClient {

private final String apiUrl;
private final int apiKey;

Expand All @@ -48,17 +48,9 @@ private HttpClient(Builder builder) {
this.apiUrl = builder.apiUrl;
}

public String createSession(Map<String, Collection<String>> params) throws RequestException {
Map<String, List<String>> paramsWithList = null;
if (params != null) {
paramsWithList = new HashMap<>();
for (Entry<String, Collection<String>> entry : params.entrySet()) {
paramsWithList.put(entry.getKey(), new ArrayList<>(entry.getValue()));
}
}

public String createSession(Map<String, List<String>> params) throws RequestException {
Future<Response> request = this.preparePost(this.apiUrl + "/session/create")
.setFormParams(paramsWithList)
.setFormParams(params)
.setHeader("Accept", "application/json") // XML version is deprecated
.execute();

Expand Down Expand Up @@ -1303,6 +1295,7 @@ public static class Builder {
private String principal;
private String password;
private String apiUrl;
private String userAgent = DefaultUserAgent.DEFAULT_USER_AGENT;
private AsyncHttpClientConfig config;
private int requestTimeoutMS;

Expand Down Expand Up @@ -1340,18 +1333,29 @@ public Builder requestTimeoutMS(int requestTimeoutMS) {
return this;
}

/**
* Sets the user agent to a custom value.
*
* @param userAgent The user agent.
*
* @return This Builder with user agent string.
*/
public Builder userAgent(String userAgent) {
this.userAgent = userAgent;
return this;
}

public HttpClient build() {
DefaultAsyncHttpClientConfig.Builder configBuilder = new DefaultAsyncHttpClientConfig.Builder()
.setUserAgent("Opentok-Java-SDK/" + Version.VERSION + " JRE/" + System.getProperty("java.version"))
.setUserAgent(userAgent)
.addRequestFilter(new TokenAuthRequestFilter(apiKey, apiSecret));

if (apiUrl == null) {
apiUrl = DefaultApiUrl.DEFAULT_API_URI;
}

if (proxy != null) {
configBuilder.setProxyServer(createProxyServer(proxy, proxyAuthScheme, principal, password));
}

if (requestTimeoutMS != 0) {
configBuilder.setRequestTimeout(requestTimeoutMS);
}
Expand Down
Loading

0 comments on commit 9e897d1

Please sign in to comment.