Tools release: 1.2.0

This commit is contained in:
Buildbot
2021-04-01 00:27:14 +00:00
parent b16312fa46
commit 86a1b39d68
31 changed files with 1523 additions and 419 deletions

View File

@@ -9,29 +9,24 @@ package(
java_library(
name = "providers",
srcs = glob(["*.java"]),
runtime_deps = [
"@grpc_context//:io_grpc_grpc_context",
"@grpc_netty_all//:io_netty_netty_all",
"@io_perfmark_api//:io_perfmark_perfmark_api",
"@netty_boringssl//:io_netty_netty_tcnative_boringssl_static",
"@open_census//:io_opencensus_opencensus_contrib_http_jetty_client",
"@open_census_api//:io_opencensus_opencensus_api",
"@open_census_grpc_metrics//:io_opencensus_opencensus_contrib_grpc_metrics",
"@open_census_util//:io_opencensus_opencensus_contrib_http_util",
],
deps = [
":libwvpl_cas_proxy_sdk_lib.jar",
"//google/chrome/widevine/contentpartners/v1beta1:device_security_profiles_java_proto",
"//google/chrome/widevine/contentpartners/v1beta1:published_devices_grpc",
"//google/chrome/widevine/contentpartners/v1beta1:published_devices_java_proto",
"//httpclient",
"//interfaces",
"@google_guice//:com_google_inject_guice",
"@json//:org_json_json",
"@jsr305_annotations//:com_google_code_findbugs_jsr305",
"@com_google_protobuf//:protobuf_java",
"@google_guava//:com_google_guava_guava",
"@grpc_core//:io_grpc_grpc_core",
"@grpc_netty//:io_grpc_grpc_netty",
"@grpc_stub//:io_grpc_grpc_stub",
"@io_grpc_grpc_java//api",
"@io_grpc_grpc_java//netty",
"@io_grpc_grpc_java//protobuf",
"@io_grpc_grpc_java//stub",
"@maven//:com_google_api_grpc_proto_google_common_protos",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_code_gson_gson",
],
)

View File

@@ -2,13 +2,18 @@
package com.google.video.widevine.jts.providers;
import com.google.chrome.widevine.contentpartners.v1beta1.DeviceSecurityProfileCriteria;
import com.google.chrome.widevine.contentpartners.v1beta1.ListDeviceSecurityProfilesRequest;
import com.google.chrome.widevine.contentpartners.v1beta1.PublishedDevices;
import com.google.chrome.widevine.contentpartners.v1beta1.PublishedDevicesRequest;
import com.google.chrome.widevine.contentpartners.v1beta1.PublishedDevicesServiceGrpc;
import com.google.chrome.widevine.contentpartners.v1beta1.SignedDeviceSecurityProfiles;
import com.google.inject.Inject;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.TextFormat;
import com.google.video.widevine.jts.httpclient.Credentials;
import com.google.video.widevine.jts.interfaces.DeviceCertificate;
import com.google.video.widevine.jts.interfaces.DeviceSecurityProfile;
import com.google.video.widevine.sdk.wvpl.WvPLBaseEnvironment;
import com.google.video.widevine.sdk.wvpl.WvPLStatusException;
import io.grpc.ManagedChannel;
@@ -19,18 +24,22 @@ import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/**
* Provides the latest {@code PublishedDevices} data from the Widevine Published Devices Service.
* Provides the latest {@code PublishedDevices} or {@code SignedDeviceSecurityProfiles} data from
* the Widevine Published Devices Service.
*
* This implementation uses the Widevine Published Devices API, and support a gRPC method for
* retrieving PublishedDevices with an embedded Published Devices list.
* <p>This implementation uses the Widevine Published Devices API, and support a gRPC method for
* retrieving PublishedDevices with an embedded Published Devices list, or Device Security Profiles
* list.
*/
public class PublishedDevicesProvider implements DeviceCertificate {
public class PublishedDevicesProvider implements DeviceCertificate, DeviceSecurityProfile {
private static final Logger logger = Logger.getLogger(PublishedDevicesProvider.class.getName());
private WvPLBaseEnvironment<?> environment = null;
private String apiServicePath = null;
private Credentials credentials = null;
private String provider = null;
/**
* PublishedDevicesProvider constructor.
@@ -38,15 +47,21 @@ public class PublishedDevicesProvider implements DeviceCertificate {
* @param environment A WvPLBaseEnvironment object initialized with a Service Certificate.
* @param serviceAccountPath Path to a GCP Service Account json file, used in OAUTH.
* @param apiServicePath Path to a Widevine Published Devices API service.
* @param provider Provider name, necessary for creating ListDSP request. It could be null if it
* is not used by dsps.
* @throws IOException upon failure creating OAUTH credentials.
*/
@Inject
public PublishedDevicesProvider(
WvPLBaseEnvironment<?> environment, String serviceAccountPath, String apiServicePath)
WvPLBaseEnvironment<?> environment,
String serviceAccountPath,
String apiServicePath,
@Nullable String provider)
throws IOException {
this.environment = environment;
this.apiServicePath = apiServicePath;
credentials = new Credentials(serviceAccountPath);
this.provider = provider;
}
/**
@@ -57,7 +72,7 @@ public class PublishedDevicesProvider implements DeviceCertificate {
* @throws WvPLStatusException upon WvPLBaseEnvironment errors.
*/
@Override
public PublishedDevices getPublishedDevices() throws InterruptedException, WvPLStatusException{
public PublishedDevices getPublishedDevices() throws InterruptedException, WvPLStatusException {
ManagedChannel channel = null;
PublishedDevices devicesResponse = null;
@@ -70,10 +85,20 @@ public class PublishedDevicesProvider implements DeviceCertificate {
PublishedDevicesServiceGrpc.PublishedDevicesServiceBlockingStub blockingStub =
PublishedDevicesServiceGrpc.newBlockingStub(channel)
.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata));
devicesResponse = blockingStub.getPublishedDevices(PublishedDevicesRequest.parseFrom(
environment.generateDeviceStatusListRequest()));
logger.log(Level.INFO, "GRPC Call to PublishedDevicesService.GetSignedList returned:\n %s"
+ TextFormat.printer().printToString(devicesResponse));
devicesResponse =
blockingStub.getPublishedDevices(
PublishedDevicesRequest.parseFrom(
environment.generateDeviceStatusListRequest(),
ExtensionRegistry.getEmptyRegistry()));
String truncatedLogString = TextFormat.printer().printToString(devicesResponse);
int tenLines = 800;
if (truncatedLogString.length() > tenLines) {
truncatedLogString = truncatedLogString.substring(0, tenLines) + "...";
}
logger.log(
Level.INFO,
"GRPC Call to PublishedDevicesService.GetPublishedDevices returned:\n %s"
+ truncatedLogString);
} catch (IOException e) {
logger.log(Level.INFO, "IOException encountered trying to retrieve the signed list: " + e);
} finally {
@@ -85,6 +110,50 @@ public class PublishedDevicesProvider implements DeviceCertificate {
return devicesResponse;
}
@Override
public SignedDeviceSecurityProfiles getSignedDeviceSecurityProfiles()
throws InterruptedException, WvPLStatusException {
// Generate list dsp request.
ListDeviceSecurityProfilesRequest listDspRequest =
ListDeviceSecurityProfilesRequest.newBuilder()
.setDeviceSecurityProfileCriteria(
DeviceSecurityProfileCriteria.newBuilder()
.setContentProvider(this.provider)
.build())
.build();
ManagedChannel channel = null;
SignedDeviceSecurityProfiles signedMessageInResponse = null;
logger.log(Level.INFO, "Getting DeviceSecurityProfilesList...");
try {
channel = createRpcChannel(apiServicePath);
Metadata metadata = new Metadata();
String token = "Bearer " + credentials.getAccessToken();
metadata.put(Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER), token);
PublishedDevicesServiceGrpc.PublishedDevicesServiceBlockingStub blockingStub =
PublishedDevicesServiceGrpc.newBlockingStub(channel)
.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata));
signedMessageInResponse =
blockingStub.listDeviceSecurityProfiles(listDspRequest).getSignedDeviceSecurityProfiles();
logger.log(
Level.INFO,
"GRPC Call to PublishedDevicesService.ListDeviceSecurityProfiles returned:\n %s"
+ TextFormat.printer().printToString(signedMessageInResponse));
} catch (IOException e) {
logger.log(
Level.INFO, "IOException encountered trying to retrieve the signed dsp list: " + e);
} finally {
if (channel != null) {
channel.shutdown();
channel.awaitTermination(1, TimeUnit.SECONDS);
}
}
return signedMessageInResponse;
}
private static ManagedChannel createRpcChannel(String host) {
return NettyChannelBuilder.forTarget(host).build();
}