Exemple #1
0
 public Credential(DataSet.TitleRow title)
 {
     CredentialTableAdapter ta = new CredentialTableAdapter();
     foreach (DataSet.CredentialRow row in ta.GetDataByTitleId(title.Id))
     {
         if (row.Kind == ApnsPkcs12FilePathKind)
         {
             apnsPkcs12FilePath = row.Body;
         }
         else if (row.Kind == ApnsPkcs12FilePasswordKind)
         {
             apnsPkcs12FilePassword = row.Body;
         }
         else if (row.Kind == ApnsIsSandboxKind)
         {
             apnsIsSandbox = bool.Parse(row.Body);
         }
         else if (row.Kind == LvlRsaKeyValueKind)
         {
             lvlRsaKeyValue = row.Body;
         }
         else if (row.Kind == LvlPackageNameKind)
         {
             lvlPackageName = row.Body;
         }
     }
 }
        public void Test_IsOK()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                TitleTableAdapter tta = new TitleTableAdapter();
                tta.Insert("test title", "test push message", "test dir", "test dir");
                DataSet.TitleRow title = tta.GetDataByName("test title")[0];

                CredentialTableAdapter cta = new CredentialTableAdapter();
                DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable();
                cdt.AddCredentialRow(title, Credential.LvlPackageNameKind, "org.kaoriha.flowerflower");
                cta.Update(cdt);
                cdt.AddCredentialRow(title, Credential.LvlRsaKeyValueKind, "<RSAKeyValue><Modulus>lzqteVeU/xQAa5fNe6v/s+HZ2F6IZ953LG3tmKjW7JGzK9BJGaE+s5PZgd0ZFG+q9DWa80PQB2mxRaSoPZwe8ystMErjOoeFdXE5RVTXxBIu4YaqRAKTNcj5ki5qr2emalsBFU5w9CJHRCGta+0ByIR5KyCPvK6wgmDwLdG1MHPxLFgDXHcQmIDAwkhovD9thin9RvyVG4C2zeEwcynYHoEVBPtdeBGX4VxX6KkIGE7hxV1/BQt32j0xrX1luq7YBw9XOAlXehj9oMxg0ZGcYT9dD7CAYDOJvoOoKZL4dmyvBon249dUE2af+QrxfT6dGglRVIVlxaPBC6NixGOc+Q==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
                cta.Update(cdt);

                DateTime now = new DateTime(2011, 10, 14);
                LVLTableAdapter lta = new LVLTableAdapter();
                DataSet.LVLDataTable ldt = new DataSet.LVLDataTable();
                ldt.AddLVLRow(105002991, now);
                lta.Update(ldt);
                DataSet.LVLRow lvl = ldt[0];

                Verifier v = new Verifier(lvl.Id, "3|105002991|org.kaoriha.flowerflower|1|ANlOHQM/Rs23FkGZEoX2p4DicHHRN68KEw==|1316406950698",
                    "IuI1h8lefJGUfkXxleI7hERAiDBp0Rx8ItdKbUd/n9ObLA0odCfN3siqxd82I3MpgEJ6YL+zcK6dwHcjhioGN4nSI0rORIpTOrQt2zbsKWK7DAvlefeY3BDPTtm/73Z2gNVt1cv7RIaee/eVARMA8o0J5mxijoAkA6wybEW4fxpHZKG1sFH2UyNz8eZ1hEBg8YLi4yGKI2HNrTSgHgmTUXoT30qbjXf91jvqL2rSdtbHTHibDmKmu7kp+gk0H8eNRijmNwAQqoEGMPhqyv18tpth7UWNb0GnG0f+RYJDVyLhT84Iy+g3wN+JPjXGAADVVotOTTMuec113FlF1wvsIA==", now);
                Expect(v.IsOK(), Is.EqualTo(true));

                Verifier v2 = new Verifier(lvl.Id, "1|105002991|org.kaoriha.flowerflower|1|ANlOHQM/Rs23FkGZEoX2p4DicHHRN68KEw==|1316406950698",
                    "IuI1h8lefJGUfkXxleI7hERAiDBp0Rx8ItdKbUd/n9ObLA0odCfN3siqxd82I3MpgEJ6YL+zcK6dwHcjhioGN4nSI0rORIpTOrQt2zbsKWK7DAvlefeY3BDPTtm/73Z2gNVt1cv7RIaee/eVARMA8o0J5mxijoAkA6wybEW4fxpHZKG1sFH2UyNz8eZ1hEBg8YLi4yGKI2HNrTSgHgmTUXoT30qbjXf91jvqL2rSdtbHTHibDmKmu7kp+gk0H8eNRijmNwAQqoEGMPhqyv18tpth7UWNb0GnG0f+RYJDVyLhT84Iy+g3wN+JPjXGAADVVotOTTMuec113FlF1wvsIA==", now);
                Expect(v2.IsOK(), Is.EqualTo(false));

                Verifier v3 = new Verifier(lvl.Id + 1, "3|105002991|org.kaoriha.flowerflower|1|ANlOHQM/Rs23FkGZEoX2p4DicHHRN68KEw==|1316406950698",
                    "IuI1h8lefJGUfkXxleI7hERAiDBp0Rx8ItdKbUd/n9ObLA0odCfN3siqxd82I3MpgEJ6YL+zcK6dwHcjhioGN4nSI0rORIpTOrQt2zbsKWK7DAvlefeY3BDPTtm/73Z2gNVt1cv7RIaee/eVARMA8o0J5mxijoAkA6wybEW4fxpHZKG1sFH2UyNz8eZ1hEBg8YLi4yGKI2HNrTSgHgmTUXoT30qbjXf91jvqL2rSdtbHTHibDmKmu7kp+gk0H8eNRijmNwAQqoEGMPhqyv18tpth7UWNb0GnG0f+RYJDVyLhT84Iy+g3wN+JPjXGAADVVotOTTMuec113FlF1wvsIA==", now);
                Expect(v3.IsOK(), Is.EqualTo(false));
            }
        }
        private void editTitleButton_Click(object sender, EventArgs e)
        {
            if (titleDataGridView.SelectedRows.Count == 0)
            {
                return;
            }
            long titleId = long.Parse(titleDataGridView.SelectedRows[0].Cells[0].Value.ToString());
            DataSet.TitleRow title = titleTableAdapter.GetDataById(titleId)[0];
            Credential c = new Credential(title);
            using (EditTitleForm f = new EditTitleForm(false, ref title, ref c))
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    CredentialTableAdapter cta = new CredentialTableAdapter();
                    DataSet.CredentialDataTable cdt = cta.GetDataByTitleId(title.Id);

                    foreach (DataSet.CredentialRow cr in cdt)
                    {
                        if (cr.Kind == Credential.ApnsPkcs12FilePathKind)
                        {
                            cr.Body = c.ApnsPkcs12FilePath;
                        }
                        if (cr.Kind == Credential.ApnsPkcs12FilePasswordKind)
                        {
                            cr.Body = c.ApnsPkcs12FilePassword;
                        }
                        if (cr.Kind == Credential.ApnsIsSandboxKind)
                        {
                            cr.Body = c.ApnsIsSandbox.ToString();
                        }
                        if (cr.Kind == Credential.LvlRsaKeyValueKind)
                        {
                            cr.Body = c.LvlRsaKeyValue;
                        }
                        if (cr.Kind == Credential.LvlPackageNameKind)
                        {
                            cr.Body = c.LvlPackageName;
                        }
                    }
                    cta.Update(cdt);
                    this.titleTableAdapter.Update(title);
                    this.titleTableAdapter.Fill(this.dataSet.Title);
                }
            }
        }
        public void TestNotification()
        {
            logger.Info("test");
            //            Settings.TestSettings(typeof(NotificationServiceStub), null);
            using (TransactionScope scope = new TransactionScope())
            {
                TitleTableAdapter tta = new TitleTableAdapter();
                DataSet.TitleDataTable tdt = new DataSet.TitleDataTable();
                tdt.AddTitleRow("test title", "test push message", "test site root path", "test standby path");
                tta.Update(tdt);
                DataSet.TitleRow title = tdt[0];

                CredentialTableAdapter cta = new CredentialTableAdapter();
                DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable();
                cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePathKind, SecureConstant.P12File);
                cta.Update(cdt);
                cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePasswordKind, SecureConstant.P12FilePassword);
                cta.Update(cdt);
                cdt.AddCredentialRow(title, Credential.LvlRsaKeyValueKind, "test lvlrsakeyvalue");
                cta.Update(cdt);

                SubscriberTableAdapter sta = new SubscriberTableAdapter();
                DataSet.SubscriberDataTable sdt = new DataSet.SubscriberDataTable();
                sdt.AddSubscriberRow(title, "test authkey", "web", Constant.Ago);
                sta.Update(sdt);
                DataSet.SubscriberRow subscriber = sdt[0];

                APNsTableAdapter ata = new APNsTableAdapter();
                ata.Insert(subscriber.Id, "B9C83DAE377DDEEECB7C9EA662F7BFBC5D3FA95A5AD5E3CD4B0DD843E0D9EBED", false, 0, false);

                ApnsPusher p = ApnsPusher.GetInstance(title);
                p.PushReleaseNotification("test push message 2");
                System.Threading.Thread.Sleep(10000); // �����ɏI������ƒʐM���Ԃɍ���Ȃ��i���ۂɑ��M����ꍇ�j

                DataSet.APNsDataTable adt = ata.GetDataByTitleId(title.Id);
                Expect(adt[0].UnreadRelease, Is.EqualTo(1));
            }
        }
        private DataSet.TitleRow PrepareBasic()
        {
            TitleTableAdapter tta = new TitleTableAdapter();
            tta.Insert("test title", "test push message", "test site root path", "test standby path");
            DataSet.TitleRow title = tta.GetDataByName("test title")[0];

            CredentialTableAdapter cta = new CredentialTableAdapter();
            DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable();
            cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePathKind, "test pkcs12filepath");
            cta.Update(cdt);
            cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePasswordKind, "test pkcs12filepassword");
            cta.Update(cdt);

            SiteConstant.TestSettings(title);

            return title;
        }
        private void NewTitleButton_Click(object sender, EventArgs e)
        {
            DataSet.TitleDataTable dt = new DataSet.TitleDataTable();
            DataSet.TitleRow title = dt.AddTitleRow("", "", "", "");
            Credential c = new Credential();
            using (EditTitleForm f = new EditTitleForm(true, ref title, ref c))
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    titleTableAdapter.Update(dt);
                    CredentialTableAdapter cta = new CredentialTableAdapter();
                    DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable();
                    cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePathKind, c.ApnsPkcs12FilePath);
                    cta.Update(cdt);
                    cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePasswordKind, c.ApnsPkcs12FilePassword);
                    cta.Update(cdt);
                    cdt.AddCredentialRow(title, Credential.ApnsIsSandboxKind, c.ApnsIsSandbox.ToString());
                    cta.Update(cdt);
                    cdt.AddCredentialRow(title, Credential.LvlRsaKeyValueKind, c.LvlRsaKeyValue);
                    cta.Update(cdt);
                    cdt.AddCredentialRow(title, Credential.LvlPackageNameKind, c.LvlPackageName);
                    cta.Update(cdt);

                    this.titleTableAdapter.Fill(this.dataSet.Title);
                    MessageBox.Show("�V�����z�M�^�C�g����lj����܂���");
                }
            }
        }