Example usage for com.amazonaws.services.cognitoidp.model ConfirmDeviceResult ConfirmDeviceResult

List of usage examples for com.amazonaws.services.cognitoidp.model ConfirmDeviceResult ConfirmDeviceResult

Introduction

In this page you can find the example usage for com.amazonaws.services.cognitoidp.model ConfirmDeviceResult ConfirmDeviceResult.

Prototype

ConfirmDeviceResult

Source Link

Usage

From source file:io.fineo.client.auth.cognito.CognitoUser.java

License:Open Source License

/**
 * The method confirms a device. If this device can be remembered and if this is a new device,
 * a new device key is generated at the end of a successful authentication. SRP verification is
 * performed by the service, during the next authentication attempts, to identify this device.
 * This method generates the necessary tokens to enable the device SRP verification.
 *
 * @param deviceMetadata        REQUIRED: Metadata for the new device.
 *//*from  w w  w  .j  a v a  2 s.  c o m*/
private ConfirmDeviceResult confirmDevice(final NewDeviceMetadataType deviceMetadata) {
    Map<String, String> deviceSrpVerifiers = CognitoDeviceHelper.generateVerificationParameters(deviceKey,
            deviceMetadata.getDeviceGroupKey());

    ConfirmDeviceResult confirmDeviceResult = new ConfirmDeviceResult();
    confirmDeviceResult.setUserConfirmationNecessary(false);
    try {
        confirmDeviceResult = confirmDeviceInternal(getCachedSession(), deviceMetadata.getDeviceKey(),
                deviceSrpVerifiers.get("verifier"), deviceSrpVerifiers.get("salt"), "Fineo.JDBC");
    } catch (Exception e) {
        LOG.error(TAG, "Device confirmation failed: " + e.getMessage());
        return null;
    }
    this.devices.cacheDevice(usernameInternal, getUserPoolId(), deviceMetadata);
    return confirmDeviceResult;
}