use of com.amazonaws.mobile.client.internal.ReturningRunnable in project aws-sdk-android by aws-amplify.
the class DeviceOperations method _getDevice.
private ReturningRunnable<Device> _getDevice(final String deviceKey) {
return new ReturningRunnable<Device>() {
@Override
public Device run() throws Exception {
CognitoDevice cognitoDevice = getCognitoDevice(deviceKey);
final GetDeviceRequest getDeviceRequest = new GetDeviceRequest();
getDeviceRequest.setAccessToken(mobileClient.getTokens().getAccessToken().getTokenString());
getDeviceRequest.setDeviceKey(cognitoDevice.getDeviceKey());
final GetDeviceResult getDeviceResult = userpoolLL.getDevice(getDeviceRequest);
return marshallDeviceTypeToDevice(getDeviceResult.getDevice());
}
};
}
use of com.amazonaws.mobile.client.internal.ReturningRunnable in project aws-sdk-android by aws-amplify.
the class DeviceOperations method _listDevices.
private ReturningRunnable<ListDevicesResult> _listDevices(final Integer limit, final String paginationToken) {
return new ReturningRunnable<ListDevicesResult>() {
@Override
public ListDevicesResult run() throws Exception {
final ListDevicesRequest listDevicesRequest = new ListDevicesRequest();
listDevicesRequest.setAccessToken(mobileClient.getTokens().getAccessToken().getTokenString());
listDevicesRequest.setLimit(limit);
listDevicesRequest.setPaginationToken(paginationToken);
final com.amazonaws.services.cognitoidentityprovider.model.ListDevicesResult listDevicesResult = userpoolLL.listDevices(listDevicesRequest);
final ArrayList<Device> devices = new ArrayList<Device>(limit);
for (DeviceType deviceType : listDevicesResult.getDevices()) {
devices.add(marshallDeviceTypeToDevice(deviceType));
}
return new ListDevicesResult(devices, listDevicesResult.getPaginationToken());
}
};
}
use of com.amazonaws.mobile.client.internal.ReturningRunnable in project aws-sdk-android by aws-amplify.
the class DeviceOperations method _rememberDevice.
private ReturningRunnable<Void> _rememberDevice(final String deviceKey, final boolean rememberDevice) {
return new ReturningRunnable<Void>() {
@Override
public Void run() throws Exception {
CognitoDevice cognitoDevice = getCognitoDevice(deviceKey);
final UpdateDeviceStatusRequest updateDeviceStatusRequest = new UpdateDeviceStatusRequest().withAccessToken(mobileClient.getTokens().getAccessToken().getTokenString()).withDeviceKey(cognitoDevice.getDeviceKey()).withDeviceRememberedStatus(rememberDevice ? DeviceRememberedStatusType.Remembered : DeviceRememberedStatusType.Not_remembered);
userpoolLL.updateDeviceStatus(updateDeviceStatusRequest);
return null;
}
};
}
use of com.amazonaws.mobile.client.internal.ReturningRunnable in project aws-sdk-android by aws-amplify.
the class OAuth2Utils method _signOut.
private ReturningRunnable<Void> _signOut(final SignOutOptions signOutOptions) {
return new ReturningRunnable<Void>() {
@Override
public Void run() throws Exception {
if (signOutOptions.isSignOutGlobally()) {
final GlobalSignOutRequest globalSignOutRequest = new GlobalSignOutRequest();
globalSignOutRequest.setAccessToken(getTokens().getAccessToken().getTokenString());
userpoolLL.globalSignOut(globalSignOutRequest);
}
if (signOutOptions.isInvalidateTokens()) {
if (userpool != null) {
userpool.getCurrentUser().revokeTokens();
}
if (hostedUI != null) {
if (signOutOptions.getBrowserPackage() != null) {
hostedUI.setBrowserPackage(signOutOptions.getBrowserPackage());
}
hostedUI.signOut();
} else if (mOAuth2Client != null) {
final CountDownLatch latch = new CountDownLatch(1);
final JSONObject hostedUIJSON = getHostedUIJSON();
final String signOutUriString = hostedUIJSON.getString("SignOutURI");
final Uri.Builder uriBuilder = Uri.parse(signOutUriString).buildUpon();
if (getHostedUIJSON().optString("SignOutRedirectURI", null) != null) {
uriBuilder.appendQueryParameter("redirect_uri", getHostedUIJSON().getString("SignOutRedirectURI"));
}
final JSONObject signOutQueryParametersJSON = hostedUIJSON.getJSONObject("SignOutQueryParameters");
if (signOutQueryParametersJSON != null) {
final Iterator<String> keysIterator = signOutQueryParametersJSON.keys();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
uriBuilder.appendQueryParameter(key, signOutQueryParametersJSON.getString(key));
}
}
final Exception[] signOutError = new Exception[1];
mOAuth2Client.signOut(uriBuilder.build(), new Callback<Void>() {
@Override
public void onResult(Void result) {
latch.countDown();
}
@Override
public void onError(Exception e) {
signOutError[0] = e;
latch.countDown();
}
});
latch.await();
if (signOutError[0] != null) {
throw signOutError[0];
}
}
}
signOut();
return null;
}
};
}
use of com.amazonaws.mobile.client.internal.ReturningRunnable in project aws-sdk-android by aws-amplify.
the class DeviceOperations method _forgetDevice.
private ReturningRunnable<Void> _forgetDevice(final String deviceKey) {
return new ReturningRunnable<Void>() {
@Override
public Void run() throws Exception {
CognitoDevice cognitoDevice = getCognitoDevice(deviceKey);
final ForgetDeviceRequest forgetDeviceRequest = new ForgetDeviceRequest().withAccessToken(mobileClient.getTokens().getAccessToken().getTokenString()).withDeviceKey(cognitoDevice.getDeviceKey());
userpoolLL.forgetDevice(forgetDeviceRequest);
return null;
}
};
}
Aggregations