public class PermissionManager extends Object implements Closeable
SyncUser
.
Current functionality supported by this class:
This class depends on underlying Realms, so all data coming from this class is thread-confined and must be closed after use to avoid leaking resources.
Modifier and Type | Class and Description |
---|---|
static interface |
PermissionManager.AcceptOfferCallback
Callback used when accepting a permission offer.
|
static interface |
PermissionManager.ApplyPermissionsCallback
Callback used when modifying or creating new permissions.
|
static interface |
PermissionManager.MakeOfferCallback
Callback used when making a permission offer for other users.
|
static interface |
PermissionManager.OffersCallback
Callback used when loading the list of
PermissionOffer 's created by the user. |
static interface |
PermissionManager.PermissionsCallback
Callback used when loading a set of permissions.
|
static interface |
PermissionManager.RevokeOfferCallback
Callback used when revoking an existing offer.
|
Modifier and Type | Method and Description |
---|---|
RealmAsyncTask |
acceptOffer(String offerToken,
PermissionManager.AcceptOfferCallback callback)
Accepts a permission offer sent by another user.
|
RealmAsyncTask |
applyPermissions(PermissionRequest request,
PermissionManager.ApplyPermissionsCallback callback)
Applies a given set of permissions to a Realm.
|
void |
close()
Closes the PermissionManager as well as any underlying Realms.
|
RealmAsyncTask |
getCreatedOffers(PermissionManager.OffersCallback callback)
Returns the list of offers created by this user.
|
RealmAsyncTask |
getDefaultPermissions(PermissionManager.PermissionsCallback callback)
NOTE: Moved out of the public API until we know for sure how this is going to work.
|
RealmAsyncTask |
getPermissions(PermissionManager.PermissionsCallback callback)
Retrieves the list of permissions for all Realms available to this user.
|
boolean |
isClosed()
Checks if this PermissionManager is closed or not.
|
RealmAsyncTask |
makeOffer(PermissionOffer offer,
PermissionManager.MakeOfferCallback callback)
Makes a permission offer to users.
|
RealmAsyncTask |
revokeOffer(String offerToken,
PermissionManager.RevokeOfferCallback callback)
Revokes an existing offer.
|
public RealmAsyncTask getPermissions(PermissionManager.PermissionsCallback callback)
callback
- callback notified when the permissions are ready. The returned RealmResults
is a fully
live query result, that will be auto-updated like any other RealmResults
.RealmAsyncTask
that can be used to cancel the task if needed.public RealmAsyncTask getDefaultPermissions(PermissionManager.PermissionsCallback callback)
callback
- callback notified when the permissions are ready. The returned RealmResults
is a fully
live query result, that will be auto-updated like any other RealmResults
.RealmAsyncTask
that can be used to cancel the task if needed.public RealmAsyncTask applyPermissions(PermissionRequest request, PermissionManager.ApplyPermissionsCallback callback)
A PermissionRequest
object encapsulates a description of which users are granted what
AccessLevel
s for which Realm(s).
Once the request is successfully handled, a Permission
entry is created in each user's
PermissionManager
and can be found using getPermissions(PermissionsCallback)
.
request
- request object describing which permissions to grant and to what Realm(s).callback
- callback when the request either succeeded or failed.public RealmAsyncTask makeOffer(PermissionOffer offer, PermissionManager.MakeOfferCallback callback)
PermissionOffer
do not take effect until the offer has been accepted by a user
calling acceptOffer(String, AcceptOfferCallback)
.
A permission offer can be used as a flexible way of sharing Realms with other users that might not be known at the time
of making the offer as well as enabling sharing across other channels like e-mail. If a specific user should be
granted access, using applyPermissions(PermissionRequest, ApplyPermissionsCallback)
will be faster and quicker.
An offer can be accepted by multiple users.
callback
- callback to be notified with the offer token once it is ready.RealmAsyncTask
that can be used to cancel the task if needed.public RealmAsyncTask acceptOffer(String offerToken, PermissionManager.AcceptOfferCallback callback)
offerToken
- token representing the permission offer.callback
- with the permission details that were accepted.RealmAsyncTask
that can be used to cancel the task if needed.public RealmAsyncTask revokeOffer(String offerToken, PermissionManager.RevokeOfferCallback callback)
offerToken
- token that should be revoked.RealmAsyncTask
that can be used to cancel the task if needed.public RealmAsyncTask getCreatedOffers(PermissionManager.OffersCallback callback)
revokeOffer(String, RevokeOfferCallback)
or sent to other users by sending the
PermissionOffer.getToken()
.RealmAsyncTask
that can be used to cancel the task if needed.public void close()
close
in interface Closeable
close
in interface AutoCloseable
public boolean isClosed()
true
if the PermissionManager is closed, false
if it is still open.