diff --git a/README.md b/README.md index 9384f15..4999451 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The backward-incompatible changes compared to the master branch of android-libstorj include: - Account registration is not suppored anymore. App developers should use the Web API to Storj V3 satellites to register new user accounts and obtain API keys. -- The [Keys](android-libstorj/src/main/java/io/storj/libstorj/Keys.java) class changed from using user, password and mnemonic to using API key and encryption key. This is required to reflect the changed key management in Storj V3. +- The [Keys](android-libstorj/src/main/java/io/storj/libstorj/Keys.java) class changed from using user, password and mnemonic to using API key and encryption access. This is required to reflect the changed key management in Storj V3. - Error handling is not as fine-grained as in the previous versions that support Storj V2. App developers should not rely on receiving an adequate error code. In most cases the error code will be either [GENERIC_ERROR](https://github.com/storj/android-libstorj/blob/eeeb26c96c4701912d2c3ef08cd1a844cd042a65/android-libstorj/src/main/java/io/storj/libstorj/Storj.java#L66) or [TRANSFER_CANCELED](https://github.com/storj/android-libstorj/blob/eeeb26c96c4701912d2c3ef08cd1a844cd042a65/android-libstorj/src/main/java/io/storj/libstorj/Storj.java#L71). ## Requirements @@ -17,7 +17,7 @@ Add the Gradle dependency to the `build.gradle` file of the app module: ```Gradle dependencies { - implementation 'io.storj:libstorj-android-v3:0.9.1' + implementation 'io.storj:libstorj-android-v3:0.10.0' } ``` diff --git a/android-libstorj/build.gradle b/android-libstorj/build.gradle index 9c47947..80dd0d1 100644 --- a/android-libstorj/build.gradle +++ b/android-libstorj/build.gradle @@ -6,8 +6,8 @@ android { defaultConfig { minSdkVersion 21 targetSdkVersion 26 - versionCode 13 - versionName "0.9.1" + versionCode 14 + versionName "0.10.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -33,7 +33,7 @@ publish { userOrg = 'kaloyan-raev' groupId = 'io.storj' artifactId = 'libstorj-android-v3' - publishVersion = '0.9.1' + publishVersion = '0.10.0' desc = 'Libstorj for Android (Storj V3 compatible)' website = 'https://github.com/storj/android-libstorj' } @@ -42,5 +42,5 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - implementation 'io.storj:libuplink-android:0.1.1' + implementation 'io.storj:libuplink-android:0.2' } diff --git a/android-libstorj/src/main/java/io/storj/libstorj/Keys.java b/android-libstorj/src/main/java/io/storj/libstorj/Keys.java index 418c102..d668216 100644 --- a/android-libstorj/src/main/java/io/storj/libstorj/Keys.java +++ b/android-libstorj/src/main/java/io/storj/libstorj/Keys.java @@ -21,25 +21,25 @@ * */ public class Keys { private String apiKey; - private String encryptionKey; + private String encryptionAccess; /** * Constructs a new Keys object with the provided credentials. * * @param apiKey * an API key - * @param encryptionKey - * an encryption key + * @param encryptionAccess + * a serialized encryption access */ - public Keys(String apiKey, String encryptionKey) { + public Keys(String apiKey, String encryptionAccess) { this.apiKey = apiKey; - this.encryptionKey = encryptionKey; + this.encryptionAccess = encryptionAccess; } /** @@ -52,11 +52,11 @@ public String getApiKey() { } /** - * Returns the encryption key. + * Returns the serialized encryption access. * - * @return an encryption key + * @return a serialized encryption access */ - public String getEncryptionKey() { - return encryptionKey; + public String getEncryptionContext() { + return encryptionAccess; } } diff --git a/android-libstorj/src/main/java/io/storj/libstorj/Storj.java b/android-libstorj/src/main/java/io/storj/libstorj/Storj.java index 63641ed..701ceed 100644 --- a/android-libstorj/src/main/java/io/storj/libstorj/Storj.java +++ b/android-libstorj/src/main/java/io/storj/libstorj/Storj.java @@ -34,16 +34,16 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import io.storj.libuplink.mobile.BucketAccess; import io.storj.libuplink.mobile.BucketConfig; import io.storj.libuplink.mobile.BucketInfo; import io.storj.libuplink.mobile.BucketList; import io.storj.libuplink.mobile.Config; +import io.storj.libuplink.mobile.EncryptionAccess; import io.storj.libuplink.mobile.ListOptions; +import io.storj.libuplink.mobile.Mobile; import io.storj.libuplink.mobile.ObjectInfo; import io.storj.libuplink.mobile.ObjectList; import io.storj.libuplink.mobile.Project; -import io.storj.libuplink.mobile.ProjectOptions; import io.storj.libuplink.mobile.Reader; import io.storj.libuplink.mobile.ReaderOptions; import io.storj.libuplink.mobile.Uplink; @@ -705,7 +705,7 @@ public Keys getKeys(String passphrase) { return null; } - keys = new Keys(props.getProperty("api-key"), props.getProperty("enc-key")); + keys = new Keys(props.getProperty("api-key"), props.getProperty("enc-ctx")); } return keys; } @@ -728,7 +728,7 @@ public Keys getKeys(String passphrase) { public boolean importKeys(Keys keys, String passphrase) { Properties props = new Properties(); props.setProperty("api-key", keys.getApiKey()); - props.setProperty("enc-key", keys.getEncryptionKey()); + props.setProperty("enc-ctx", keys.getEncryptionContext()); try { props.store(new FileWriter(getAuthFile()), null); @@ -1715,10 +1715,7 @@ private void runInProject(ProjectRunnable runnable) throws Exception { Config config = new Config(); Uplink uplink = new Uplink(config, System.getenv("STORJ_TEMP")); try { - ProjectOptions options = new ProjectOptions(); - options.setEncryptionKey(keys.getEncryptionKey().getBytes()); - - Project project = uplink.openProject(addr, keys.getApiKey(), options); + Project project = uplink.openProject(addr, keys.getApiKey()); try { runnable.run(project); } finally { @@ -1733,9 +1730,8 @@ private void runInBucket(final String bucketId, final BucketRunnable runnable) t runInProject(new ProjectRunnable() { @Override public void run(Project project) throws Exception { - BucketAccess access = new BucketAccess(); - access.setPathEncryptionKey(keys.getEncryptionKey().getBytes()); - io.storj.libuplink.mobile.Bucket bucket = project.openBucket(bucketId, access); + EncryptionAccess encryption = Mobile.parseEncryptionAccess(keys.getEncryptionContext()); + io.storj.libuplink.mobile.Bucket bucket = project.openBucket(bucketId, encryption); try { runnable.run(bucket); } finally {