Example usage for com.amazonaws.services.identitymanagement.model ListMFADevicesRequest ListMFADevicesRequest

List of usage examples for com.amazonaws.services.identitymanagement.model ListMFADevicesRequest ListMFADevicesRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.identitymanagement.model ListMFADevicesRequest ListMFADevicesRequest.

Prototype

public ListMFADevicesRequest(String userName) 

Source Link

Document

Constructs a new ListMFADevicesRequest object.

Usage

From source file:com.vb.aws.services.si.iam.IamUtilsImpl.java

/**
 * Checks if user MFA is enabled or not.
 * @param user/*from   w  w  w.  j  av a 2s.  com*/
 * @return returns true, if MFA is enabled for the user.
 */
public Boolean isMFAEnabled(User user) throws AmazonClientException {

    Boolean mfaDeviceEnabled = false;
    try {
        if (user != null) {
            ListMFADevicesRequest listMFADevicesRequest = new ListMFADevicesRequest(user.getUserName());
            ListMFADevicesResult listMFADevicesResult = this.iamClient.listMFADevices(listMFADevicesRequest);
            if (listMFADevicesResult.getMFADevices().size() > 0) {
                mfaDeviceEnabled = true;
            }
        }

    } catch (AmazonClientException e) {
        System.out.println("ERROR : Fetching list of MFA Devices.");
        e.printStackTrace();
        throw e;
    }
    //System.out.println("INFO : MFA enabled for the user? " + mfaDeviceEnabled);
    return mfaDeviceEnabled;

}