From f0a52664d7f7b4d8b2aaf0f97eeb11af4497aad1 Mon Sep 17 00:00:00 2001 From: Hisham Date: Mon, 12 Nov 2018 18:16:27 +0530 Subject: [PATCH] added user messages in library licence response return --- .../java/com/vocabimate/protocol/ILicenceTo.java | 2 +- .../java/com/vocabimate/protocol/KeyHelper.java | 12 ++++++------ .../protocol/VocabimateHttpUrlConnection.java | 15 +++++++-------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/protocol/src/main/java/com/vocabimate/protocol/ILicenceTo.java b/protocol/src/main/java/com/vocabimate/protocol/ILicenceTo.java index 95343e2daff..0d4df813a83 100644 --- a/protocol/src/main/java/com/vocabimate/protocol/ILicenceTo.java +++ b/protocol/src/main/java/com/vocabimate/protocol/ILicenceTo.java @@ -17,7 +17,7 @@ public interface ILicenceTo extends Serializable { String getLocalEncryptionKey(); String getLocalEncryptionIV(); // this could be null - ILicenceContract getLicence(); + ILicenceWrapperContract getLicenceWrapperContract(); int getVideoId(); Class getLicenceResponseModelClass(); diff --git a/protocol/src/main/java/com/vocabimate/protocol/KeyHelper.java b/protocol/src/main/java/com/vocabimate/protocol/KeyHelper.java index 633e45ddb46..620dcf2ca3a 100644 --- a/protocol/src/main/java/com/vocabimate/protocol/KeyHelper.java +++ b/protocol/src/main/java/com/vocabimate/protocol/KeyHelper.java @@ -12,7 +12,7 @@ public abstract class KeyHelper implements Serializable, ILicenceTo { private String licenceUrl; private String localEncryptionKey; private String localEncryptionIV; - private ILicenceContract licenceContract; + private ILicenceWrapperContract licenceWrapperContract; protected KeyHelper(String m3u8Path, String token, String licenceUrl, String localEncryptionKey, String localEncryptionIV) { this.m3u8Path = m3u8Path; @@ -22,13 +22,13 @@ protected KeyHelper(String m3u8Path, String token, String licenceUrl, String loc this.localEncryptionIV = localEncryptionIV; } - /*package*/ void setLicence(ILicenceContract licence) { - this.licenceContract = licence; + @Override + public ILicenceWrapperContract getLicenceWrapperContract() { + return licenceWrapperContract; } - @Override - public ILicenceContract getLicence() { - return this.licenceContract; + /*package*/ void setLicenceWrapperContract(ILicenceWrapperContract licenceWrapperContract) { + this.licenceWrapperContract = licenceWrapperContract; } @Override diff --git a/protocol/src/main/java/com/vocabimate/protocol/VocabimateHttpUrlConnection.java b/protocol/src/main/java/com/vocabimate/protocol/VocabimateHttpUrlConnection.java index b72d41a8909..89ad00f8932 100644 --- a/protocol/src/main/java/com/vocabimate/protocol/VocabimateHttpUrlConnection.java +++ b/protocol/src/main/java/com/vocabimate/protocol/VocabimateHttpUrlConnection.java @@ -68,21 +68,20 @@ public void connect() throws IOException { ILicenceWrapperContract licenceWrapper = new Gson().fromJson(result, licenceTo.getLicenceResponseModelClass()); InputStream stream; if (licenceWrapper != null) { - ILicenceContract licenseFile = licenceWrapper.getLicenseFile(); - if(licenseFile == null){ - connected = false; - responseCode = 500; - return; - } if(licenceTo instanceof KeyHelper) { - ((KeyHelper)licenceTo).setLicence(licenseFile); + ((KeyHelper)licenceTo).setLicenceWrapperContract(licenceWrapper); } - if(licenseFile.getDecryptionKey() != null) { + ILicenceContract licenseFile = licenceWrapper.getLicenseFile(); + if(licenseFile != null && licenseFile.getDecryptionKey() != null) { TokenDecryptionHelper tokenDecryptionHelper = new TokenDecryptionHelper(token, licenseFile.getDecryptionKey()); byte[] decrypt = tokenDecryptionHelper.decrypt(); stream = new ByteArrayInputStream(decrypt); vocAbsInputStream.setInputStream(stream); } + } else { + connected = false; + responseCode = 500; + return; } } connected = true;