Esempio n. 1
0
        void setupIssuer()
        {
            // constructor for the Issuer Setup protocol
            IssuerSetupV0_6 newIssuerSetup = IssuerSetup.v0_6();

            // handler for created issuer identifier message
            setupIssuerHandler(newIssuerSetup);

            // request that issuer identifier be created
            newIssuerSetup.create(context);

            // wait for request to complete
            WaitFor(ref setup_complete, "Waiting for setup to complete");

            App.consoleOutput("The issuer DID and Verkey must be on the ledger.");
            App.consoleOutput("Issuer DID: " + _issuerDID);
            App.consoleOutput("Issuer Verkey: " + _issuerVerkey);
            App.consoleOutput("The issuer DID and Verkey must be on the ledger.");

            bool automatedRegistration = consoleYesNo("Attempt automated registration via https://selfserve.sovrin.org", true);

            if (automatedRegistration)
            {
                HttpClient client = new HttpClient();

                var request = new HttpRequestMessage(HttpMethod.Post, "https://selfserve.sovrin.org/nym");

                JsonObject payload_builder = new JsonObject();
                payload_builder.Add("network", "stagingnet");
                payload_builder.Add("did", _issuerDID);
                payload_builder.Add("verkey", _issuerVerkey);
                payload_builder.Add("paymentaddr", "");
                string payload = payload_builder.ToString();

                request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
                request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var response = client.PostAsync(request.RequestUri, request.Content).GetAwaiter().GetResult();
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var data = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                    App.consoleOutput($"Got response from Sovrin portal: {data}");
                }
                else
                {
                    App.consoleOutput("Something went wrong with contactig Sovrin portal");
                    App.consoleOutput($"Please add DID ({_issuerDID}) and Verkey ({_issuerVerkey}) to ledger manually");

                    WaitReturn("Press ENTER when DID is on ledger");
                }
            }
            else
            {
                App.consoleOutput($"Please add DID ({_issuerDID}) and Verkey ({_issuerVerkey}) to ledger manually");

                WaitReturn("Press ENTER when DID is on ledger");
            }
        }
Esempio n. 2
0
 public void testCreate()
 {
     withContext(context =>
     {
         IssuerSetupV0_6 testProtocol = IssuerSetup.v0_6();
         byte[] message             = testProtocol.createMsgPacked(context);
         JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, message);
         Assert.AreEqual(
             "did:sov:123456789abcdefghi1234;spec/issuer-setup/0.6/create",
             unpackedMessage.getAsString("@type"));
     });
 }
Esempio n. 3
0
        public void testCreateMessages()
        {
            Context         context = TestHelpers.getContext();
            IssuerSetupV0_6 p       = IssuerSetup.v0_6();
            JsonObject      msg     = p.createMsg(context);

            Assert.AreEqual(
                "did:sov:123456789abcdefghi1234;spec/issuer-setup/0.6/create",
                msg.getAsString("@type")
                );
            Assert.IsNotNull(msg.getAsString("@id"));
        }
Esempio n. 4
0
 public void testCreate()
 {
     withContext(context =>
     {
         IssuerSetupV0_6 testProtocol = IssuerSetup.v0_6();
         byte[] message             = testProtocol.createMsgPacked(context);
         JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, message);
         Assert.AreEqual(
             Util.EVERNYM_MSG_QUALIFIER + "/issuer-setup/0.6/create",
             unpackedMessage.getAsString("@type"));
     });
 }
Esempio n. 5
0
        public void testCreateMessages()
        {
            Context         context = TestHelpers.getContext();
            IssuerSetupV0_6 p       = IssuerSetup.v0_6();
            JsonObject      msg     = p.createMsg(context);

            Assert.AreEqual(
                Util.EVERNYM_MSG_QUALIFIER + "/issuer-setup/0.6/create",
                msg.getAsString("@type")
                );
            Assert.IsNotNull(msg.getAsString("@id"));
        }
Esempio n. 6
0
        void issuerIdentifier()
        {
            // constructor for the Issuer Setup protocol
            IssuerSetupV0_6 issuerSetup = IssuerSetup.v0_6();

            issuerIdentifierHandler(issuerSetup);

            // query the current identifier
            issuerSetup.currentPublicIdentifier(context);

            // wait for response from verity-application
            WaitFor(ref issuerComplete, "Waiting for current issuer DID");
        }
Esempio n. 7
0
        public void testGetMessageType()
        {
            string msgName = "msg name";

            IssuerSetupV0_6 t = IssuerSetup.v0_6();

            string expectedType = Util.getMessageType(
                Util.EVERNYM_MSG_QUALIFIER,
                t.family(),
                t.version(),
                msgName);

            Assert.AreEqual(expectedType, t.messageType(msgName));
        }
Esempio n. 8
0
 void issuerIdentifierHandler(IssuerSetupV0_6 handler)
 {
     // handler for current issuer identifier message
     handlers.addHandler(
         handler,
         (msgName, message) =>
     {
         if ("public-identifier".Equals(msgName))
         {
             App.consolePrintMessage(msgName, message);
             _issuerDID    = message.GetValue("did");
             _issuerVerkey = message.GetValue("verKey");
         }
         ;
         issuerComplete = true;
     }
         );
 }
Esempio n. 9
0
        void setupIssuerHandler(IssuerSetupV0_6 handler)
        {
            handlers.addHandler(
                handler,
                (msgName, message) =>
            {
                if ("public-identifier-created".Equals(msgName))
                {
                    App.consolePrintMessage(msgName, message);

                    var json_identifier = message.GetValue("identifier");
                    _issuerDID          = json_identifier["did"];
                    _issuerVerkey       = json_identifier["verKey"];
                    setup_complete      = true;
                }
                else
                {
                    App.nonHandled(msgName, message);
                }
            }
                );
        }
Esempio n. 10
0
        public void testGetThreadId()
        {
            IssuerSetupV0_6 testProtocol = IssuerSetup.v0_6();

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