1 // Copyright 2010 Google Inc. All rights reserved.
3 package com
.google
.appengine
.api
.oauth
;
5 import com
.google
.appengine
.api
.users
.User
;
8 * The OAuthService provides methods useful for validating OAuth requests.
10 * @see <a href="http://tools.ietf.org/html/rfc5849">RFC 5849</a> for
11 * the OAuth specification.
13 public interface OAuthService
{
15 * Returns the {@link User} on whose behalf the request was made.
17 * @throws OAuthRequestException If the request was not a valid OAuth request.
18 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
20 User
getCurrentUser() throws OAuthRequestException
;
23 * Returns the {@link User} on whose behalf the request was made.
24 * @param scope The custom OAuth scope that is accepted.
26 * @throws OAuthRequestException If the request was not a valid OAuth request.
27 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
29 User
getCurrentUser(String scope
) throws OAuthRequestException
;
32 * Returns the {@link User} on whose behalf the request was made.
33 * @param scopes The custom OAuth scopes at least one of which is accepted.
35 * @throws OAuthRequestException If the request was not a valid OAuth request.
36 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
38 User
getCurrentUser(String
... scopes
) throws OAuthRequestException
;
41 * Returns true if the user on whose behalf the request was made is an admin
42 * for this application, false otherwise.
44 * @throws OAuthRequestException If the request was not a valid OAuth request.
45 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
47 boolean isUserAdmin() throws OAuthRequestException
;
50 * Returns true if the user on whose behalf the request was made is an admin
51 * for this application, false otherwise.
52 * @param scope The custom OAuth scope that is accepted.
54 * @throws OAuthRequestException If the request was not a valid OAuth request.
55 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
57 * @since App Engine 1.7.3.
59 boolean isUserAdmin(String scope
) throws OAuthRequestException
;
62 * Returns true if the user on whose behalf the request was made is an admin
63 * for this application, false otherwise.
64 * @param scopes The custom OAuth scopes at least one of which is accepted.
66 * @throws OAuthRequestException If the request was not a valid OAuth request.
67 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
69 boolean isUserAdmin(String
... scopes
) throws OAuthRequestException
;
72 * Returns the oauth_consumer_key OAuth parameter from the request.
74 * @throws OAuthRequestException If the request was not a valid OAuth request.
75 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
77 String
getOAuthConsumerKey() throws OAuthRequestException
;
80 * Returns the client_id from oauth2 request.
82 * @throws OAuthRequestException If the request was not a valid OAuth2 request.
83 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
85 String
getClientId(String scope
) throws OAuthRequestException
;
88 * Returns the client_id from oauth2 request.
89 * @param scopes The custom OAuth scopes at least one of which is accepted.
91 * @throws OAuthRequestException If the request was not a valid OAuth2 request.
92 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
94 String
getClientId(String
... scopes
) throws OAuthRequestException
;
97 * Return authorized scopes from input scopes.
98 * @param scopes The custom OAuth scopes at least one of which is accepted.
100 * @throws OAuthRequestException If the request was not a valid OAuth2 request.
101 * @throws OAuthServiceFailureException If an unknown OAuth error occurred.
103 String
[] getAuthorizedScopes(String
... scopes
) throws OAuthRequestException
;