コード例 #1
0
        private static Task <Member> CreateMember(TokenClient tokenClient)
        {
            // An alias is a human-readable way to identify a member, e.g., a domain or email address.
            // If a domain alias is used instead of an email, please contact Token
            // with the domain and member ID for verification.
            // See https://developer.token.io/sdk/#aliases for more information.
            var email = "ascsharp-" + Util.Nonce().ToLower() + "*****@*****.**";
            var alias = new Alias
            {
                Type  = Alias.Types.Type.Email,
                Value = email
            };

            return(tokenClient.CreateMember(alias)
                   .FlatMap(async(mem) =>
            {
                // A member's profile has a display name and picture.
                // The Token UI shows this (and the alias) to the user when requesting access.
                await mem.SetProfile(new Profile
                {
                    DisplayNameFirst = "Demo PFM"
                });
                byte[] pict = System.IO.File.ReadAllBytes(Path.Combine(rootLocation, "Content/southside.png"));
                await mem.SetProfilePicture("image/png", pict);

                return mem;
            }));
        }
コード例 #2
0
        /// <summary>
        /// Creates a TPP member and verifies it using eIDAS certificate.
        ///
        /// </summary>
        /// <param name="client">token client</param>
        /// <param name="tppAuthNumber">authNumber of the TPP</param>
        /// <param name="certificate">base64 encoded eIDAS certificate</param>
        /// <param name="bankId">id of the bank the TPP trying to get access to</param>
        /// <param name="privateKey">private key corresponding to the public key in the certificate</param>
        /// <returns>verified business member</returns>
        public static Member VerifyEidas(
            Tokenio.Tpp.TokenClient client,
            string tppAuthNumber,
            string certificate,
            string bankId,
            byte[] privateKey)
        {
            Algorithm signingAlgorithm = Algorithm.Rs256;
            ISigner   signer           = new Rs256Signer("eidas", privateKey);

            // resolve memberId of the bank TPP is trying to get access to
            string bankMemberId = client
                                  .ResolveAliasBlocking(new Alias {
                Value = bankId, Type = Alias.Types.Type.Bank
            })
                                  .Id;
            // create an eIDAS alias under realm of the target bank
            Alias eidasAlias = new Alias
            {
                Value   = tppAuthNumber.Trim(),
                RealmId = bankMemberId,
                Type    = Alias.Types.Type.Eidas
            };

            // create a member under realm of the bank with eIDAS alias
            Tokenio.Tpp.Member tpp = client.CreateMember(eidasAlias, null, bankMemberId).Result;
            // construct a payload with all the required data
            VerifyEidasPayload payload = new VerifyEidasPayload
            {
                Algorithm   = signingAlgorithm,
                Alias       = eidasAlias,
                Certificate = certificate,
                MemberId    = tpp.MemberId()
            };

            // verify eIDAS
            VerifyEidasResponse response = tpp
                                           .VerifyEidas(payload, signer.Sign(payload))
                                           .Result;

            return(tpp);
        }