X Tutup
Skip to content

Commit c4254c3

Browse files
committed
switch to java 9+ (from java 7 only) for compilation. Runtime is still java 7+. Complement README with links and RFC descriptions.
1 parent f69dbb2 commit c4254c3

File tree

10 files changed

+87
-53
lines changed

10 files changed

+87
-53
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ OAuthService service = new ServiceBuilder(YOUR_API_KEY)
1818
That **single line** (added newlines for readability) is the only thing you need to configure ScribeJava with LinkedIn's OAuth API for example.
1919

2020
Working runnable examples are [here](https://github.com/scribejava/scribejava/tree/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples)
21+
Common usage: [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20Example.java)
2122

2223
### Threadsafe
2324

@@ -26,17 +27,27 @@ Hit ScribeJava as hard and with many threads as you like.
2627
### Java 7 compatible
2728

2829
That's it. You can use it in old environments and in android apps.
30+
note: To compile from sources you will need Java 9 or newer
2931

3032
### Async and other HTTP clients
3133

3234
ScribeJava support out-of-box several HTTP clients:
33-
* ning async http client 1.9.x (maven module scribejava-httpclient-ning)
34-
* Async Http Client asynchttpclient 2.x (maven module scribejava-httpclient-ahc)
35-
* OkHttp (maven module scribejava-httpclient-okhttp)
36-
* Apache HttpComponents HttpClient (maven module scribejava-httpclient-apache)
35+
* ning async http client 1.9.x (maven module scribejava-httpclient-ning) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncNingExample.java)
36+
* Async Http Client asynchttpclient 2.x (maven module scribejava-httpclient-ahc) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20AsyncAHCExample.java)
37+
* OkHttp (maven module scribejava-httpclient-okhttp) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/GitHubAsyncOkHttpExample.java)
38+
* Apache HttpComponents HttpClient (maven module scribejava-httpclient-apache) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FacebookAsyncApacheExample.java)
39+
* any externally created HTTP client [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteExternalHttpExample.java)
3740

3841
just add corresponding maven modules to your pom
3942

43+
### Supports many flows and additional features
44+
45+
* RFC 6749 The OAuth 2.0 Authorization Framework, Authorization Code Authorization Grant [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20Example.java)
46+
* RFC 6749 The OAuth 2.0 Authorization Framework, Client Credentials Authorization Grant [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java)
47+
* RFC 6749 The OAuth 2.0 Authorization Framework, Resource Owner Password Credentials Authorization Grant
48+
* RFC 7636 Proof Key for Code Exchange by OAuth Public Clients (PKCE) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20WithPKCEExample.java)
49+
* RFC 7009 OAuth 2.0 Token Revocation [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20RevokeExample.java)
50+
4051
### Supports all major 1.0a and 2.0 OAuth APIs out-of-the-box
4152

