Skip to content

Commit 59f16bf

Browse files
Added bunch of javadocs and restricted some visibility.
No functional changes
1 parent aad8dac commit 59f16bf

35 files changed

+393
-64
lines changed

src/main/java/org/scribe/builder/ServiceBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class ServiceBuilder
2222
private Api api;
2323
private String scope;
2424

25+
/**
26+
* Default constructor
27+
*/
2528
public ServiceBuilder()
2629
{
2730
this.callback = OAuthConstants.OUT_OF_BAND;

src/main/java/org/scribe/builder/api/Api.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@
1010
*/
1111
public interface Api
1212
{
13-
/**
14-
* Creates an {@link OAuthService}
15-
*
16-
* @param apiKey your application api key
17-
* @param apiSecret your application api secret
18-
* @param callback the callback url (or 'oob' for out of band OAuth)
19-
*
20-
* @return fully configured {@link OAuthService}
21-
*/
22-
OAuthService createService(String apiKey, String apiSecret, String callback);
23-
2413
/**
2514
* Creates an {@link OAuthService}
2615
*

src/main/java/org/scribe/builder/api/DefaultApi10a.java

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,89 @@
55
import org.scribe.oauth.*;
66
import org.scribe.services.*;
77

8+
/**
9+
* Default implementation of the OAuth protocol, version 1.0a
10+
*
11+
* This class is meant to be extended by concrete implementations of the API.
12+
* If your Api adheres to the 1.0a protocol correctly, you just need to extend
13+
* this class and define the getters for your endpoints.
14+
*
15+
* @author Pablo Fernandez
16+
*
17+
*/
818
public abstract class DefaultApi10a implements Api
919
{
10-
public AccessTokenExtractor getAccessTokenExtractor()
20+
21+
protected AccessTokenExtractor getAccessTokenExtractor()
1122
{
1223
return new TokenExtractorImpl();
1324
}
1425

15-
public BaseStringExtractor getBaseStringExtractor()
26+
protected BaseStringExtractor getBaseStringExtractor()
1627
{
1728
return new BaseStringExtractorImpl();
1829
}
1930

20-
public HeaderExtractor getHeaderExtractor()
31+
protected HeaderExtractor getHeaderExtractor()
2132
{
2233
return new HeaderExtractorImpl();
2334
}
2435

25-
public RequestTokenExtractor getRequestTokenExtractor()
36+
protected RequestTokenExtractor getRequestTokenExtractor()
2637
{
2738
return new TokenExtractorImpl();
2839
}
2940

30-
public SignatureService getSignatureService()
41+
protected SignatureService getSignatureService()
3142
{
3243
return new HMACSha1SignatureService();
3344
}
3445

35-
public TimestampService getTimestampService()
46+
protected TimestampService getTimestampService()
3647
{
3748
return new TimestampServiceImpl();
3849
}
3950

40-
public Verb getAccessTokenVerb()
51+
protected Verb getAccessTokenVerb()
4152
{
4253
return Verb.POST;
4354
}
4455

45-
public Verb getRequestTokenVerb()
56+
protected Verb getRequestTokenVerb()
4657
{
4758
return Verb.POST;
4859
}
4960

50-
public abstract String getRequestTokenEndpoint();
51-
public abstract String getAccessTokenEndpoint();
61+
/**
62+
* Returns the URL that receives the request token requests.
63+
*
64+
* @return request token URL
65+
*/
66+
protected abstract String getRequestTokenEndpoint();
67+
68+
/**
69+
* Returns the URL that receives the access token requests.
70+
*
71+
* @return access token URL
72+
*/
73+
protected abstract String getAccessTokenEndpoint();
74+
75+
/**
76+
* Returns the {@link OAuthService} for this Api
77+
*
78+
* @param apiKey Key
79+
* @param apiSecret Api Secret
80+
* @param callback OAuth callback (either URL or 'oob')
81+
* @param scope OAuth scope (optional)
82+
*/
83+
public OAuthService createService(String apiKey, String apiSecret, String callback, String scope)
84+
{
85+
OAuthService service = createService(apiKey, apiSecret, callback);
86+
service.addScope(scope);
87+
return service;
88+
}
5289

53-
public OAuthService createService(String apiKey, String apiSecret, String callback)
90+
private OAuthService createService(String apiKey, String apiSecret, String callback)
5491
{
5592
return new OAuth10aServiceImpl( getSignatureService(),
5693
getTimestampService(),
@@ -61,13 +98,6 @@ public OAuthService createService(String apiKey, String apiSecret, String callba
6198
createConfig(apiKey, apiSecret, callback));
6299
}
63100

64-
public OAuthService createService(String apiKey, String apiSecret, String callback, String scope)
65-
{
66-
OAuthService service = createService(apiKey, apiSecret, callback);
67-
service.addScope(scope);
68-
return service;
69-
}
70-
71101
private OAuthConfig createConfig(String apiKey, String apiSecret, String callback)
72102
{
73103
OAuthConfig config = new OAuthConfig();

src/main/java/org/scribe/builder/api/FoursquareApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
public class FoursquareApi extends DefaultApi10a
44
{
55
@Override
6-
public String getAccessTokenEndpoint()
6+
protected String getAccessTokenEndpoint()
77
{
88
return "http://foursquare.com/oauth/access_token";
99
}
1010

1111
@Override
12-
public String getRequestTokenEndpoint()
12+
protected String getRequestTokenEndpoint()
1313
{
1414
return "http://foursquare.com/oauth/request_token";
1515
}

src/main/java/org/scribe/builder/api/GoogleApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
public class GoogleApi extends DefaultApi10a
44
{
55
@Override
6-
public String getAccessTokenEndpoint()
6+
protected String getAccessTokenEndpoint()
77
{
88
return "https://www.google.com/accounts/OAuthGetAccessToken";
99
}
1010

1111
@Override
12-
public String getRequestTokenEndpoint()
12+
protected String getRequestTokenEndpoint()
1313
{
1414
return "https://www.google.com/accounts/OAuthGetRequestToken";
1515
}

src/main/java/org/scribe/builder/api/LinkedInApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ public class LinkedInApi extends DefaultApi10a
77
{
88

99
@Override
10-
public String getAccessTokenEndpoint()
10+
protected String getAccessTokenEndpoint()
1111
{
1212
return "https://api.linkedin.com/uas/oauth/accessToken";
1313
}
1414

1515
@Override
16-
public String getRequestTokenEndpoint()
16+
protected String getRequestTokenEndpoint()
1717
{
1818
return "https://api.linkedin.com/uas/oauth/requestToken";
1919
}
2020

2121
@Override
22-
public BaseStringExtractor getBaseStringExtractor()
22+
protected BaseStringExtractor getBaseStringExtractor()
2323
{
2424
return new LinkedInBaseStringExtractorImpl();
2525
}

src/main/java/org/scribe/builder/api/TwitterApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
public class TwitterApi extends DefaultApi10a
44
{
55
@Override
6-
public String getAccessTokenEndpoint()
6+
protected String getAccessTokenEndpoint()
77
{
88
return "http://twitter.com/oauth/access_token";
99
}
1010

1111
@Override
12-
public String getRequestTokenEndpoint()
12+
protected String getRequestTokenEndpoint()
1313
{
1414
return "http://twitter.com/oauth/request_token";
1515
}

src/main/java/org/scribe/builder/api/VimeoApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
public class VimeoApi extends DefaultApi10a
44
{
55
@Override
6-
public String getAccessTokenEndpoint()
6+
protected String getAccessTokenEndpoint()
77
{
88
return "http://vimeo.com/oauth/access_token";
99
}
1010

1111
@Override
12-
public String getRequestTokenEndpoint()
12+
protected String getRequestTokenEndpoint()
1313
{
1414
return "http://vimeo.com/oauth/request_token";
1515
}

src/main/java/org/scribe/builder/api/YahooApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
public class YahooApi extends DefaultApi10a
44
{
55
@Override
6-
public String getAccessTokenEndpoint()
6+
protected String getAccessTokenEndpoint()
77
{
88
return "https://api.login.yahoo.com/oauth/v2/get_token";
99
}
1010

1111
@Override
12-
public String getRequestTokenEndpoint()
12+
protected String getRequestTokenEndpoint()
1313
{
1414
return "https://api.login.yahoo.com/oauth/v2/get_request_token";
1515
}
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
package org.scribe.exceptions;
22

3+
/**
4+
* Default scribe exception.
5+
* Represents a problem in the OAuth signing process
6+
*
7+
* @author Pablo Fernandez
8+
*/
39
public class OAuthException extends RuntimeException
410
{
511

12+
/**
13+
* Default constructor
14+
* @param message message explaining what went wrong
15+
* @param e original exception
16+
*/
617
public OAuthException(String message, Exception e)
718
{
819
super(message, e);
920
}
1021

22+
/**
23+
* No-exception constructor. Used when there is no original exception
24+
*
25+
* @param message message explaining what went wrong
26+
*/
1127
public OAuthException(String message)
1228
{
1329
super(message, null);
1430
}
1531

1632
private static final long serialVersionUID = 1L;
17-
1833
}

0 commit comments

Comments
 (0)