SDKLauncher-Android
SDKLauncher-Android copied to clipboard
Opening encrypted epubs on android devices.
General Instructions
- Please use a short, but meaningful title.
- Delete everything in italics before submitting issue
- Make sure to fill in as much information as possible
Question
(choose ONE from the above list and delete the others)
Product
Choose one of the following (and delete the others)
- Native application (Readium SDK C++)
- official "launcher" sample OR propietary app
- Android
Additional information
Please list any additional information that might help us
Hi @rahulk11, You question is too vague. Encrypted epubs may mean anything. If it's about epubs protected by a DRM, which DRM? They are old DRM's (Adobe) and modern DRM's (e.g. Readium LCP).
Also, could you please rename your issue with a shorter title (e.g. Opening Readium LCP encrypted epubs), use a Github tag, not "Question" in the title, and provide a first comment with sufficient details?
@llemeurfr I am sorry for the mistake. Any way, i have some epubs encrypted by an algorithm, not protected by DRM. I need to implement the decryption and reading of the books in my app, without storing decrypted files anywhere. How can i achieve it using Readium SDK?
Firstly, you need to follow the EPUB specification to make sure that your publications "declare" which resources (i.e. files within the zip container) are encrypted, and with what algorithm / DRM scheme: http://www.idpf.org/epub/301/spec/epub-ocf.html#sec-container-metainf-encryption.xml
Then, you should explore the notion of "Content Module" and "Content Filter" in the ReadiumSDK architecture, https://github.com/readium/readium-sdk/tree/develop/ePub3/ePub ...and use the concrete open-source LCP implementation as your guide: https://github.com/readium/readium-lcp-client/tree/develop/src/lcp-content-filter
Daniel
@danielweck thanks. i'll look into these
Hi @danielweck , i've checked with the publication and they dont have any plan to include DRM. They just giving me an encrypted epub. Encryption is not done to individual files inside epub, instead, the epub file as a whole has been encrypted using conceal library from facebook.
ReadiumSDK does not support decrypting the publication as a whole (i.e. the EPUB zip archive as a single cypher stream).
The recommended ; and widely implemented ; practice in the electronic publishing industry is to encrypt individual resource within the EPUB package so that some resources remain available as plain text (e.g. essential metadata that reading systems can access prior to loading the full EPUB / prior to reading encrypted resources).
Furthermore, depending on the cypher algorithm, encrypting the zip container as a whole makes it hard ; if not impossible ; to efficiently "stream" data out of the EPUB package (e.g. video/audio files).
So I am afraid you use-case sits outside of the ReadiumSDK's scope.
You can of course decrypt the entire zip file in a separate process, place the output somewhere in a hidden folder on the filesystem, and pass the new file location to ReadiumSDK (in which case we fallback to loading a regular plain-text publication). The problem with that approach is that unless the hidden filesystem location is well protected, this is a weak solution because malicious users could potentially have access to the fully-decrypted version.
@danielweck thank you for your input. However i was thinking if it is possible to provide stream of epub to ReadiumSDK instead of giving it a file path. I've seen something similar in this library I've not tried it yet because it seems very old and abandoned library. Thanks again.
ReadiumSDK (the C++ lib) only support s loading EPUB files from filesystem locations. Behind the scenes, the zip library accesses a low-level system file handle.
How does SDKLauncher-Android project integrate lcp? I did not understand how to integrate the lcp project written in C++ into the readium sdk project. Is there any specific integration document or steps for reference? I want to test https://www.edrlab.org/readium/readium-lcp/testing-readium-lcp-compliant-devices/ on an android device. Is there any trouble to give specific instructions and help? Thank you very much!
@xiaoxiaomuou have you tried compiling + running the feature/lcp
branch?
https://github.com/readium/SDKLauncher-Android/tree/feature/lcp
The Git submodules should be:
- the
develop
branch ofreadium-lcp-client
: https://github.com/readium/readium-lcp-client/tree/develop - the
develop
branch ofreadium-sdk
: https://github.com/readium/readium-sdk/tree/develop - the
develop
branch ofreadium-shared-js
: https://github.com/readium/readium-shared-js/tree/develop
@danielweck I have completely cloned https://github.com/readium/SDKLauncher-Android/tree/feature/lcp, but I encountered an error that I didn't know how to modify during compilation: <Error:error: 'E: /LcpSdkTest/SDKLauncher-Android/readium-sdk/Platform/Android/epub3/libs/DEBUG/armeabi-v7a/libepub3.so', needed by '../../../../build/intermediates/cmake /arm7/debug/obj/armeabi-v7a/liblcp.so', missing and no known rule to make it> Please advise me how to modify the project? Thank you again!
@xiaoxiaomuou yes, sorry the AndroidStudio/Gradle/CMake build system is currently imperfect, you need to make sure that the build output from readium-sdk
(i.e. libepub3.so
and libgnustl_shared.so
) is located in SDKLauncher-Android/readium-sdk/Platform/Android/epub3/libs/DEBUG/armeabi-v7a/
(or x86
instead of armeabi-v7a
, if you are building for the emulator instead of a physical device).
Try the following command line steps and let us know how it goes, please.
The hierarchy of filesystem folders / git repositories should look like:
-
SDKLauncher-Android
(branchfeature/lcp
)-
readium-sdk
(branchdevelop
) -
readium-lcp-client
(branchdevelop
) -
readium-shared-js
(branchdevelop
)
-
-
cd PathToMyCode/
-
git clone --recursive -b develop https://github.com/readium/SDKLauncher-Android.git SDKLauncher-Android
-
cd SDKLauncher-Android
-
git submodule update --init --recursive
-
git checkout feature/lcp && git submodule foreach --recursive "git checkout develop"
-
cd readium-sdk/Platform/Android
- make sure that the file
local.properties
exists with the contents shown below at appendix "A1" -
./gradlew build
- make sure that the generated
readium-sdk
lib (libepub3.so
) is copied into theSDKLauncher-Android/readium-sdk/Platform/Android/epub3/libs
folder, using the following file hierarchy:./DEBUG/armeabi-v7a/libepub3.so
,./DEBUG/armeabi-v7a/libgnustl_shared.so
(same forRELEASE
if you are building for production rather than tests, and also forx86
if you did not disable it inlocal.properties
, as shown in "A1" appendix) -
cd readium-lcp-client/platform/android
- make sure that the file
local.properties
exists with the contents shown below at appendix "A2" -
./gradlew build
- if these command line steps are successful, you should now be able to use AndroidStudio as normal.
Steps 6 to 9 are essential, because building liblcp.so
requires the readium-sdk
(i.e. libepub3.so
) to be precompiled and located in a specific directory structure.
Note that steps 10, 11, 12 are actually optional, next time you can just use AndroidStudio directly. Make sure that the file SDKLauncher-Android/SDKLauncher-Android/local.properties
exists with the contents shown below at appendix "A3".
This confusing situation is an unfortunate consequence of the evolving build system: originally Eclipse shell scripts, then AndroidStudio + Gradle and NDK Makefile invoked externally, then Gradle-experimental internal DSL for NDK/JNI, now Gradle and pure CMake which allows hybrid Java/C++ debugging without the need for Gradle-experimental ... ! Within the next couple of months there will be a refactoring of the build system to only use the latest recommended practice, instead of a combination of techniques. In the meantime, thank you for your understanding, and good luck with building! Let us know if this works for you. Thanks.
Appendix "A1" SDKLauncher-Android/readium-sdk/Platform/Android/local.properties
:
ndk.dir=/PATH/TO/Android/sdk/ndk-bundle
sdk.dir=/PATH/TO/Android/sdk
readium.ndk_experimental=true
readium.ndk_clang=false
readium.ndk_skipARM=false
readium.ndk_skipX86=true
Appendix "A2" SDKLauncher-Android/readium-lcp-client/platform/android/local.properties
:
ndk.dir=/PATH/TO/Android/sdk/ndk-bundle
sdk.dir=/PATH/TO/Android/sdk
readium.ndk_experimental=true
readium.ndk_clang=false
readium.ndk_skipARM=false
readium.ndk_skipX86=true
readium.sdk_lib_dir=/PATH/TO/SDKLauncher-Android/readium-sdk/Platform/Android/epub3/libs/
readium.sdk_include_dir=/PATH/TO/SDKLauncher-Android/readium-sdk/Platform/Android/epub3/include/
Appendix "A3" SDKLauncher-Android/SDKLauncher-Android/local.properties
:
ndk.dir=/PATH/TO/Android/sdk/ndk-bundle
sdk.dir=/PATH/TO/Android/sdk
readium.ndk_experimental=true
readium.ndk_clang=false
readium.ndk_skipARM=false
readium.ndk_skipX86=true
@danielweck my project works fine with "com.android.tools.build:gradle:2.2.3" but now because of playstore restriction i have upgraded project gradle to 'com.android.tools.build:gradle:3.2.1' it compiles fine but after this upgrade licence is not getting decrypted , if (mLicense.isDecrypted()) returns false. can you suggest something.
Do you compile readium-sdk
yourself, and if so with what NDK version?
Do you compile
readium-sdk
yourself, and if so with what NDK version?
Pkg.Revision = 15.2.4203891 is this what you are asking? same ndk was working previously.
Thanks. Would you mind trying with NDK 16.1.4479499
please? This is still an older version compared with the latest available NDK (installed by default by Android Studio), but to my knowledge this is the last compatible version with the readium-sdk
(pre-Clang GCC compiler for the Readium C++ code).
PS: what other changes did you make to the Gradle config? You had to add build "flavors", right? Anything else?
I tried with ndk 16b still same issue. yes i added flavorDimensions "default" in LCP gradle and removed following code from LCP manifest. uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26"
The latest working Gradle (etc) configuration is available in these Pull Requests:
readium-sdk
:
https://github.com/readium/readium-sdk/pull/317
readium-lcp-client
:
https://github.com/readium/readium-lcp-client/pull/49
SDKLauncher-Android
:
https://github.com/readium/SDKLauncher-Android/pull/147
...or if not using readium-sdk
and readium-lcp-client
Git submodules inside SDKLauncher-Android
, but pre-compiled AARs instead:
https://github.com/readium/SDKLauncher-Android/pull/152