Beispiel #1
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateIdentityPool operation.
        /// <seealso cref="Amazon.CognitoIdentity.IAmazonCognitoIdentity.CreateIdentityPool"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <CreateIdentityPoolResponse> CreateIdentityPoolAsync(CreateIdentityPoolRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreateIdentityPoolRequestMarshaller();
            var unmarshaller = CreateIdentityPoolResponseUnmarshaller.GetInstance();

            return(Invoke <IRequest, CreateIdentityPoolRequest, CreateIdentityPoolResponse>(request, marshaller, unmarshaller, signer, cancellationToken));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new identity pool. The identity pool is a store of user identity information
        /// that is specific to your AWS account.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool service method.</param>
        ///
        /// <returns>The response from the CreateIdentityPool service method, as returned by CognitoIdentity.</returns>
        /// <exception cref="InternalErrorException">
        /// Thrown when the service encounters an error during processing the request.
        /// </exception>
        /// <exception cref="InvalidParameterException">
        /// Thrown for missing or bad input parameter(s).
        /// </exception>
        /// <exception cref="LimitExceededException">
        /// Thrown when the total number of user pools has exceeded a preset limit.
        /// </exception>
        /// <exception cref="NotAuthorizedException">
        /// Thrown when a user is not authorized to access the requested resource.
        /// </exception>
        /// <exception cref="ResourceConflictException">
        /// Thrown when a user tries to use a login which is already linked to another account.
        /// </exception>
        /// <exception cref="TooManyRequestsException">
        /// Thrown when a request is throttled.
        /// </exception>
        public CreateIdentityPoolResponse CreateIdentityPool(CreateIdentityPoolRequest request)
        {
            var marshaller   = new CreateIdentityPoolRequestMarshaller();
            var unmarshaller = CreateIdentityPoolResponseUnmarshaller.Instance;

            return(Invoke <CreateIdentityPoolRequest, CreateIdentityPoolResponse>(request, marshaller, unmarshaller));
        }
Beispiel #3
0
        internal CreateIdentityPoolResponse CreateIdentityPool(CreateIdentityPoolRequest request)
        {
            CreateIdentityPoolRequestMarshaller    marshaller = new CreateIdentityPoolRequestMarshaller();
            CreateIdentityPoolResponseUnmarshaller instance   = CreateIdentityPoolResponseUnmarshaller.Instance;

            return(Invoke <CreateIdentityPoolRequest, CreateIdentityPoolResponse>(request, marshaller, instance));
        }
Beispiel #4
0
        private void CreateIdentityPool(out string poolId, out string poolName)
        {
            poolName = "netTestPool" + DateTime.Now.ToFileTime();
            var request = new CreateIdentityPoolRequest
            {
                IdentityPoolName = poolName,
                AllowUnauthenticatedIdentities = true
#if INCLUDE_FACEBOOK_TESTS
                ,
                SupportedLoginProviders = new Dictionary <string, string>()
                {
                    { FacebookProvider, FacebookAppId }
                }
#endif
            };

            var createPoolResult = Client.CreateIdentityPool(request);

            Assert.IsNotNull(createPoolResult.IdentityPoolId);
            Assert.IsNotNull(createPoolResult.IdentityPoolName);
            Assert.AreEqual(request.AllowUnauthenticatedIdentities, createPoolResult.AllowUnauthenticatedIdentities);
            poolId = createPoolResult.IdentityPoolId;
            allPoolIds.Add(poolId);

            var describePoolResult = Client.DescribeIdentityPool(new DescribeIdentityPoolRequest
            {
                IdentityPoolId = poolId
            });

            Assert.AreEqual(poolId, describePoolResult.IdentityPoolId);
            Assert.AreEqual(poolName, describePoolResult.IdentityPoolName);

            var getIdentityPoolRolesResult = Client.GetIdentityPoolRoles(poolId);

            Assert.AreEqual(poolId, getIdentityPoolRolesResult.IdentityPoolId);
            Assert.AreEqual(0, getIdentityPoolRolesResult.Roles.Count);

            var roles = new Dictionary <string, string>(StringComparer.Ordinal);

            if ((poolRoles & PoolRoles.Unauthenticated) == PoolRoles.Unauthenticated)
            {
                roles["unauthenticated"] = PrepareRole();
            }
            if ((poolRoles & PoolRoles.Authenticated) == PoolRoles.Authenticated)
            {
                roles["authenticated"] = PrepareRole();
            }

            Client.SetIdentityPoolRoles(new SetIdentityPoolRolesRequest
            {
                IdentityPoolId = poolId,
                Roles          = roles
            });

            getIdentityPoolRolesResult = Client.GetIdentityPoolRoles(poolId);
            Assert.AreEqual(poolId, getIdentityPoolRolesResult.IdentityPoolId);
            Assert.AreEqual(NumberOfPoolRoles, getIdentityPoolRolesResult.Roles.Count);

            Thread.Sleep(2000);
        }
        IAsyncResult invokeCreateIdentityPool(CreateIdentityPoolRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller   = new CreateIdentityPoolRequestMarshaller();
            var unmarshaller = CreateIdentityPoolResponseUnmarshaller.Instance;

            return(Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer));
        }
