|
3 | 3 | import org.scribe.builder.api.*; |
4 | 4 | import org.scribe.model.*; |
5 | 5 |
|
6 | | -public class OAuth2ServiceImpl implements OAuthService |
| 6 | +public class OAuth20ServiceImpl implements OAuthService |
7 | 7 | { |
8 | | - private final Api api; |
| 8 | + private static final String VERSION = "2.0"; |
| 9 | + |
| 10 | + private final DefaultApi20 api; |
9 | 11 | private final OAuthConfig config; |
10 | 12 |
|
11 | | - public OAuth2ServiceImpl(Api api, OAuthConfig config) |
| 13 | + /** |
| 14 | + * Default constructor |
| 15 | + * |
| 16 | + * @param api OAuth2.0 api information |
| 17 | + * @param config OAuth 2.0 configuration param object |
| 18 | + */ |
| 19 | + public OAuth20ServiceImpl(DefaultApi20 api, OAuthConfig config) |
12 | 20 | { |
13 | 21 | this.api = api; |
14 | 22 | this.config = config; |
15 | 23 | } |
16 | 24 |
|
17 | | - @Override |
| 25 | + /** |
| 26 | + * {@inheritDoc} |
| 27 | + */ |
18 | 28 | public void addScope(String scope) |
19 | 29 | { |
20 | 30 | throw new UnsupportedOperationException("OAuth 2 does not use scopes"); |
21 | 31 | } |
22 | 32 |
|
23 | | - @Override |
| 33 | + /** |
| 34 | + * {@inheritDoc} |
| 35 | + */ |
24 | 36 | public Token getAccessToken(Token requestToken, Verifier verifier) |
25 | 37 | { |
26 | 38 | throw new UnsupportedOperationException("Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there"); |
27 | 39 | } |
28 | 40 |
|
29 | | - @Override |
| 41 | + /** |
| 42 | + * {@inheritDoc} |
| 43 | + */ |
30 | 44 | public Token getRequestToken() |
31 | 45 | { |
32 | 46 | throw new UnsupportedOperationException("Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there"); |
33 | 47 | } |
34 | 48 |
|
35 | | - @Override |
| 49 | + /** |
| 50 | + * {@inheritDoc} |
| 51 | + */ |
36 | 52 | public String getVersion() |
37 | 53 | { |
38 | | - return "2.0"; |
| 54 | + return VERSION; |
39 | 55 | } |
40 | 56 |
|
41 | | - @Override |
| 57 | + /** |
| 58 | + * {@inheritDoc} |
| 59 | + */ |
42 | 60 | public void signRequest(Token accessToken, OAuthRequest request) |
43 | 61 | { |
44 | | - |
| 62 | + request.addParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken()); |
45 | 63 | } |
46 | 64 |
|
47 | | - @Override |
| 65 | + /** |
| 66 | + * {@inheritDoc} |
| 67 | + */ |
48 | 68 | public String getAuthorizationUrl(Token requestToken) |
49 | 69 | { |
50 | | - return null; |
| 70 | + return api.getAuthorizationUrl(config); |
51 | 71 | } |
52 | 72 |
|
53 | 73 | } |
0 commit comments