All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserSettings Maven / Gradle / Ivy

Go to download

The AWS Android SDK for Amazon Cognito Identity Provider module holds the client classes that are used for communicating with Amazon Cognito Identity Provider Service

There is a newer version: 2.79.0
Show newest version
/*
 * Copyright 2013-2016 Amazon.com,
 * Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Amazon Software License (the "License").
 * You may not use this file except in compliance with the
 * License. A copy of the License is located at
 *
 *     http://aws.amazon.com/asl/
 *
 * or in the "license" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, express or implied. See the License
 * for the specific language governing permissions and
 * limitations under the License.
 */

package com.amazonaws.mobileconnectors.cognitoidentityprovider;

import com.amazonaws.services.cognitoidentityprovider.model.MFAOptionType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * This class encapsulates all settings for a user.
 */
public class CognitoUserSettings {
    /**
     * User Settings.
     */
    private Map userSettings;

    /**
     * Constructs an "empty" user settings object.
     */
    public CognitoUserSettings() {
        this(null);
    }

    /**
     * Constructs from MFAOptionType List.
     *
     * @param userSettingsList      REQUIRED: User settings as a {@link MFAOptionType} list.
     */
    protected CognitoUserSettings(List userSettingsList) {
        this.userSettings = new HashMap();
        if (userSettingsList != null) {
            for (MFAOptionType option : userSettingsList) {
                userSettings.put(option.getAttributeName().toString(), option.getDeliveryMedium().toString());
            }
        }
    }

    /**
     * Returns a MFAOptionType list.
     *
     * @return User settings as a {@link MFAOptionType} list.
     */
    protected List getSettingsList() {
        List settingsList = new ArrayList();
        if (userSettings != null) {
            for (Map.Entry detail : userSettings.entrySet()) {
                MFAOptionType option = new MFAOptionType();
                option.setAttributeName(detail.getKey());
                option.setDeliveryMedium(detail.getValue());
                settingsList.add(option);
            }
        }
        return  settingsList;
    }

    /**
     * Return user settings as key, value pairs.
     *
     * @return user settings as a key, value pairs.
     */
    public Map getSettings() {
        return userSettings;
    }

    /**
     * Sets user settings.
     * 

* Add a new setting for this user. This will override an earlier value set for an attribute * in this object. *

* * @param attributeName REQUIRED: User's attribute name, whose setting is being changed * @param option REQUIRED: The value of the setting. */ public void setSettings(String attributeName, String option) { userSettings.put(attributeName, option); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy