public async Task Handle(object command)
 {
     switch (command)
     {
     case ContextCommands.Provision cmd:
         var provisioner          = Provision.v0_7(cmd.Token);
         var ctx                  = ContextBuilder.fromScratch(cmd.WalletId, cmd.WalletKey, cmd.VerityApplicationEndpoint);
         var provisioningResponse = provisioner.provision(ctx);
         var context              = new Context(provisioningResponse);
         _repository.Add(context);
         break;
     }
 }
Пример #2
0
        Context provisionAgent()
        {
            ProvisionV0_7 provisioner;

            if (consoleYesNo("Provide Provision Token", true))
            {
                string token = consoleInput("Token", Environment.GetEnvironmentVariable("TOKEN")).Trim();
                App.coloredConsoleOutput(token, "Using provision token: ");
                provisioner = Provision.v0_7(token);
            }
            else
            {
                provisioner = Provision.v0_7();
            }

            string verityUrl = consoleInput("Verity Application Endpoint", Environment.GetEnvironmentVariable("VERITY_SERVER")).Trim();

            if ("".Equals(verityUrl))
            {
                verityUrl = "http://localhost:9000";
            }

            App.coloredConsoleOutput(verityUrl, "Using Verity Application Endpoint Url: ");

            // create initial Context
            Context ctx = ContextBuilder.fromScratch("examplewallet1", "examplewallet1", verityUrl);

            // ask that an agent by provision (setup) and associated with created key pair
            Context provisioningResponse = null;

            try
            {
                provisioningResponse = provisioner.provision(ctx);
            }
            catch (ProvisionTokenException e)
            {
                App.consoleOutput(e.ToString());
                App.consoleOutput("Provisioning failed! Likely causes:");
                App.consoleOutput("- token not provided but Verity Endpoint requires it");
                App.consoleOutput("- token provided but is invalid or expired");

                throw new Exception();
            }

            return(provisioningResponse);
        }
Пример #3
0
        public void createMessage()
        {
            Context context = TestHelpers.getContext();

            ProvisionV0_7 p   = Provision.v0_7();
            JsonObject    msg = p.provisionMsg(context);

            Assert.AreEqual(msg.getAsString("requesterVk"), context.SdkVerKey());


            string        goodToken = "{\"sponseeId\": \"myId\", \"sponsorId\": \"evernym-test-sponsorabc123\", \"nonce\": \"123\", \"timestamp\": \"2020-06-05T21:33:36.085Z\", \"sig\": \"ZkejifRr3txh7NrKokC5l2D2YcABUlGlAoFHZD9RapHHBfVtNnHgYux1RCAiEh4Q31VJE3C92T1ZnqDm1WlEAA==\", \"sponsorVerKey\": \"GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL\"}";
            ProvisionV0_7 p2        = Provision.v0_7(goodToken);

            JsonObject msg2 = p2.provisionMsg(context);

            Assert.IsTrue(msg2.ContainsKey("provisionToken"));
        }
Пример #4
0
        public void testGetThreadId()
        {
            ProvisionV0_7 testProtocol = Provision.v0_7();

            Assert.IsNotNull(testProtocol.getThreadId());
        }