Exemplo n.º 1
0
        /// <summary>
        /// Adds an identity to an agent listener.
        /// </summary>
        /// <param name="listener">The listener to add the identity to.</param>
        /// <param name="pool">The pool.</param>
        /// <param name="wallet">The wallet.</param>
        /// <param name="did">The DID of the identity to add.</param>
        /// <returns>An asynchronous task that returns no value.</returns>
        private static Task AgentAddIdentityAsync(Listener listener, Pool pool, Wallet wallet, string did)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();
            var commandHandle        = AddTaskCompletionSource(taskCompletionSource);

            var result = IndyNativeMethods.indy_agent_add_identity(
                commandHandle,
                listener.Handle,
                pool.Handle,
                wallet.Handle,
                did,
                _noValueCallback
                );

            CheckResult(result);

            return(taskCompletionSource.Task);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds an identity to the listener.
        /// </summary>
        /// <remarks>
        /// <para>Although an AgentListner instance can listen for incoming connections on a specified
        /// endpoint, any incoming connection to an identity not associated with the listener will be
        /// automatically rejected.  This method adds an identity to the listener that will be authorized
        /// to accept connections.
        /// </para>
        /// <para>This method will perform a <see cref="Wallet"/> lookup to find the identity information
        /// for the DID to add and consequently the DID must have already been saved in the wallet using
        /// the <see cref="Hyperledger.Indy.SignusApi.CreateAndStoreMyDidResult"/> method prior to attempting to
        /// add it to the listener.
        /// </para>
        /// <para>Authorization to accept incoming connections to a DID on a listener can be removed using
        /// the <see cref="RemoveIdentityAsync(Wallet, string)"/> method.
        /// </para>
        /// </remarks>
        /// <seealso cref="Signus"/>
        /// <param name="pool">The node pool that will be used to verify the identity.</param>
        /// <param name="wallet">The Wallet that contains the identity.</param>
        /// <param name="did">The DID of the identity to authorize connections to.</param>
        /// <returns>An asynchronous <see cref="Task"/> completes once the operation completes.</returns>
        public Task AddIdentityAsync(Pool pool, Wallet wallet, string did)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = IndyNativeMethods.indy_agent_add_identity(
                commandHandle,
                Handle,
                pool.Handle,
                wallet.Handle,
                did,
                CallbackHelper.TaskCompletingNoValueCallback
                );

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }