55import org .scribe .oauth .*;
66import 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+ */
818public 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 ();
0 commit comments