Ejemplo n.º 1
0
        private void button_AccessTokenDetail_Click(object sender, EventArgs e)
        {
            DetailedTokenViewer viewer = new DetailedTokenViewer(rawAccessToken);

            viewer.ShowDialog();

            DialogResult = DialogResult.None;
        }
Ejemplo n.º 2
0
        private void button_AccessTokenDetail_Click(object sender, EventArgs e)
        {
            // 1. Try to decode the ID Token and the Access Token.
            // 2. Select a token and open a detail window.

            string idToken     = (rawIdToken != "" && rawIdToken != null) ? rawIdToken : textBox_IdToken.Text;
            string accessToken = (rawAccessToken != "" && rawAccessToken != null) ? rawAccessToken : textBox_AccessToken.Text;

            Tuple <bool, string, string, string> decodedIdToken     = TryDecodeToken(idToken);
            Tuple <bool, string, string, string> decodedAccessToken = TryDecodeToken(accessToken);

            if (decodedIdToken.Item1 == true)
            {
                if (decodedAccessToken.Item1 == true)
                {
                    // IdToken : Valid
                    // AccessToken : Valid

                    DialogResult dialogResult = MessageBox.Show("Do you want to see the detail of Access Token?" + Environment.NewLine + "If you want to see the detail of ID Token, click [no].", "Office365APIEditor", MessageBoxButtons.YesNoCancel);

                    if (dialogResult == DialogResult.Yes)
                    {
                        DetailedTokenViewer viewer = new DetailedTokenViewer(decodedAccessToken);

                        viewer.ShowDialog();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        DetailedTokenViewer viewer = new DetailedTokenViewer(decodedIdToken);

                        viewer.ShowDialog();
                    }
                }
                else
                {
                    // IdToken : Valid
                    // AccessToken : Invalid

                    DialogResult dialogResult = MessageBox.Show("You can see the detail of ID Token.", "Office365APIEditor", MessageBoxButtons.OKCancel);

                    if (dialogResult == DialogResult.OK)
                    {
                        DetailedTokenViewer viewer = new DetailedTokenViewer(decodedIdToken);

                        viewer.ShowDialog();
                    }
                }
            }
            else
            {
                if (decodedAccessToken.Item1 == true)
                {
                    // IdToken : Invalid
                    // AccessToken : Valid

                    DialogResult dialogResult = MessageBox.Show("You can see the detail of Access Token.", "Office365APIEditor", MessageBoxButtons.OKCancel);

                    if (dialogResult == DialogResult.OK)
                    {
                        DetailedTokenViewer viewer = new DetailedTokenViewer(decodedAccessToken);

                        viewer.ShowDialog();
                    }
                }
                else
                {
                    // IdToken : Invalid
                    // AccessToken : Invalid

                    MessageBox.Show("Decoding of both ID Token and Access Token failed.", "Office365APIEditor");
                }
            }

            DialogResult = DialogResult.None;
        }