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

com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserAttributes 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.AttributeType;

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

/**
 * Encapsulates all user attributes and provides methods to access them.
 */
public class CognitoUserAttributes {
    /**
     * All attributes set for a user.
     */
    private Map userAttributes;

    /**
     *  Multi-factor authentication options set for a user.
     */
    private Map mfaOptions;

    /**
     * Public constructor, creates an "empty container".
     * Use {@link CognitoUserAttributes#addAttribute(String, String)} method to add user attributes.
     */
    public CognitoUserAttributes() {
        this(null);
    }

    /**
     * Constructor for internal use.
     *
     * @param userAttributes    REQUIRED: Cognito user attributes as a list.
     */
    protected CognitoUserAttributes(List userAttributes) {
        this.userAttributes = new HashMap();
        if (userAttributes != null) {
            for (AttributeType attribute : userAttributes) {
                this.userAttributes.put(attribute.getName(), attribute.getValue());
            }
        }
    }

    /**
     * Adds an attribute to this object.
     * 

* Will add the attribute and its value. Overrides an earlier value set for an attribute * which was already added to this object. *

* * @param attributeName REQUIRED: The attribute name. * @param value REQUIRED: Value for the attribute. */ public void addAttribute(String attributeName, String value) { userAttributes.put(attributeName, value); } /** * Returns the user attributes as a key, value pairs. * * @return User attributes as key, value pairs */ public Map getAttributes() { return userAttributes; } /** * Returns the user attributes as a {@link AttributeType} list. * * @return {@link AttributeType} Cognito user attributes as a list. */ protected List getAttributesList() { List attributesList = new ArrayList(); if (userAttributes != null) { for (Map.Entry detail : userAttributes.entrySet()) { AttributeType attribute = new AttributeType(); attribute.setName(detail.getKey()); attribute.setValue(detail.getValue()); attributesList.add(attribute); } } return attributesList; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy