Merge "Avoid passing device ID when unused"
This commit is contained in:
@@ -26,10 +26,8 @@ class ClientIdentification {
|
||||
|
||||
// Use in conjunction with license requests
|
||||
// |client_token| must be provided
|
||||
// |device_id| optional
|
||||
// |crypto_session| input parameter, mandatory
|
||||
CdmResponseType Init(const std::string& client_token,
|
||||
const std::string& device_id,
|
||||
CryptoSession* crypto_session);
|
||||
|
||||
// Fill the ClientIdentification portion of the license or provisioning
|
||||
@@ -53,7 +51,6 @@ class ClientIdentification {
|
||||
|
||||
bool is_license_request_;
|
||||
std::string client_token_;
|
||||
std::string device_id_;
|
||||
CryptoSession* crypto_session_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(ClientIdentification);
|
||||
|
||||
@@ -39,8 +39,7 @@ class CdmLicense {
|
||||
virtual ~CdmLicense();
|
||||
|
||||
virtual bool Init(const std::string& client_token,
|
||||
CdmClientTokenType client_token_type,
|
||||
const std::string& device_id, bool use_privacy_mode,
|
||||
CdmClientTokenType client_token_type, bool use_privacy_mode,
|
||||
const std::string& signed_service_certificate,
|
||||
CryptoSession* session, PolicyEngine* policy_engine);
|
||||
|
||||
@@ -140,7 +139,6 @@ class CdmLicense {
|
||||
std::string server_url_;
|
||||
std::string client_token_;
|
||||
CdmClientTokenType client_token_type_;
|
||||
std::string device_id_;
|
||||
const CdmSessionId session_id_;
|
||||
std::unique_ptr<InitializationData> stored_init_data_;
|
||||
bool initialized_;
|
||||
|
||||
@@ -228,7 +228,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
if (!Properties::GetServiceCertificate(session_id_, &service_certificate))
|
||||
service_certificate.clear();
|
||||
|
||||
if (!license_parser_->Init(client_token, client_token_type, serial_number,
|
||||
if (!license_parser_->Init(client_token, client_token_type,
|
||||
Properties::UsePrivacyMode(session_id_),
|
||||
service_certificate, crypto_session_.get(),
|
||||
policy_engine_.get()))
|
||||
|
||||
@@ -20,7 +20,6 @@ const std::string kKeyArchitectureName = "architecture_name";
|
||||
const std::string kKeyDeviceName = "device_name";
|
||||
const std::string kKeyProductName = "product_name";
|
||||
const std::string kKeyBuildInfo = "build_info";
|
||||
const std::string kKeyDeviceId = "device_id";
|
||||
const std::string kKeyWvCdmVersion = "widevine_cdm_version";
|
||||
const std::string kKeyOemCryptoSecurityPatchLevel =
|
||||
"oem_crypto_security_patch_level";
|
||||
@@ -50,7 +49,6 @@ CdmResponseType ClientIdentification::Init(CryptoSession* crypto_session) {
|
||||
}
|
||||
|
||||
CdmResponseType ClientIdentification::Init(const std::string& client_token,
|
||||
const std::string& device_id,
|
||||
CryptoSession* crypto_session) {
|
||||
if (crypto_session == nullptr) {
|
||||
LOGE("Crypto session not provided");
|
||||
@@ -63,7 +61,6 @@ CdmResponseType ClientIdentification::Init(const std::string& client_token,
|
||||
}
|
||||
|
||||
is_license_request_ = true;
|
||||
device_id_ = device_id;
|
||||
client_token_ = client_token;
|
||||
crypto_session_ = crypto_session;
|
||||
return NO_ERROR;
|
||||
|
||||
@@ -202,7 +202,7 @@ CdmLicense::~CdmLicense() {}
|
||||
|
||||
bool CdmLicense::Init(const std::string& client_token,
|
||||
CdmClientTokenType client_token_type,
|
||||
const std::string& device_id, bool use_privacy_mode,
|
||||
bool use_privacy_mode,
|
||||
const std::string& signed_service_certificate,
|
||||
CryptoSession* session, PolicyEngine* policy_engine) {
|
||||
if (!clock_) {
|
||||
@@ -233,7 +233,6 @@ bool CdmLicense::Init(const std::string& client_token,
|
||||
|
||||
client_token_ = client_token;
|
||||
client_token_type_ = client_token_type;
|
||||
device_id_ = device_id;
|
||||
crypto_session_ = session;
|
||||
policy_engine_ = policy_engine;
|
||||
use_privacy_mode_ = use_privacy_mode;
|
||||
@@ -1047,7 +1046,7 @@ CdmResponseType CdmLicense::PrepareClientId(
|
||||
const CdmAppParameterMap& app_parameters,
|
||||
const std::string& provider_client_token, LicenseRequest* license_request) {
|
||||
wvcdm::ClientIdentification id;
|
||||
CdmResponseType status = id.Init(client_token_, device_id_, crypto_session_);
|
||||
CdmResponseType status = id.Init(client_token_, crypto_session_);
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
video_widevine::ClientIdentification* client_id =
|
||||
|
||||
@@ -164,9 +164,8 @@ class MockCdmLicense : public CdmLicense {
|
||||
public:
|
||||
MockCdmLicense(const CdmSessionId& session_id) : CdmLicense(session_id) {}
|
||||
|
||||
MOCK_METHOD7(Init,
|
||||
bool(const std::string&, CdmClientTokenType, const std::string&,
|
||||
bool, const std::string&, CryptoSession*, PolicyEngine*));
|
||||
MOCK_METHOD6(Init, bool(const std::string&, CdmClientTokenType, bool,
|
||||
const std::string&, CryptoSession*, PolicyEngine*));
|
||||
MOCK_METHOD0(provider_session_token, std::string());
|
||||
};
|
||||
|
||||
@@ -225,8 +224,8 @@ TEST_F(CdmSessionTest, InitWithBuiltInCertificate) {
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString), false,
|
||||
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), false, Eq(kEmptyString),
|
||||
Eq(crypto_session_), Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
@@ -252,8 +251,8 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString), false,
|
||||
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), false, Eq(kEmptyString),
|
||||
Eq(crypto_session_), Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
@@ -279,8 +278,8 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString), false,
|
||||
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), false, Eq(kEmptyString),
|
||||
Eq(crypto_session_), Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init(nullptr));
|
||||
@@ -336,8 +335,8 @@ TEST_F(CdmSessionTest, UpdateUsageEntry) {
|
||||
EXPECT_CALL(*crypto_session_, GetUsageTableHeader())
|
||||
.WillOnce(Return(&usage_table_header_));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), Eq(kEmptyString), false,
|
||||
Eq(kEmptyString), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
Init(Eq(kToken), Eq(kClientTokenDrmCert), false, Eq(kEmptyString),
|
||||
Eq(crypto_session_), Eq(policy_engine_)))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
// Set up mocks and expectations for the UpdateUsageEntryInformation call.
|
||||
|
||||
@@ -245,21 +245,21 @@ TEST_F(CdmLicenseTest, InitSuccess) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, kEmptyString,
|
||||
false, kEmptyServiceCertificate,
|
||||
crypto_session_, policy_engine_));
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, false,
|
||||
kEmptyServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
}
|
||||
|
||||
TEST_F(CdmLicenseTest, InitFail_EmptyToken) {
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init("", kClientTokenDrmCert, "", false,
|
||||
EXPECT_FALSE(cdm_license_->Init("", kClientTokenDrmCert, false,
|
||||
kEmptyServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
}
|
||||
|
||||
TEST_F(CdmLicenseTest, InitFail_CryptoSessionNull) {
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", false,
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, false,
|
||||
kEmptyServiceCertificate, nullptr,
|
||||
policy_engine_));
|
||||
}
|
||||
@@ -268,7 +268,7 @@ TEST_F(CdmLicenseTest, InitFail_PolicyEngineNull) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", false,
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, false,
|
||||
kEmptyServiceCertificate, crypto_session_,
|
||||
nullptr));
|
||||
}
|
||||
@@ -277,7 +277,7 @@ TEST_F(CdmLicenseTest, InitWithEmptyServiceCert) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", true,
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, true,
|
||||
kEmptyServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
}
|
||||
@@ -286,7 +286,7 @@ TEST_F(CdmLicenseTest, InitWithInvalidServiceCert) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", true,
|
||||
EXPECT_FALSE(cdm_license_->Init(kToken, kClientTokenDrmCert, true,
|
||||
kInvalidServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
}
|
||||
@@ -295,7 +295,7 @@ TEST_F(CdmLicenseTest, InitWithServiceCert) {
|
||||
EXPECT_CALL(*crypto_session_, IsOpen()).WillOnce(Return(true));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, "", true,
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, true,
|
||||
kDefaultServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
}
|
||||
@@ -330,9 +330,9 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) {
|
||||
Return(NO_ERROR)));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, kEmptyString,
|
||||
true, kDefaultServiceCertificate,
|
||||
crypto_session_, policy_engine_));
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, true,
|
||||
kDefaultServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
|
||||
CdmAppParameterMap app_parameters;
|
||||
CdmKeyMessage signed_request;
|
||||
@@ -457,9 +457,9 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) {
|
||||
Return(NO_ERROR)));
|
||||
|
||||
CreateCdmLicense();
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, kEmptyString,
|
||||
true, kDefaultServiceCertificate,
|
||||
crypto_session_, policy_engine_));
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, true,
|
||||
kDefaultServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
|
||||
CdmAppParameterMap app_parameters;
|
||||
CdmKeyMessage signed_request;
|
||||
@@ -600,9 +600,9 @@ TEST_P(CdmLicenseEntitledKeyTest, LoadsEntitledKeys) {
|
||||
|
||||
// Set up the CdmLicense with the mocks and fake entitlement key
|
||||
CreateCdmLicense();
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, kEmptyString,
|
||||
true, kDefaultServiceCertificate,
|
||||
crypto_session_, policy_engine_));
|
||||
EXPECT_TRUE(cdm_license_->Init(kToken, kClientTokenDrmCert, true,
|
||||
kDefaultServiceCertificate, crypto_session_,
|
||||
policy_engine_));
|
||||
cdm_license_->set_entitlement_keys(entitlement_license);
|
||||
|
||||
// Call the function under test and check its return value
|
||||
|
||||
Reference in New Issue
Block a user