Skip to content

Commit 4a361d5

Browse files
committed
remove 'final' from methods in OAuth[10a|20]Service to allow mocking it
1 parent eafc4ae commit 4a361d5

3 files changed

Lines changed: 35 additions & 36 deletions

File tree

changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[SNAPSHOT]
22
* fix Salesforce API (thanks to https://github.com/jhorowitz-firedrum)
3+
* remove 'final' from methods in OAuth[10a|20]Service to allow mocking it
34

45
[5.2.0-java7again]
56
* allow 'null' as callback. It's an optional parameter. Remove "oob" as default (thanks to https://github.com/massongit)

scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public OAuth10aService(DefaultApi10a api, OAuthConfig config) {
3333
this.api = api;
3434
}
3535

36-
public final OAuth1RequestToken getRequestToken() throws IOException, InterruptedException, ExecutionException {
36+
public OAuth1RequestToken getRequestToken() throws IOException, InterruptedException, ExecutionException {
3737
final OAuthConfig config = getConfig();
3838
config.log("obtaining request token from " + api.getRequestTokenEndpoint());
3939
final OAuthRequest request = prepareRequestTokenRequest();
@@ -47,12 +47,11 @@ public final OAuth1RequestToken getRequestToken() throws IOException, Interrupte
4747
return api.getRequestTokenExtractor().extract(response);
4848
}
4949

50-
public final Future<OAuth1RequestToken> getRequestTokenAsync() {
50+
public Future<OAuth1RequestToken> getRequestTokenAsync() {
5151
return getRequestTokenAsync(null);
5252
}
5353

54-
public final Future<OAuth1RequestToken> getRequestTokenAsync(
55-
OAuthAsyncRequestCallback<OAuth1RequestToken> callback) {
54+
public Future<OAuth1RequestToken> getRequestTokenAsync(OAuthAsyncRequestCallback<OAuth1RequestToken> callback) {
5655
final OAuthConfig config = getConfig();
5756
config.log("async obtaining request token from " + api.getRequestTokenEndpoint());
5857
final OAuthRequest request = prepareRequestTokenRequest();
@@ -90,15 +89,15 @@ protected void addOAuthParams(OAuthRequest request, String tokenSecret) {
9089
config.log("appended additional OAuth parameters: " + request.getOauthParameters());
9190
}
9291

93-
public final OAuth1AccessToken getAccessToken(OAuth1RequestToken requestToken, String oauthVerifier)
92+
public OAuth1AccessToken getAccessToken(OAuth1RequestToken requestToken, String oauthVerifier)
9493
throws IOException, InterruptedException, ExecutionException {
9594
getConfig().log("obtaining access token from " + api.getAccessTokenEndpoint());
9695
final OAuthRequest request = prepareAccessTokenRequest(requestToken, oauthVerifier);
9796
final Response response = execute(request);
9897
return api.getAccessTokenExtractor().extract(response);
9998
}
10099

101-
public final Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken requestToken, String oauthVerifier) {
100+
public Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken requestToken, String oauthVerifier) {
102101
return getAccessTokenAsync(requestToken, oauthVerifier, null);
103102
}
104103

@@ -111,7 +110,7 @@ public final Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken re
111110
* @param callback optional callback
112111
* @return Future
113112
*/
114-
public final Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken requestToken, String oauthVerifier,
113+
public Future<OAuth1AccessToken> getAccessTokenAsync(OAuth1RequestToken requestToken, String oauthVerifier,
115114
OAuthAsyncRequestCallback<OAuth1AccessToken> callback) {
116115
final OAuthConfig config = getConfig();
117116
config.log("async obtaining access token from " + api.getAccessTokenEndpoint());

scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth20Service.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,19 @@ public OAuth2AccessToken convert(Response response) throws IOException {
6060
});
6161
}
6262

63-
public final Future<OAuth2AccessToken> getAccessTokenAsync(String code) {
63+
public Future<OAuth2AccessToken> getAccessTokenAsync(String code) {
6464
return getAccessToken(code, null, null);
6565
}
6666

67-
public final Future<OAuth2AccessToken> getAccessTokenAsync(String code, String pkceCodeVerifier) {
67+
public Future<OAuth2AccessToken> getAccessTokenAsync(String code, String pkceCodeVerifier) {
6868
return getAccessToken(code, null, pkceCodeVerifier);
6969
}
7070

71-
public final OAuth2AccessToken getAccessToken(String code)
72-
throws IOException, InterruptedException, ExecutionException {
71+
public OAuth2AccessToken getAccessToken(String code) throws IOException, InterruptedException, ExecutionException {
7372
return getAccessToken(code, (String) null);
7473
}
7574

76-
public final OAuth2AccessToken getAccessToken(String code, String pkceCodeVerifier)
75+
public OAuth2AccessToken getAccessToken(String code, String pkceCodeVerifier)
7776
throws IOException, InterruptedException, ExecutionException {
7877
final OAuthRequest request = createAccessTokenRequest(code, pkceCodeVerifier);
7978

@@ -89,14 +88,14 @@ public final OAuth2AccessToken getAccessToken(String code, String pkceCodeVerifi
8988
* @param pkceCodeVerifier pkce Code Verifier
9089
* @return Future
9190
*/
92-
public final Future<OAuth2AccessToken> getAccessToken(String code,
93-
OAuthAsyncRequestCallback<OAuth2AccessToken> callback, String pkceCodeVerifier) {
91+
public Future<OAuth2AccessToken> getAccessToken(String code, OAuthAsyncRequestCallback<OAuth2AccessToken> callback,
92+
String pkceCodeVerifier) {
9493
final OAuthRequest request = createAccessTokenRequest(code, pkceCodeVerifier);
9594

9695
return sendAccessTokenRequestAsync(request, callback);
9796
}
9897

99-
public final Future<OAuth2AccessToken> getAccessToken(String code,
98+
public Future<OAuth2AccessToken> getAccessToken(String code,
10099
OAuthAsyncRequestCallback<OAuth2AccessToken> callback) {
101100

102101
return getAccessToken(code, callback, null);
@@ -126,18 +125,18 @@ protected OAuthRequest createAccessTokenRequest(String code, String pkceCodeVeri
126125
return request;
127126
}
128127

129-
public final Future<OAuth2AccessToken> refreshAccessTokenAsync(String refreshToken) {
128+
public Future<OAuth2AccessToken> refreshAccessTokenAsync(String refreshToken) {
130129
return refreshAccessToken(refreshToken, null);
131130
}
132131

133-
public final OAuth2AccessToken refreshAccessToken(String refreshToken)
132+
public OAuth2AccessToken refreshAccessToken(String refreshToken)
134133
throws IOException, InterruptedException, ExecutionException {
135134
final OAuthRequest request = createRefreshTokenRequest(refreshToken);
136135

137136
return sendAccessTokenRequestSync(request);
138137
}
139138

140-
public final Future<OAuth2AccessToken> refreshAccessToken(String refreshToken,
139+
public Future<OAuth2AccessToken> refreshAccessToken(String refreshToken,
141140
OAuthAsyncRequestCallback<OAuth2AccessToken> callback) {
142141
final OAuthRequest request = createRefreshTokenRequest(refreshToken);
143142

@@ -157,14 +156,14 @@ protected OAuthRequest createRefreshTokenRequest(String refreshToken) {
157156
return request;
158157
}
159158

160-
public final OAuth2AccessToken getAccessTokenPasswordGrant(String uname, String password)
159+
public OAuth2AccessToken getAccessTokenPasswordGrant(String uname, String password)
161160
throws IOException, InterruptedException, ExecutionException {
162161
final OAuthRequest request = createAccessTokenPasswordGrantRequest(uname, password);
163162

164163
return sendAccessTokenRequestSync(request);
165164
}
166165

167-
public final Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password) {
166+
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password) {
168167
return getAccessTokenPasswordGrantAsync(uname, password, null);
169168
}
170169

@@ -176,7 +175,7 @@ public final Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String u
176175
* @param callback Optional callback
177176
* @return Future
178177
*/
179-
public final Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password,
178+
public Future<OAuth2AccessToken> getAccessTokenPasswordGrantAsync(String uname, String password,
180179
OAuthAsyncRequestCallback<OAuth2AccessToken> callback) {
181180
final OAuthRequest request = createAccessTokenPasswordGrantRequest(uname, password);
182181

@@ -201,11 +200,11 @@ protected OAuthRequest createAccessTokenPasswordGrantRequest(String username, St
201200
return request;
202201
}
203202

204-
public final Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrantAsync() {
203+
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrantAsync() {
205204
return getAccessTokenClientCredentialsGrant(null);
206205
}
207206

208-
public final OAuth2AccessToken getAccessTokenClientCredentialsGrant()
207+
public OAuth2AccessToken getAccessTokenClientCredentialsGrant()
209208
throws IOException, InterruptedException, ExecutionException {
210209
final OAuthRequest request = createAccessTokenClientCredentialsGrantRequest();
211210

@@ -219,7 +218,7 @@ public final OAuth2AccessToken getAccessTokenClientCredentialsGrant()
219218
* @param callback optional callback
220219
* @return Future
221220
*/
222-
public final Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant(
221+
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant(
223222
OAuthAsyncRequestCallback<OAuth2AccessToken> callback) {
224223
final OAuthRequest request = createAccessTokenClientCredentialsGrantRequest();
225224

@@ -252,15 +251,15 @@ public void signRequest(String accessToken, OAuthRequest request) {
252251
api.getSignatureType().signRequest(accessToken, request);
253252
}
254253

255-
public final void signRequest(OAuth2AccessToken accessToken, OAuthRequest request) {
254+
public void signRequest(OAuth2AccessToken accessToken, OAuthRequest request) {
256255
signRequest(accessToken == null ? null : accessToken.getAccessToken(), request);
257256
}
258257

259-
public final AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE() {
258+
public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE() {
260259
return getAuthorizationUrlWithPKCE(null);
261260
}
262261

263-
public final AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE(Map<String, String> additionalParams) {
262+
public AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE(Map<String, String> additionalParams) {
264263
final PKCE pkce = PKCE_SERVICE.generatePKCE();
265264
return new AuthorizationUrlWithPKCE(pkce, getAuthorizationUrl(additionalParams, pkce));
266265
}
@@ -270,7 +269,7 @@ public final AuthorizationUrlWithPKCE getAuthorizationUrlWithPKCE(Map<String, St
270269
*
271270
* @return the URL where you should redirect your users
272271
*/
273-
public final String getAuthorizationUrl() {
272+
public String getAuthorizationUrl() {
274273
return getAuthorizationUrl(null, null);
275274
}
276275

@@ -280,11 +279,11 @@ public final String getAuthorizationUrl() {
280279
* @param additionalParams any additional GET params to add to the URL
281280
* @return the URL where you should redirect your users
282281
*/
283-
public final String getAuthorizationUrl(Map<String, String> additionalParams) {
282+
public String getAuthorizationUrl(Map<String, String> additionalParams) {
284283
return getAuthorizationUrl(additionalParams, null);
285284
}
286285

287-
public final String getAuthorizationUrl(PKCE pkce) {
286+
public String getAuthorizationUrl(PKCE pkce) {
288287
return getAuthorizationUrl(null, pkce);
289288
}
290289

@@ -315,30 +314,30 @@ protected OAuthRequest createRevokeTokenRequest(String tokenToRevoke, TokenTypeH
315314
return request;
316315
}
317316

318-
public final Future<Void> revokeTokenAsync(String tokenToRevoke) {
317+
public Future<Void> revokeTokenAsync(String tokenToRevoke) {
319318
return revokeTokenAsync(tokenToRevoke, null);
320319
}
321320

322-
public final Future<Void> revokeTokenAsync(String tokenToRevoke, TokenTypeHint tokenTypeHint) {
321+
public Future<Void> revokeTokenAsync(String tokenToRevoke, TokenTypeHint tokenTypeHint) {
323322
return revokeToken(tokenToRevoke, null, tokenTypeHint);
324323
}
325324

326-
public final void revokeToken(String tokenToRevoke) throws IOException, InterruptedException, ExecutionException {
325+
public void revokeToken(String tokenToRevoke) throws IOException, InterruptedException, ExecutionException {
327326
revokeToken(tokenToRevoke, (TokenTypeHint) null);
328327
}
329328

330-
public final void revokeToken(String tokenToRevoke, TokenTypeHint tokenTypeHint)
329+
public void revokeToken(String tokenToRevoke, TokenTypeHint tokenTypeHint)
331330
throws IOException, InterruptedException, ExecutionException {
332331
final OAuthRequest request = createRevokeTokenRequest(tokenToRevoke, tokenTypeHint);
333332

334333
checkForErrorRevokeToken(execute(request));
335334
}
336335

337-
public final Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback) {
336+
public Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback) {
338337
return revokeToken(tokenToRevoke, callback, null);
339338
}
340339

341-
public final Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback,
340+
public Future<Void> revokeToken(String tokenToRevoke, OAuthAsyncRequestCallback<Void> callback,
342341
TokenTypeHint tokenTypeHint) {
343342
final OAuthRequest request = createRevokeTokenRequest(tokenToRevoke, tokenTypeHint);
344343

0 commit comments

Comments
 (0)