use of com.amazonaws.services.cognitoidentityprovider.model.GlobalSignOutRequest in project aws-sdk-android by aws-amplify.
the class CognitoUser method globalSignOutInternal.
/**
* Internal method to Sign-Out from all devices of this user.
*
* @param session REQUIRED: {@link GenericHandler} callback.
*/
private void globalSignOutInternal(CognitoUserSession session) {
// Check if session is valid
if (session == null) {
throw new CognitoNotAuthorizedException("user is not authenticated");
}
if (!session.isValid()) {
throw new CognitoNotAuthorizedException("user is not authenticated");
}
final GlobalSignOutRequest globalSignOutRequest = new GlobalSignOutRequest();
globalSignOutRequest.setAccessToken(getCachedSession().getAccessToken().getJWTToken());
cognitoIdentityProviderClient.globalSignOut(globalSignOutRequest);
}
use of com.amazonaws.services.cognitoidentityprovider.model.GlobalSignOutRequest 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;
}
};
}
Aggregations