4253
* Automatic (https://www.automatic.com/)

changelog

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[SNAPSHOT]
22
* make redirect_uri optional while Access Token requesting on OAuth 2.0 (thanks to https://github.com/computerlove)
3+
* switch to java 9+ (from java 7 only) for compilation. Runtime is still java 7+. Complement README with links and RFC descriptions.
34

45
[5.6.0]
56
* remove support for obsolete NetEase (http://www.163.com/) and sohu 搜狐 (http://www.sohu.com/) (thanks to https://github.com/zawn)
@@ -205,8 +206,7 @@
205206

206207
[2.0]
207208
* merge back SubScribe fork to the ScribeJava
208-
209+
209210
for previous changes see
210211
v1-changelog - changelog for 1.x version
211212
v2pre-changelog - changelog for SubScribe fork
212-

pom.xml

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
<connection>scm:git:git://github.com/scribejava/scribejava.git</connection>
3535
<developerConnection>scm:git:git@github.com:scribejava/scribejava.git</developerConnection>
3636
<url>https://github.com/scribejava/scribejava</url>
37-
<tag>HEAD</tag>
38-
</scm>
37+
<tag>HEAD</tag>
38+
</scm>
3939

4040
<developers>
4141
<developer>
@@ -78,7 +78,7 @@
7878
<plugin>
7979
<groupId>org.apache.felix</groupId>
8080
<artifactId>maven-bundle-plugin</artifactId>
81-
<version>3.5.1</version>
81+
<version>4.0.0</version>
8282
<executions>
8383
<execution>
8484
<id>bundle-manifest</id>
@@ -107,17 +107,38 @@
107107
<dependency>
108108
<groupId>com.puppycrawl.tools</groupId>
109109
<artifactId>checkstyle</artifactId>
110-
<version>6.19</version>
110+
<version>8.12</version>
111111
</dependency>
112112
</dependencies>
113113
</plugin>
114114
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
115116
<artifactId>maven-release-plugin</artifactId>
116117
<version>2.5.3</version>
117118
<configuration>
118119
<autoVersionSubmodules>true</autoVersionSubmodules>
119120
</configuration>
120121
</plugin>
122+
<plugin>
123+
<groupId>org.apache.maven.plugins</groupId>
124+
<artifactId>maven-surefire-plugin</artifactId>
125+
<version>2.22.0</version>
126+
</plugin>
127+
<plugin>
128+
<groupId>org.apache.maven.plugins</groupId>
129+
<artifactId>maven-clean-plugin</artifactId>
130+
<version>3.1.0</version>
131+
</plugin>
132+
<plugin>
133+
<groupId>org.apache.maven.plugins</groupId>
134+
<artifactId>maven-enforcer-plugin</artifactId>
135+
<version>1.4.1</version>
136+
</plugin>
137+
<plugin>
138+
<groupId>org.apache.maven.plugins</groupId>
139+
<artifactId>maven-install-plugin</artifactId>
140+
<version>2.5.2</version>
141+
</plugin>
121142
</plugins>
122143
</pluginManagement>
123144
<plugins>
@@ -126,8 +147,7 @@
126147
<version>3.8.0</version>
127148
<configuration>
128149
<encoding>UTF-8</encoding>
129-
<source>1.7</source>
130-
<target>1.7</target>
150+
<release>7</release>
131151
<showDeprecation>true</showDeprecation>
132152
</configuration>
133153
</plugin>
@@ -170,7 +190,9 @@
170190
<artifactId>maven-javadoc-plugin</artifactId>
171191
<version>3.0.1</version>
172192
<configuration>
193+
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
173194
<encoding>UTF-8</encoding>
195+
<additionalOptions>-html5</additionalOptions>
174196
</configuration>
175197
<executions>
176198
<execution>
@@ -203,26 +225,6 @@
203225
</execution>
204226
</executions>
205227
</plugin>
206-
<plugin>
207-
<groupId>org.apache.maven.plugins</groupId>
208-
<artifactId>maven-enforcer-plugin</artifactId>
209-
<version>1.4.1</version>
210-
<executions>
211-
<execution>
212-
<id>enforce-java</id>
213-
<goals>
214-
<goal>enforce</goal>
215-
</goals>
216-
<configuration>
217-
<rules>
218-
<requireJavaVersion>
219-
<version>(,1.8)</version>
220-
</requireJavaVersion>
221-
</rules>
222-
</configuration>
223-
</execution>
224-
</executions>
225-
</plugin>
226228
</plugins>
227229
</build>
228230

scribejava-apis/src/main/java/com/github/scribejava/apis/MediaWikiApi.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ public MediaWikiApi(String indexUrl, String niceUrlBase) {
3636
}
3737

3838
/**
39-
* The instance for wikis hosted by the Wikimedia Foundation. Consumers are requested on
39+
* The instance for wikis hosted by the Wikimedia Foundation.Consumers are requested on
4040
* <a href="https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose">
4141
* Special:OAuthConsumerRegistration/propose
4242
* </a>.
43+
*
44+
* @return instance
4345
*/
4446
public static MediaWikiApi instance() {
4547
return InstanceHolder.INSTANCE;
@@ -50,6 +52,8 @@ public static MediaWikiApi instance() {
5052
* <a href="https://meta.wikimedia.beta.wmflabs.org/wiki/Special:OAuthConsumerRegistration/propose">
5153
* Special:OAuthConsumerRegistration/propose
5254
* </a>.
55+
*
56+
* @return instanceBeta
5357
*/
5458
public static MediaWikiApi instanceBeta() {
5559
return BetaInstanceHolder.BETA_INSTANCE;

scribejava-core/src/main/java/com/github/scribejava/core/builder/api/DefaultApi20.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ public String getRevokeTokenEndpoint() {
7575
/**
7676
* Returns the URL where you should redirect your users to authenticate your application.
7777
*
78+
* @param responseType responseType
79+
* @param apiKey apiKey
7880
* @param additionalParams any additional GET params to add to the URL
81+
* @param callback callback
82+
* @param state state
83+
* @param scope scope
7984
* @return the URL where you should redirect your users
8085
*/
8186
public String getAuthorizationUrl(String responseType, String apiKey, String callback, String scope, String state,

scribejava-core/src/main/java/com/github/scribejava/core/extractors/BaseStringExtractorImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ protected String getVerb(OAuthRequest request) {
3232

3333
/**
3434
* https://tools.ietf.org/html/rfc5849#section-3.4.1.2
35+
* @param request request
36+
* @return url
3537
*/
3638
protected String getUrl(OAuthRequest request) {
3739
return request.getSanitizedUrl();

scribejava-core/src/main/java/com/github/scribejava/core/java8/Base64.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@
4040
* <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>.
4141
*
4242
* <ul>
43-
* <li><a name="basic"><b>Basic</b></a>
43+
* <li><a id="basic"><b>Basic</b></a>
4444
* <p>
4545
* Uses "The Base64 Alphabet" as specified in Table 1 of RFC 4648 and RFC 2045 for encoding and decoding operation. The
4646
* encoder does not add any line feed (line separator) character. The decoder rejects data that contains characters
4747
* outside the base64 alphabet.</p></li>
4848
*
49-
* <li><a name="url"><b>URL and Filename safe</b></a>
49+
* <li><a id="url"><b>URL and Filename safe</b></a>
5050
* <p>
5151
* Uses the "URL and Filename safe Base64 Alphabet" as specified in Table 2 of RFC 4648 for encoding and decoding. The
5252
* encoder does not add any line feed (line separator) character. The decoder rejects data that contains characters
5353
* outside the base64 alphabet.</p></li>
5454
*
55-
* <li><a name="mime"><b>MIME</b></a>
55+
* <li><a id="mime"><b>MIME</b></a>
5656
* <p>
5757
* Uses the "The Base64 Alphabet" as specified in Table 1 of RFC 2045 for encoding and decoding operation. The encoded
5858
* output must be represented in lines of no more than 76 characters each and uses a carriage return {@code '\r'}
@@ -629,7 +629,8 @@ private int outLength(byte[] src, int sp, int sl) {
629629
len -= (sl - sp + 1);
630630
break;
631631
}
632-
if ((b = base64[b]) == -1) {
632+
b = base64[b];
633+
if (b == -1) {
633634
n++;
634635
}
635636
}
@@ -655,7 +656,8 @@ private int decode0(byte[] src, int sp, int sl, byte[] dst) {
655656
int shiftto = 18; // pos of first byte of 4-byte atom
656657
while (sp < sl) {
657658
int b = src[sp++] & 0xff;
658-
if ((b = base64[b]) < 0) {
659+
b = base64[b];
660+
if (b < 0) {
659661
if (b == -2) { // padding byte '='
660662
// = shiftto==18 unnecessary padding
661663
// x= shiftto==12 a dangling single x
@@ -689,15 +691,20 @@ private int decode0(byte[] src, int sp, int sl, byte[] dst) {
689691
}
690692
}
691693
// reached end of byte array or hit padding '=' characters.
692-
if (shiftto == 6) {
693-
dst[dp++] = (byte) (bits >> 16);
694-
} else if (shiftto == 0) {
695-
dst[dp++] = (byte) (bits >> 16);
696-
dst[dp++] = (byte) (bits >> 8);
697-
} else if (shiftto == 12) {
698-
// dangling single "x", incorrectly encoded.
699-
throw new IllegalArgumentException(
700-
"Last unit does not have enough valid bits");
694+
switch (shiftto) {
695+
case 6:
696+
dst[dp++] = (byte) (bits >> 16);
697+
break;
698+
case 0:
699+
dst[dp++] = (byte) (bits >> 16);
700+
dst[dp++] = (byte) (bits >> 8);
701+
break;
702+
case 12:
703+
// dangling single "x", incorrectly encoded.
704+
throw new IllegalArgumentException(
705+
"Last unit does not have enough valid bits");
706+
default:
707+
break;
701708
}
702709
// anything left is invalid, if is not MIME.
703710
// if MIME, ignore all non-base64 character
@@ -929,7 +936,8 @@ public int read(byte[] b, int off, int len) throws IOException {
929936
eof = true;
930937
break;
931938
}
932-
if ((v = base64[v]) == -1) {
939+
v = base64[v];
940+
if (v == -1) {
933941
if (isMIME) // skip if for rfc2045
934942
{
935943
continue;

scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ public void initMultipartBoundary() {
147147

148148
/**
149149
* you can invoke {@link #initMultipartBoundary(java.lang.String) } to set custom boundary
150+
* @param contentDisposition contentDisposition
151+
* @param contentType contentType
152+
* @param payload payload
150153
*/
151154
public void addMultipartPayload(String contentDisposition, String contentType, byte[] payload) {
152155
if (multipartPayload == null) {

scribejava-core/src/test/java/com/github/scribejava/core/services/RSASha1SignatureServiceTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.github.scribejava.core.services;
22

3+
import com.github.scribejava.core.java8.Base64;
34
import java.security.KeyFactory;
45
import java.security.NoSuchAlgorithmException;
56
import java.security.PrivateKey;
67
import java.security.spec.InvalidKeySpecException;
78
import java.security.spec.PKCS8EncodedKeySpec;
8-
import javax.xml.bind.DatatypeConverter;
99
import static org.junit.Assert.assertEquals;
1010
import org.junit.Test;
1111

@@ -48,11 +48,12 @@ private static PrivateKey getPrivateKey() {
4848
+ "I/AfAkEA0Y9vr0tombsUB8cZv0v5OYoBZvCTbMANtzfb4AOHpiKqqbohDOevLQ7/\n"
4949
+ "SpvgVCmVaDz2PptcRAyEBZ5MCssneQJAB2pmvaDH7Ambfod5bztLfOhLCtY5EkXJ\n"
5050
+ "n6rZcDbRaHorRhdG7m3VtDKOUKZ2DF7glkQGV33phKukErVPUzlHBwJAScD9TqaG\n"
51-
+ "wJ3juUsVtujV23SnH43iMggXT7m82STpPGam1hPfmqu2Z0niePFo927ogQ7H1EMJ\n" + "UHgqXmuvk2X/Ww==";
51+
+ "wJ3juUsVtujV23SnH43iMggXT7m82STpPGam1hPfmqu2Z0niePFo927ogQ7H1EMJ\n"
52+
+ "UHgqXmuvk2X/Ww==";
5253

5354
try {
5455
final KeyFactory fac = KeyFactory.getInstance("RSA");
55-
final PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(DatatypeConverter.parseBase64Binary(str));
56+
final PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(Base64.getMimeDecoder().decode(str));
5657
return fac.generatePrivate(privKeySpec);
5758
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
5859
throw new RuntimeException(e);

scribejava-httpclient-ahc/src/test/java/com/github/scribejava/httpclient/ahc/AhcHttpClientTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import com.github.scribejava.core.AbstractClientTest;
44
import com.github.scribejava.core.httpclient.HttpClient;
5-
import org.junit.Ignore;
65

7-
@Ignore(value = "we are java7 and AHC is java8")
86
public class AhcHttpClientTest extends AbstractClientTest {
97

108
@Override

0 commit comments

Comments
 (0)
X Tutup