use of com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.GenericHandler in project aws-sdk-android by aws-amplify.
the class CognitoUser method deleteAttributesInBackground.
/**
* Deletes user attributes, in background.
*
* @param attributeNamesToDelete REQUIRED: List of user attributes that have
* to be deleted.
* @param callback REQUIRED: {@link GenericHandler} callback
*/
public void deleteAttributesInBackground(final List<String> attributeNamesToDelete, final GenericHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser user = this;
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
final CognitoUserSession session = user.getCachedSession();
deleteAttributesInternal(attributeNamesToDelete, session);
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess();
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.GenericHandler in project aws-sdk-android by aws-amplify.
the class CognitoUser method changePasswordInBackground.
/**
* Request to change password for this user, in background.
* <p>
* This operation requires a valid accessToken.
* Un-authenticated users will have
* to be authenticated before calling this method.
* </p>
*
* @param oldUserPassword REQUIRED: Current password of this user.
* @param newUserPassword REQUIRED: New password for this user.
* @param callback REQUIRED: {@link GenericHandler} callback handler.
*/
public void changePasswordInBackground(final String oldUserPassword, final String newUserPassword, final GenericHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser user = this;
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
final CognitoUserSession session = user.getCachedSession();
changePasswordInternal(oldUserPassword, newUserPassword, session);
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess();
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.GenericHandler in project aws-sdk-android by aws-amplify.
the class CognitoUser method setUserMfaSettingsInBackground.
/**
* Sets preferences for the registered MFA's of a user.
* @param mfaSettings Required: A list with all MFA settings.
* @param callback Required: {@link GenericHandler} callback.
*/
public void setUserMfaSettingsInBackground(final List<CognitoMfaSettings> mfaSettings, final GenericHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUserSession session = this.getCachedSession();
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
setUserMfaSettingsInternal(mfaSettings, session);
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess();
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.GenericHandler in project aws-sdk-android by aws-amplify.
the class CognitoUser method setUserSettingsInBackground.
/**
* Set's user settings, in background.
*
* @param cognitoUserSettings REQUIRED: User settings as
* {@link CognitoUserSettings}.
* @param callback REQUIRED: {@link GenericHandler} callback.
*/
public void setUserSettingsInBackground(final CognitoUserSettings cognitoUserSettings, final GenericHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUserSession session = this.getCachedSession();
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
setUserSettingsInternal(cognitoUserSettings, session);
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess();
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.GenericHandler in project aws-sdk-android by aws-amplify.
the class CognitoUser method globalSignOutInBackground.
/**
* Sign-out from all devices associated with this user, in background.
*
* @param callback REQUIRED: {@link GenericHandler} callback.
*/
public void globalSignOutInBackground(final GenericHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser user = this;
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
final CognitoUserSession session = user.getCachedSession();
globalSignOutInternal(session);
returnCallback = new Runnable() {
@Override
public void run() {
signOut();
callback.onSuccess();
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
Aggregations