Beispiel #6
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateIdentityPool operation.
        /// <seealso cref="Amazon.CognitoIdentity.IAmazonCognitoIdentity"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <CreateIdentityPoolResponse> CreateIdentityPoolAsync(CreateIdentityPoolRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreateIdentityPoolRequestMarshaller();
            var unmarshaller = CreateIdentityPoolResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateIdentityPoolRequest, CreateIdentityPoolResponse>(request, marshaller,
                                                                                       unmarshaller, cancellationToken));
        }
Beispiel #7
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateIdentityPool operation.
        /// <seealso cref="Amazon.CognitoIdentity.IAmazonCognitoIdentity"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool operation on AmazonCognitoIdentityClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateIdentityPool
        ///         operation.</returns>
        public IAsyncResult BeginCreateIdentityPool(CreateIdentityPoolRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new CreateIdentityPoolRequestMarshaller();
            var unmarshaller = CreateIdentityPoolResponseUnmarshaller.Instance;

            return(BeginInvoke <CreateIdentityPoolRequest>(request, marshaller, unmarshaller,
                                                           callback, state));
        }
        public static void CreateIdentityPool(out string poolId, out string poolName)
        {
            poolName = "netTestPool" + DateTime.Now.ToFileTime();
            var request = new CreateIdentityPoolRequest
            {
                IdentityPoolName = poolName,
                AllowUnauthenticatedIdentities = true
            };
            var createPoolResult = Client.CreateIdentityPool(request);

            Assert.IsNotNull(createPoolResult.IdentityPoolId);
            Assert.IsNotNull(createPoolResult.IdentityPoolName);
            Assert.AreEqual(request.AllowUnauthenticatedIdentities, createPoolResult.AllowUnauthenticatedIdentities);
            poolId = createPoolResult.IdentityPoolId;
            allPoolIds.Add(poolId);

            var describePoolResult = Client.DescribeIdentityPool(new DescribeIdentityPoolRequest
            {
                IdentityPoolId = poolId
            });

            Assert.AreEqual(poolId, describePoolResult.IdentityPoolId);
            Assert.AreEqual(poolName, describePoolResult.IdentityPoolName);

            var getIdentityPoolRolesResult = Client.GetIdentityPoolRoles(poolId);

            Assert.AreEqual(poolId, getIdentityPoolRolesResult.IdentityPoolId);
            Assert.AreEqual(0, getIdentityPoolRolesResult.Roles.Count);

            var roles = new Dictionary <string, string>(StringComparer.Ordinal);

            if ((poolRoles & PoolRoles.Unauthenticated) == PoolRoles.Unauthenticated)
            {
                roles["unauthenticated"] = CognitoSync.PrepareRole();
            }
            if ((poolRoles & PoolRoles.Authenticated) == PoolRoles.Authenticated)
            {
                roles["authenticated"] = CognitoSync.PrepareRole();
            }

            Client.SetIdentityPoolRoles(new SetIdentityPoolRolesRequest
            {
                IdentityPoolId = poolId,
                Roles          = roles
            });

            getIdentityPoolRolesResult = Client.GetIdentityPoolRoles(poolId);
            Assert.AreEqual(poolId, getIdentityPoolRolesResult.IdentityPoolId);
            Assert.AreEqual(NumberOfPoolRoles, getIdentityPoolRolesResult.Roles.Count);
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new identity pool. The identity pool is a store of user identity information
        /// that is specific to your AWS account.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool service method.</param>
        ///
        /// <returns>The response from the CreateIdentityPool service method, as returned by CognitoIdentity.</returns>
        /// <exception cref="T:Amazon.CognitoIdentity.Model.InternalErrorException">
        /// Thrown when the service encounters an error during processing the request.
        /// </exception>
        /// <exception cref="T:Amazon.CognitoIdentity.Model.InvalidParameterException">
        /// Thrown for missing or bad input parameter(s).
        /// </exception>
        /// <exception cref="T:Amazon.CognitoIdentity.Model.LimitExceededException">
        /// Thrown when the total number of user pools has exceeded a preset limit.
        /// </exception>
        /// <exception cref="T:Amazon.CognitoIdentity.Model.NotAuthorizedException">
        /// Thrown when a user is not authorized to access the requested resource.
        /// </exception>
        /// <exception cref="T:Amazon.CognitoIdentity.Model.ResourceConflictException">
        /// Thrown when a user tries to use a login which is already linked to another account.
        /// </exception>
        /// <exception cref="T:Amazon.CognitoIdentity.Model.TooManyRequestsException">
        /// Thrown when a request is throttled.
        /// </exception>
        public CreateIdentityPoolResponse CreateIdentityPool(CreateIdentityPoolRequest request)
        {
            var task = CreateIdentityPoolAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateIdentityPool operation.
        /// <seealso cref="Amazon.CognitoIdentity.IAmazonCognitoIdentity"/>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool operation.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// <returns>void</returns>
        public void CreateIdentityPoolAsync(CreateIdentityPoolRequest request, AmazonServiceCallback callback, object state)
        {
            if (!AmazonInitializer.IsInitialized)
            {
                throw new Exception("AWSPrefab is not added to the scene");
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
            {
                var marshaller   = new CreateIdentityPoolRequestMarshaller();
                var unmarshaller = CreateIdentityPoolResponseUnmarshaller.Instance;
                Invoke(request, callback, state, marshaller, unmarshaller, signer);
            }));
            return;
        }
Beispiel #11
0
        public void CreateIdentityPoolAsync(CreateIdentityPoolRequest request, AmazonServiceCallback <CreateIdentityPoolRequest, CreateIdentityPoolResponse> callback, AsyncOptions options = null)
        {
            options = ((options == null) ? new AsyncOptions() : options);
            CreateIdentityPoolRequestMarshaller    marshaller = new CreateIdentityPoolRequestMarshaller();
            CreateIdentityPoolResponseUnmarshaller instance   = CreateIdentityPoolResponseUnmarshaller.Instance;
            Action <AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;

            if (callback != null)
            {
                callbackHelper = delegate(AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao)
                {
                    AmazonServiceResult <CreateIdentityPoolRequest, CreateIdentityPoolResponse> responseObject = new AmazonServiceResult <CreateIdentityPoolRequest, CreateIdentityPoolResponse>((CreateIdentityPoolRequest)req, (CreateIdentityPoolResponse)res, ex, ao.State);
                    callback(responseObject);
                };
            }
            BeginInvoke(request, marshaller, instance, options, callbackHelper);
        }
Beispiel #12
0
        public static void CreateIdentityPool(out string poolId, out string poolName)
        {
            poolName = "netTestPool" + DateTime.Now.ToFileTime();
            var request = new CreateIdentityPoolRequest
            {
                IdentityPoolName = poolName,
                AllowUnauthenticatedIdentities = true,
            };
            var createPoolResult = Client.CreateIdentityPool(request);

            Assert.IsNotNull(createPoolResult.IdentityPoolId);
            Assert.IsNotNull(createPoolResult.IdentityPoolName);
            Assert.AreEqual(request.AllowUnauthenticatedIdentities, createPoolResult.AllowUnauthenticatedIdentities);
            poolId = createPoolResult.IdentityPoolId;
            allPoolIds.Add(poolId);

            var describePoolResult = Client.DescribeIdentityPool(new DescribeIdentityPoolRequest
            {
                IdentityPoolId = poolId
            });

            Assert.AreEqual(poolId, describePoolResult.IdentityPoolId);
            Assert.AreEqual(poolName, describePoolResult.IdentityPoolName);
        }
Beispiel #13
0
        private void CreateIdentityPool(out string poolId, out string poolName)
        {
            AutoResetEvent ars = new AutoResetEvent(false);
            Exception      responseException = new Exception();

            poolName = "unityTestPool" + DateTime.Now.ToFileTime();
            var request = new CreateIdentityPoolRequest
            {
                IdentityPoolName = poolName,
                AllowUnauthenticatedIdentities = true
#if INCLUDE_FACEBOOK_TESTS
                ,
                SupportedLoginProviders = new Dictionary <string, string>()
                {
                    { FacebookProvider, FacebookAppId }
                }
#endif
            };
            string identityPoolId   = null;
            string identityPoolName = null;
            bool   allowUnauthenticatedIdentities = false;

            Client.CreateIdentityPoolAsync(request, (response) =>
            {
                responseException = response.Exception;
                if (response.Exception == null)
                {
                    identityPoolId   = response.Response.IdentityPoolId;
                    identityPoolName = response.Response.IdentityPoolName;
                    allowUnauthenticatedIdentities = response.Response.AllowUnauthenticatedIdentities;
                }
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();
            Utils.AssertExceptionIsNull(responseException);
            Utils.AssertStringIsNotNullOrEmpty(identityPoolId);
            Utils.AssertStringIsNotNullOrEmpty(identityPoolName);
            Utils.AssertTrue(request.AllowUnauthenticatedIdentities == allowUnauthenticatedIdentities);
            poolId = identityPoolId;
            allPoolIds.Add(poolId);

            Client.DescribeIdentityPoolAsync(new DescribeIdentityPoolRequest
            {
                IdentityPoolId = poolId
            }, (response) =>
            {
                responseException = response.Exception;
                if (response.Exception == null)
                {
                    identityPoolId   = response.Response.IdentityPoolId;
                    identityPoolName = response.Response.IdentityPoolName;
                }
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();
            Utils.AssertExceptionIsNull(responseException);
            Utils.AssertTrue(poolId == identityPoolId);
            Utils.AssertTrue(poolName == identityPoolName);

            Dictionary <string, string> roles = null;

            Client.GetIdentityPoolRolesAsync(poolId, (response) =>
            {
                responseException = response.Exception;
                if (response.Exception == null)
                {
                    identityPoolId = response.Response.IdentityPoolId;
                    roles          = response.Response.Roles;
                }
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();
            Utils.AssertExceptionIsNull(responseException);
            Utils.AssertTrue(poolId == identityPoolId);
            Utils.AssertFalse(roles == null);
            Utils.AssertTrue(0 == roles.Count);

            roles = new Dictionary <string, string>(StringComparer.Ordinal);
            if ((poolRoles & PoolRoles.Unauthenticated) == PoolRoles.Unauthenticated)
            {
                roles["unauthenticated"] = PrepareRole();
            }
            if ((poolRoles & PoolRoles.Authenticated) == PoolRoles.Authenticated)
            {
                roles["authenticated"] = PrepareRole();
            }

            Client.SetIdentityPoolRolesAsync(new SetIdentityPoolRolesRequest
            {
                IdentityPoolId = poolId,
                Roles          = roles
            }, (response) =>
            {
                responseException = response.Exception;
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();
            Utils.AssertExceptionIsNull(responseException);

            Client.GetIdentityPoolRolesAsync(poolId, (response) =>
            {
                responseException = response.Exception;
                if (response.Exception == null)
                {
                    identityPoolId = response.Response.IdentityPoolId;
                    roles          = response.Response.Roles;
                }
                ars.Set();
            }, new AsyncOptions {
                ExecuteCallbackOnMainThread = false
            });
            ars.WaitOne();
            Utils.AssertExceptionIsNull(responseException);
            Utils.AssertTrue(poolId == identityPoolId);
            Utils.AssertTrue(NumberOfPoolRoles == roles.Count);

            //Thread.Sleep(2000);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the CreateIdentityPool operation.
 /// <seealso cref="Amazon.CognitoIdentity.IAmazonCognitoIdentity"/>
 /// </summary>
 ///
 /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool operation on AmazonCognitoIdentityClient.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 ///
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateIdentityPool
 ///         operation.</returns>
 public IAsyncResult BeginCreateIdentityPool(CreateIdentityPoolRequest request, AsyncCallback callback, object state)
 {
     return(invokeCreateIdentityPool(request, callback, state, false));
 }
        /// <summary>
        /// Creates a new identity pool. The identity pool is a store of user identity information
        /// that is specific to your AWS account.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateIdentityPool service method.</param>
        ///
        /// <returns>The response from the CreateIdentityPool service method, as returned by CognitoIdentity.</returns>
        /// <exception cref="InternalErrorException">
        /// Thrown when the service encounters an error during processing the request.
        /// </exception>
        /// <exception cref="InvalidParameterException">
        /// Thrown for missing or bad input parameter(s).
        /// </exception>
        /// <exception cref="LimitExceededException">
        /// Thrown when the total number of user pools has exceeded a preset limit.
        /// </exception>
        /// <exception cref="NotAuthorizedException">
        /// Thrown when a user is not authorized to access the requested resource.
        /// </exception>
        /// <exception cref="ResourceConflictException">
        /// Thrown when a user tries to use a login which is already linked to another account.
        /// </exception>
        /// <exception cref="TooManyRequestsException">
        /// Thrown when a request is throttled.
        /// </exception>
        public CreateIdentityPoolResponse CreateIdentityPool(CreateIdentityPoolRequest request)
        {
            IAsyncResult asyncResult = invokeCreateIdentityPool(request, null, null, true);

            return(EndCreateIdentityPool(asyncResult));
        }