public abstract class ApiKeyAuth extends Object
Modifier and Type | Method and Description |
---|---|
UserApiKey |
createApiKey(String name)
Creates a user API key that can be used to authenticate as the user.
|
RealmAsyncTask |
createApiKeyAsync(String name,
App.Callback<UserApiKey> callback)
Asynchronously creates a user API key that can be used to authenticate as the user.
|
void |
deleteApiKey(ObjectId id)
Deletes a specific API key created by the user.
|
RealmAsyncTask |
deleteApiKeyAsync(ObjectId id,
App.Callback<Void> callback)
Deletes a specific API key created by the user.
|
void |
disableApiKey(ObjectId id)
Disables a specific API key created by the user.
|
RealmAsyncTask |
disableApiKeyAsync(ObjectId id,
App.Callback<Void> callback)
Disables a specific API key created by the user.
|
void |
enableApiKey(ObjectId id)
Enables a specific API key created by the user.
|
RealmAsyncTask |
enableApiKeyAsync(ObjectId id,
App.Callback<Void> callback)
Enables a specific API key created by the user.
|
boolean |
equals(Object o) |
List<UserApiKey> |
fetchAllApiKeys()
Fetches all API keys associated with the user.
|
RealmAsyncTask |
fetchAllApiKeys(App.Callback<List<UserApiKey>> callback)
Fetches all API keys associated with the user.
|
UserApiKey |
fetchApiKey(ObjectId id)
Fetches a specific user API key associated with the user.
|
RealmAsyncTask |
fetchApiKeyAsync(ObjectId id,
App.Callback<UserApiKey> callback)
Fetches a specific user API key associated with the user.
|
App |
getApp()
Returns the
App that this instance in associated with. |
User |
getUser()
Returns the
User that this instance in associated with. |
int |
hashCode() |
String |
toString() |
public User getUser()
User
that this instance in associated with.User
that this instance in associated with.public App getApp()
App
that this instance in associated with.App
that this instance in associated with.public UserApiKey createApiKey(String name) throws AppException
The value of the key must be persisted at this time as this is the only time it is visible.
The key is enabled when created. It can be disabled by calling disableApiKey(ObjectId)
.
name
- the name of the keyAppException
- if the server failed to create the API key.public RealmAsyncTask createApiKeyAsync(String name, App.Callback<UserApiKey> callback)
The value of the key must be persisted at this time as this is the only time it is visible.
The key is enabled when created. It can be disabled by calling disableApiKey(ObjectId)
.
name
- the name of the keycallback
- callback when key creation has completed or failed. The callback will always
happen on the same thread as this method is called on.IllegalStateException
- if called from a non-looper thread.public UserApiKey fetchApiKey(ObjectId id) throws AppException
id
- the id of the key to fetch.AppException
- if the server failed to fetch the API key.public RealmAsyncTask fetchApiKeyAsync(ObjectId id, App.Callback<UserApiKey> callback)
id
- the id of the key to fetch.callback
- callback used when the key was fetched or the call failed. The callback
will always happen on the same thread as this method was called on.IllegalStateException
- if called from a non-looper thread.public List<UserApiKey> fetchAllApiKeys() throws AppException
AppException
- if the server failed to fetch the API keys.public RealmAsyncTask fetchAllApiKeys(App.Callback<List<UserApiKey>> callback)
callback
- callback used when the keys were fetched or the call failed. The callback
will always happen on the same thread as this method was called on.IllegalStateException
- if called from a non-looper thread.public void deleteApiKey(ObjectId id) throws AppException
id
- the id of the key to delete.AppException
- if the server failed to delete the API key.public RealmAsyncTask deleteApiKeyAsync(ObjectId id, App.Callback<Void> callback)
id
- the id of the key to delete.callback
- callback used when the was deleted or the call failed. The callback
will always happen on the same thread as this method was called on.IllegalStateException
- if called from a non-looper thread.public void disableApiKey(ObjectId id) throws AppException
id
- the id of the key to disable.AppException
- if the server failed to disable the API key.public RealmAsyncTask disableApiKeyAsync(ObjectId id, App.Callback<Void> callback)
id
- the id of the key to disable.callback
- callback used when the key was disabled or the call failed. The callback
will always happen on the same thread as this method was called on.IllegalStateException
- if called from a non-looper thread.public void enableApiKey(ObjectId id) throws AppException
id
- the id of the key to enable.AppException
- if the server failed to enable the API key.public RealmAsyncTask enableApiKeyAsync(ObjectId id, App.Callback<Void> callback)
id
- the id of the key to enable.callback
- callback used when the key was enabled or the call failed. The callback
will always happen on the same thread as this method was called on.IllegalStateException
- if called from a non-looper thread.