Example #1
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.textBoxSearchKeyword.Text))
                {
                    MessageBox.Show("You must enter a search keyword");
                    return;
                }
                if (this.keyPair == null)
                {
                    MessageBox.Show("You must load user keys first");
                    return;
                }

                Guid attributeId = GuidCreator.CreateGuidFromString(this.textBoxSearchKeyword.Text);

                IGatewayService proxy = CreateServiceProxy();
                this.searchResults = proxy.SearchForDataEntities(this.myId, attributeId);

                if (RefreshRoles(this.rolesUserControlDownload))
                {
                    DecryptSearchResultsMetadata();

                    ShowSearchResults();

                    MessageBox.Show("Search complete");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error searching for entities", ex);
            }
        }
Example #2
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.textBoxSearchKeyword.Text))
                {
                    MessageBox.Show("You must enter a search keyword");
                    return;
                }
                if (!this.userkeysLoaded)
                {
                    MessageBox.Show("You must load user keys first");
                    return;
                }

                Guid attributeId = GuidCreator.CreateGuidFromString(this.textBoxSearchKeyword.Text);

                IGatewayService proxy = CreateServiceProxy();
                this.searchResults = proxy.FindData(GetUserIdentity(), attributeId);

                DecryptSearchResultsMetadata();

                ShowSearchResults();

                MessageBox.Show("Search complete");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error searching for entities", ex);
            }
        }
Example #3
0
 private void textBoxTestName_TextChanged(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.textBoxTestName.Text))
     {
         this.labelTestId.Text = GuidCreator.CreateGuidFromString(this.textBoxTestName.Text).ToString();
     }
     else
     {
         this.labelTestId.Text = string.Empty;
     }
 }
Example #4
0
        private void buttonGenerateKeypairsForUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.textBoxNewUserId.Text))
                {
                    MessageBox.Show("You must enter a username");
                    return;
                }
                this.newUserId = GuidCreator.CreateGuidFromString(this.textBoxNewUserId.Text);

                if (this.masterKeypair == null)
                {
                    MessageBox.Show("You must load master key pair first");
                    return;
                }

                string filename = FileDialogs.AskUserForFileNameToSaveIn();
                if (!string.IsNullOrEmpty(filename))
                {
                    if (!Path.HasExtension(filename))
                    {
                        filename = filename + ".xml";
                    }


                    this.signKeyPair = DataSigner.GenerateSignKeyPair();

                    IPreService proxy = GetPreProxy();
                    this.userKeypair = proxy.GenerateKeyPair();

                    proxy = GetPreProxy();
                    this.delegationToken.ToUser = proxy.GenerateDelegationKey(this.masterKeypair.Private, this.userKeypair.Public);

                    IGatewayService gateWayproxy = GetServiceProxy();
                    gateWayproxy.RegisterUser(this.myId, this.newUserId, this.delegationToken, this.signKeyPair.PublicOnly);


                    UserKeys uk = new UserKeys();
                    uk.MasterKeyPublicKey = Convert.ToBase64String(this.masterKeypair.Public);
                    uk.UserPrivateKey     = Convert.ToBase64String(this.userKeypair.Private);
                    uk.UserSignKeys       = Convert.ToBase64String(this.signKeyPair.PublicAndPrivate);

                    XmlFile.WriteFile(uk, filename);

                    MessageBox.Show("Done");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                Logger.LogError("Error generating user keypair", ex);
            }
        }
Example #5
0
 private Guid GetUserIdentity()
 {
     return(GuidCreator.CreateGuidFromString(this.textBoxYourName.Text));
 }