Skip to content

Commit

Permalink
added user messages in library licence response return
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamMuneer committed Nov 12, 2018
1 parent 8f4db5d commit f0a5266
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface ILicenceTo extends Serializable {
String getLocalEncryptionKey();
String getLocalEncryptionIV();
// this could be null
ILicenceContract getLicence();
ILicenceWrapperContract getLicenceWrapperContract();
int getVideoId();
Class<? extends ILicenceWrapperContract> getLicenceResponseModelClass();

Expand Down
12 changes: 6 additions & 6 deletions protocol/src/main/java/com/vocabimate/protocol/KeyHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f0a5266

Please sign in to comment.