Skip to content

Commit f435971

Browse files
author
Karl Rieb
committed
2.0.5 release.
1 parent fdbc62b commit f435971

File tree

52 files changed

+1951
-4149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1951
-4149
lines changed

ChangeLog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2.0.5 (2016-06-08)
2+
---------------------------------------------
3+
- Allow old locale formats for APIv2 requests.
4+
- Fix ExceptionInInitializationError caused by CertificateParsingException when using Java 6 JREs.
5+
- Fix CertPathValidatorException: Trust anchor for certification path not found.
6+
- Add support for OkHttp3.
7+
- Add support for Google App Engine with new GoogleAppEngineRequestor.
8+
- Add support for require_role, force_reapprove, state, and disable_signup parameters in the OAuth 2 web-based authorization flow (DbxWebAuth).
9+
- Enable certificate pinning for OkHttpRequestor and OkHttp3Requestor by default.
10+
111
2.0.4 (2016-05-31)
212
---------------------------------------------
313
- Update to latest API specs:

ReadMe.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you're using Maven, then edit your project's "pom.xml" and add this to the `<
1414
<dependency>
1515
<groupId>com.dropbox.core</groupId>
1616
<artifactId>dropbox-core-sdk</artifactId>
17-
<version>2.0.4</version>
17+
<version>2.0.5</version>
1818
</dependency>
1919
```
2020

@@ -23,7 +23,7 @@ If you are using Gradle, then edit your project's "build.gradle" and add this to
2323
```groovy
2424
dependencies {
2525
// ...
26-
compile 'com.dropbox.core:dropbox-core-sdk:2.0.4'
26+
compile 'com.dropbox.core:dropbox-core-sdk:2.0.5'
2727
}
2828
```
2929

