Пример #1
0
        /// <summary>
        /// Replaces a previously-created access token.
        /// </summary>
        /// <param name="grantor">Token member granting access to her accounts</param>
        /// <param name="granteeAlias">Token member alias acquiring information access</param>
        /// <param name="oldToken">token to replace</param>
        /// <returns>success or failure</returns>
        public static TokenOperationResult ReplaceAccessToken(
            UserMember grantor,
            Alias granteeAlias,
            Token oldToken)
        {
            string accountId = grantor.CreateTestBankAccountBlocking(1000.0, "EUR")
                               .Id();

            // Replace the old access token
            Token newToken = grantor.ReplaceAccessTokenBlocking(
                oldToken,
                AccessTokenBuilder
                .FromPayload(oldToken.Payload)
                .ForAccount(accountId))
                             .Token;

            // Endorse the new access token
            TokenOperationResult status = grantor.EndorseTokenBlocking(newToken, Key.Types.Level.Standard);

            return(status);
        }
Пример #2
0
        /// <summary>
        /// Creates the access token.
        /// </summary>
        /// <returns>The access token.</returns>
        /// <param name="grantor">Grantor.</param>
        /// <param name="accountId">Account identifier.</param>
        /// <param name="granteeAlias">Grantee alias.</param>
        public static Token CreateAccessToken(
            UserMember grantor,
            string accountId,
            Alias granteeAlias)
        {
            // Create an access token for the grantee to access bank
            // account names of the grantor.
            Token accessToken = grantor.CreateAccessTokenBlocking(
                AccessTokenBuilder
                .Create(granteeAlias)
                .ForAccount(accountId)
                .ForAccountBalances(accountId));

            // Grantor endorses a token to a grantee by signing it
            // with her secure private key.
            accessToken = grantor.EndorseTokenBlocking(
                accessToken,
                Key.Types.Level.Standard).Token;

            return(accessToken);
        }