public class GitkitClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GitkitClient.Builder
Builder class to construct Gitkit client instance.
|
static class |
GitkitClient.OobAction
Gitkit out-of-band actions.
|
class |
GitkitClient.OobResponse
Wrapper class containing the out-of-band responses.
|
| Constructor and Description |
|---|
GitkitClient(String clientId,
String serviceAccountEmail,
InputStream keyStream,
String widgetUrl,
String cookieName,
HttpSender httpSender,
String serverApiKey)
Constructs a Gitkit client.
|
| Modifier and Type | Method and Description |
|---|---|
static GitkitClient |
createFromJson(String configPath)
Constructs a Gitkit client from a JSON config file
|
void |
deleteUser(GitkitUser user)
Deletes a user account at Gitkit server.
|
void |
deleteUser(String localId)
Deletes a user account at Gitkit server.
|
Iterator<GitkitUser> |
getAllUsers()
Gets all user info of this web site.
|
Iterator<GitkitUser> |
getAllUsers(Integer resultsPerRequest)
Gets all user info of this web site.
|
GitkitClient.OobResponse |
getOobResponse(javax.servlet.http.HttpServletRequest req)
Gets out-of-band response.
|
GitkitClient.OobResponse |
getOobResponse(javax.servlet.http.HttpServletRequest req,
String gitkitToken)
Gets out-of-band response.
|
GitkitUser |
getUserByEmail(String email)
Gets user info given an email.
|
GitkitUser |
getUserByLocalId(String localId)
Gets user info given a user id.
|
GitkitUser |
getUserByToken(String token)
Gets user info from GITkit service using Gitkit token.
|
static GitkitClient.Builder |
newBuilder() |
GitkitUser |
updateUser(GitkitUser user)
Updates a user info at Gitkit server.
|
void |
uploadUsers(String hashAlgorithm,
byte[] hashKey,
List<GitkitUser> users)
Uploads multiple user accounts to Gitkit server.
|
GitkitUser |
validateToken(String token)
Verifies a Gitkit token.
|
GitkitUser |
validateTokenInRequest(javax.servlet.http.HttpServletRequest request)
Verifies Gitkit token in http request.
|
public GitkitClient(String clientId, String serviceAccountEmail, InputStream keyStream, String widgetUrl, String cookieName, HttpSender httpSender, String serverApiKey)
clientId - Google oauth2 web application client id. Audience in Gitkit token must match
this client id.serviceAccountEmail - Google service account email.keyStream - Google service account private p12 key stream.widgetUrl - Url of the Gitkit widget, must starting with /.cookieName - Gitkit cookie name. Used to extract Gitkit token from incoming http request.httpSender - Concrete http sender when Gitkit client needs to call Gitkit remote API.serverApiKey - Server side API key in Google Developer Console.public static GitkitClient createFromJson(String configPath) throws org.json.JSONException, IOException
configPath - Path to JSON configuration fileorg.json.JSONExceptionIOExceptionpublic GitkitUser validateToken(String token) throws GitkitClientException
token - token string to be verified.GitkitClientException - if token has invalid signaturepublic GitkitUser validateTokenInRequest(javax.servlet.http.HttpServletRequest request) throws GitkitClientException
request - http requestGitkitClientException - if there is token but signature is invalidpublic GitkitUser getUserByToken(String token) throws GitkitClientException, GitkitServerException
token - the gitkit token.GitkitClientException - if request is invalidGitkitServerException - for Gitkit server errorpublic GitkitUser getUserByEmail(String email) throws GitkitClientException, GitkitServerException
email - user email.GitkitClientException - if request is invalidGitkitServerException - for Gitkit server errorpublic GitkitUser getUserByLocalId(String localId) throws GitkitClientException, GitkitServerException
localId - user identifier at Gitkit.GitkitClientException - if request is invalidGitkitServerException - for Gitkit server errorpublic Iterator<GitkitUser> getAllUsers()
public Iterator<GitkitUser> getAllUsers(Integer resultsPerRequest)
resultsPerRequest - pagination sizepublic GitkitUser updateUser(GitkitUser user) throws GitkitClientException, GitkitServerException
user - user info to be updated.GitkitClientException - for invalid requestGitkitServerException - for server errorpublic void uploadUsers(String hashAlgorithm, byte[] hashKey, List<GitkitUser> users) throws GitkitServerException, GitkitClientException
hashAlgorithm - hash algorithm. Supported values are HMAC_SHA256, HMAC_SHA1, HMAC_MD5,
PBKDF_SHA1, MD5 and SCRYPT.hashKey - key of hash algorithmusers - list of user accounts to be uploadedGitkitClientException - for invalid requestGitkitServerException - for server errorpublic void deleteUser(GitkitUser user) throws GitkitServerException, GitkitClientException
user - user to be deleted.GitkitClientException - for invalid requestGitkitServerException - for server errorpublic void deleteUser(String localId) throws GitkitServerException, GitkitClientException
localId - user id to be deleted.GitkitClientException - for invalid requestGitkitServerException - for server errorpublic GitkitClient.OobResponse getOobResponse(javax.servlet.http.HttpServletRequest req) throws GitkitServerException
req - http request for the oob endpointGitkitServerExceptionpublic GitkitClient.OobResponse getOobResponse(javax.servlet.http.HttpServletRequest req, String gitkitToken) throws GitkitServerException
req - http request for the oob endpointgitkitToken - Gitkit token of authenticated user, required for ChangeEmail operationGitkitServerExceptionpublic static GitkitClient.Builder newBuilder()
Copyright © 2015. All rights reserved.