@@ -158,6 +158,13 @@ Another workaround is to tell your OSGi container to provide that requirement: [
158158

159159
### Does this SDK require any special ProGuard rules for shrink optimizations?
160160

161-
Versions 2.0.0-2.0.3 of this SDK require specific ProGuard rules to work with shrinking enabled. However, since version **2.0.4**, the SDK no longer needs special ProGuard directives.
161+
Versions 2.0.0-2.0.3 of this SDK require specific ProGuard rules to work with shrinking enabled. However, since version **2.0.4**, the SDK no longer needs special ProGuard directives. However, you may want to consider adding "-dontwarn" directives for unused optional dependencies:
162+
163+
```
164+
-dontwarn okhttp3.**
165+
-dontwarn com.squareup.okhttp.**
166+
-dontwarn com.google.appengine.**
167+
-dontwarn javax.servlet.**
168+
```
162169

163170
**IMPORTANT: If you are running version 2.0.x before 2.0.3, you should update to the latest Dropbox SDK version to avoid a deserialization bug that can cause Android apps that use ProGuard to crash.**

build.gradle

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import org.gradle.internal.os.OperatingSystem;
2+
13
apply plugin: 'java'
24
apply plugin: 'osgi'
35
apply plugin: 'maven'
6+
apply plugin: 'com.github.ben-manes.versions' // dependencyUpdates task
47

58
description = 'Official Java client library for the Dropbox API.'
69
group = 'com.dropbox.core'
@@ -13,13 +16,15 @@ targetCompatibility = JavaVersion.VERSION_1_6
1316
conf2ScopeMappings.addMapping(1, configurations.compileOnly, 'provided')
1417

1518
ext {
19+
mavenName = 'Official Dropbox Java SDK'
1620
generatedSources = file("$buildDir/generated-sources")
1721
generatedResources = file("$buildDir/generated-resources")
1822
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
1923
basePom = pom {
20-
name = 'Official Dropbox Java SDK'
24+
name = mavenName
2125
artifactId = archivesBaseName
2226
project {
27+
description = description
2328
packaging 'jar'
2429
url 'https://www.dropbox.com/developers/core'
2530

@@ -54,6 +59,7 @@ buildscript {
5459
jcenter()
5560
mavenCentral()
5661
}
62+
5763
dependencies {
5864
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
5965
}
@@ -69,14 +75,21 @@ dependencies {
6975
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
7076

7177
compileOnly 'javax.servlet:servlet-api:2.5'
72-
compileOnly 'com.squareup.okhttp:okhttp:2.7.5'
78+
compileOnly 'com.squareup.okhttp:okhttp:2.7.5' // support both v2 and v3 to avoid
79+
compileOnly 'com.squareup.okhttp3:okhttp:3.3.1' // method count bloat
7380
compileOnly 'com.google.android:android:4.1.1.4'
81+
compileOnly 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
7482

7583
testCompile 'org.testng:testng:6.9.10'
7684
testCompile 'org.mockito:mockito-core:1.10.19'
7785
testCompile 'org.openjdk.jmh:jmh-core:1.12'
7886
testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
87+
testCompile 'com.google.appengine:appengine-api-1.0-sdk:1.9.38'
88+
testCompile 'com.google.appengine:appengine-api-labs:1.9.38'
89+
testCompile 'com.google.appengine:appengine-api-stubs:1.9.38'
90+
testCompile 'com.google.appengine:appengine-testing:1.9.38'
7991
testCompile 'com.squareup.okhttp:okhttp:2.7.5'
92+
testCompile 'com.squareup.okhttp3:okhttp:3.3.1'
8093
}
8194

8295
processResources {
@@ -162,27 +175,29 @@ task integrationTest(type: Test) {
162175

163176
ext {
164177
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
165-
okHttpPropertyName = 'com.dropbox.test.okHttp'
178+
httpRequestorPropertyName = 'com.dropbox.test.httpRequestor'
166179
}
167180

168181
doFirst {
169182
systemProperty authInfoPropertyName, getAuthInfoFile().absolutePath
170-
if (project.hasProperty(okHttpPropertyName)) {
171-
systemProperty okHttpPropertyName, project.property(okHttpPropertyName)
183+
if (project.hasProperty(httpRequestorPropertyName)) {
184+
systemProperty httpRequestorPropertyName, project.property(httpRequestorPropertyName)
172185
}
173186
}
174187
}
175188

176189
javadoc {
177-
title "${project.name} ${project.version} API"
190+
title "${project.mavenName} ${project.version} API"
178191
failOnError true
179192

180193
// JDK 8's javadoc has an on-by-default lint called "missing", which requires that everything
181194
// be documented. Disable this lint because we intentionally don't document some things.
182195
//
183196
// NOTE: ugly hack to set our doclint settings due to strange handling of string options by the
184197
// javadoc task.
185-
options.addBooleanOption "Xdoclint:all,-missing", true
198+
if (JavaVersion.current().isJava8Compatible()) {
199+
options.addBooleanOption "Xdoclint:all,-missing", true
200+
}
186201
options.addStringOption "link", "http://docs.oracle.com/javase/6/docs/api/"
187202
}
188203

@@ -231,9 +246,29 @@ if (project.sourceCompatibility == JavaVersion.VERSION_1_6) {
231246

232247
logger.info("Setting JVM boot classpath to use ${jdkHome}")
233248
project.tasks.withType(JavaCompile) {
234-
options.bootClasspath = "${jdkHome}/jre/lib/rt.jar"
235-
options.bootClasspath += "${sep}${jdkHome}/jre/lib/jsse.jar"
236-
options.bootClasspath += "${sep}${jdkHome}/jre/lib/jce.jar"
249+
def jdkLibs = "${jdkHome}/jre/lib"
250+
def runtimeClasses = "rt.jar"
251+
if (OperatingSystem.current().isMacOsX()) {
252+
jdkLibs = "${jdkHome}/Classes"
253+
runtimeClasses = "classes.jar"
254+
}
255+
options.bootClasspath = "${jdkLibs}/${runtimeClasses}"
256+
options.bootClasspath += "${sep}${jdkLibs}/jsse.jar"
257+
options.bootClasspath += "${sep}${jdkLibs}/jce.jar"
258+
}
259+
}
260+
}
261+
262+
// reject dependencyUpdates candidates with alpha or beta in their names:
263+
dependencyUpdates.resolutionStrategy = {
264+
componentSelection { rules ->
265+
rules.all { ComponentSelection selection ->
266+
boolean rejected = ['alpha', 'beta', 'rc'].any { qualifier ->
267+
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
268+
}
269+
if (rejected) {
270+
selection.reject('Release candidate')
271+
}
237272
}
238273
}
239274
}

examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.dropbox.core.v2.users.FullAccount;
1010

1111
import java.io.IOException;
12-
import java.util.Locale;
1312
import java.util.logging.Level;
1413
import java.util.logging.Logger;
1514

@@ -50,8 +49,7 @@ public static void main(String[] args)
5049
}
5150

5251
// Create a DbxClientV1, which is what you use to make API calls.
53-
String userLocale = Locale.getDefault().toLanguageTag();
54-
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info", userLocale);
52+
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info");
5553
DbxClientV2 dbxClient = new DbxClientV2(requestConfig, authInfo.getAccessToken(), authInfo.getHost());
5654

5755
// Make the /account/info API call.

examples/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ dependencies {
6262
compile 'com.android.support:design:23.1.1'
6363
compile 'com.android.support:recyclerview-v7:23.1.1'
6464
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
65+
// picasso 2.5.2 doesn't have OkHttp3 support (although it exists
66+
// on master). Must use OkHttp v2 and v3 until new picasso release
6567
compile 'com.squareup.picasso:picasso:2.5.2'
66-
compile 'com.squareup.okhttp:okhttp:2.4.0'
68+
compile 'com.squareup.okhttp:okhttp:2.7.5'
69+
compile 'com.squareup.okhttp3:okhttp:3.3.1'
6770
}
6871

6972
apply plugin: 'com.getkeepsafe.dexcount'

examples/android/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# OkHttp and Servlet optional dependencies
2020

2121
-dontwarn okio.**
22+
-dontwarn okhttp3.**
23+
-dontwarn com.google.appengine.**
2224
-dontwarn javax.servlet.**
2325

2426
# Support classes for compatibility with older API versions

examples/android/src/main/java/com/dropbox/core/examples/android/DropboxClientFactory.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.dropbox.core.examples.android;
22

3-
import com.dropbox.core.http.OkHttpRequestor;
4-
import com.dropbox.core.v2.DbxClientV2;
53
import com.dropbox.core.DbxHost;
64
import com.dropbox.core.DbxRequestConfig;
7-
8-
import java.util.Locale;
5+
import com.dropbox.core.http.OkHttp3Requestor;
6+
import com.dropbox.core.v2.DbxClientV2;
97

108
/**
119
* Singleton instance of {@link DbxClientV2} and friends
@@ -16,11 +14,9 @@ public class DropboxClientFactory {
1614

1715
public static void init(String accessToken) {
1816
if (sDbxClient == null) {
19-
String userLocale = Locale.getDefault().toLanguageTag();
20-
DbxRequestConfig requestConfig = new DbxRequestConfig(
21-
"examples-v2-demo",
22-
userLocale,
23-
OkHttpRequestor.INSTANCE);
17+
DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("examples-v2-demo")
18+
.withHttpRequestor(OkHttp3Requestor.INSTANCE)
19+
.build();
2420

2521
sDbxClient = new DbxClientV2(requestConfig, accessToken);
2622
}

examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import com.dropbox.core.DbxException;
77
import com.dropbox.core.DbxRequestConfig;
88
import com.dropbox.core.DbxWebAuth;
9-
import com.dropbox.core.DbxWebAuthNoRedirect;
109
import com.dropbox.core.json.JsonReader;
1110

1211
import java.io.BufferedReader;
13-
import java.io.IOException;
12+
import java.io.File;
1413
import java.io.InputStreamReader;
15-
import java.io.PrintStream;
16-
import java.util.Locale;
14+
import java.io.IOException;
1715
import java.util.logging.Level;
1816
import java.util.logging.Logger;
1917

@@ -61,11 +59,13 @@ public static void main(String[] args) throws IOException {
6159
}
6260

6361
// Run through Dropbox API authorization process
64-
String userLocale = Locale.getDefault().toLanguageTag();
65-
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-authorize", userLocale);
66-
DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(requestConfig, appInfo);
62+
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-authorize");
63+
DbxWebAuth webAuth = new DbxWebAuth(requestConfig, appInfo);
64+
DbxWebAuth.Request webAuthRequest = DbxWebAuth.newRequestBuilder()
65+
.withNoRedirect()
66+
.build();
6767

68-
String authorizeUrl = webAuth.start();
68+
String authorizeUrl = webAuth.authorize(webAuthRequest);
6969
System.out.println("1. Go to " + authorizeUrl);
7070
System.out.println("2. Click \"Allow\" (you might have to log in first).");
7171
System.out.println("3. Copy the authorization code.");
@@ -79,9 +79,9 @@ public static void main(String[] args) throws IOException {
7979

8080
DbxAuthFinish authFinish;
8181
try {
82-
authFinish = webAuth.finish(code);
82+
authFinish = webAuth.finishFromCode(code);
8383
} catch (DbxException ex) {
84-
System.err.println("Error in DbxWebAuth.start: " + ex.getMessage());
84+
System.err.println("Error in DbxWebAuth.authorize: " + ex.getMessage());
8585
System.exit(1); return;
8686
}
8787

@@ -91,9 +91,10 @@ public static void main(String[] args) throws IOException {
9191

9292
// Save auth information to output file.
9393
DbxAuthInfo authInfo = new DbxAuthInfo(authFinish.getAccessToken(), appInfo.getHost());
94+
File output = new File(argAuthFileOutput);
9495
try {
95-
DbxAuthInfo.Writer.writeToFile(authInfo, argAuthFileOutput);
96-
System.out.println("Saved authorization information to \"" + argAuthFileOutput + "\".");
96+
DbxAuthInfo.Writer.writeToFile(authInfo, output);
97+
System.out.println("Saved authorization information to \"" + output.getCanonicalPath() + "\".");
9798
} catch (IOException ex) {
9899
System.err.println("Error saving to <auth-file-out>: " + ex.getMessage());
99100
System.err.println("Dumping to stderr instead:");

examples/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ subprojects {
3636
//
3737
// This is intended to be used by the ./run script and not through gradle directly
3838
task run(type: JavaExec) {
39+
standardInput = System.in
3940
classpath = sourceSets.main.runtimeClasspath
4041
main = "com.dropbox.core.examples.${project.name.replace('-','_')}.Main"
4142
ignoreExitValue true

examples/longpoll/src/main/java/com/dropbox/core/examples/longpoll/Main.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.io.IOException;
2121
import java.net.SocketTimeoutException;
22-
import java.util.Locale;
2322
import java.util.concurrent.TimeUnit;
2423
import java.util.logging.Level;
2524
import java.util.logging.Logger;
@@ -110,9 +109,10 @@ public static void longpoll(DbxAuthInfo auth, String path) throws IOException {
110109
*/
111110
private static DbxClientV2 createClient(DbxAuthInfo auth, StandardHttpRequestor.Config config) {
112111
String clientUserAgentId = "examples-longpoll";
113-
String userLocale = Locale.getDefault().toLanguageTag();
114112
StandardHttpRequestor requestor = new StandardHttpRequestor(config);
115-
DbxRequestConfig requestConfig = new DbxRequestConfig(clientUserAgentId, userLocale, requestor);
113+
DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder(clientUserAgentId)
114+
.withHttpRequestor(requestor)
115+
.build();
116116

117117
return new DbxClientV2(requestConfig, auth.getAccessToken(), auth.getHost());
118118
}

0 commit comments

Comments
 (0)