Ejemplo n.º 1
0
        public bool ProcessLink()
        {
            //if (SuppressProcessLink)
            //    return;

            try
            {
                string arg = Arg.TrimEnd('/'); // copy so modifications arent permanent

                CreateUser user = null;

                if (arg.Contains("/invite/"))
                    user = ReadInvite(arg);

                // public network
                else if (arg.Replace("deops://", "").IndexOf('/') == -1)
                    user = new CreateUser(App, arg, AccessType.Public);

                // show create user dialog
                if (user != null)
                {
                    user.ShowDialog(this);
                    return true;
                }
            }
            catch { }

            return false;
        }
Ejemplo n.º 2
0
        private CreateUser ReadInvite(string link)
        {
            string[] mainParts = link.Replace("deops://", "").Split('/');

            if (mainParts.Length < 4)
                throw new Exception("Invalid Link");

            // Select John Marshall's Global IM Profile
            string[] nameParts = mainParts[2].Split('@');
            string name = HttpUtility.UrlDecode(nameParts[0]);
            string op = HttpUtility.UrlDecode(nameParts[1]);

            byte[] data = Utilities.HextoBytes(mainParts[3]);
            byte[] pubOpID = Utilities.ExtractBytes(data, 0, 8);
            byte[] encrypted = Utilities.ExtractBytes(data, 8, data.Length - 8);
            byte[] decrypted = null;

            // try opening invite with a currently loaded core
            Context.Cores.LockReading(delegate()
            {
                foreach (var core in Context.Cores)
                    try
                    {
                        if (Utilities.MemCompare(pubOpID, core.User.Settings.PublicOpID))
                            decrypted = core.User.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch { }
            });

            // have user select profile associated with the invite
            while (decrypted == null)
            {
                OpenFileDialog open = new OpenFileDialog();

                open.Title = "Open " + name + "'s " + op + " Profile to Verify Invitation";
                open.InitialDirectory = Application.StartupPath;
                open.Filter = "DeOps Identity (*.dop)|*.dop";

                if (open.ShowDialog() != DialogResult.OK)
                    return null; // user doesnt want to try any more

                GetTextDialog pass = new GetTextDialog("Passphrase", "Enter the passphrase for this profile", "");
                pass.ResultBox.UseSystemPasswordChar = true;

                if (pass.ShowDialog() != DialogResult.OK)
                    continue; // let user choose another profile

                try
                {
                    // open profile
                    var user = new OpUser(open.FileName, pass.ResultBox.Text, null);
                    user.Load(LoadModeType.Settings);

                    // ensure the invitation is for this op specifically
                    if (!Utilities.MemCompare(pubOpID, user.Settings.PublicOpID))
                    {
                        MessageBox.Show("This is not a " + op + " profile");
                        continue;
                    }

                    // try to decrypt the invitation
                    try
                    {
                        decrypted = user.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch
                    {
                        MessageBox.Show("Could not open the invitation with this profile");
                        continue;
                    }
                }
                catch
                {
                    MessageBox.Show("Wrong password");
                }
            }

            CreateUser created = null;

            try
            {
                InvitePackage invite = OpCore.OpenInvite(decrypted, Protocol);

                if(invite != null)
                    created = new CreateUser(App, invite);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return created;
        }
Ejemplo n.º 3
0
        private void CreateLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CreateOp form = new CreateOp();

            if (form.ShowDialog(this) != DialogResult.OK)
                return;

            CreateUser create = new CreateUser(App, form.OpName, form.OpAccess);

            if (create.ShowDialog(this) == DialogResult.OK)
                Close();
        }
Ejemplo n.º 4
0
        private void JoinLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            JoinOp join = new JoinOp();

            if (join.ShowDialog(this) != DialogResult.OK)
                return;

            CreateUser user = null;

            // private or secret network
            if (join.OpLink.Contains("/invite/"))
                user = ReadInvite(join.OpLink);

            // public network
            else
                user = new CreateUser(App, join.OpLink, join.OpAccess);

            // show create user dialog
            if (user != null && user.ShowDialog(this) == DialogResult.OK)
                Close();
        }
Ejemplo n.º 5
0
        private void CreateGlobalLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CreateUser form = new CreateUser(App, "Global IM", AccessType.Secret);
            form.GlobalIM = true;

            if (form.ShowDialog(this) == DialogResult.OK)
                Close();
        }