Esempio n. 1
0
        public void TestAllLogins()
        {
            int good = 0;
            int bad  = 0;
            GateKeeperProvider currentProvider = (GateKeeperProvider)Membership.Provider;
            string             u;
            string             p;

            HarperACL.Authenticator     auth;
            SupportClasses.BaseResponse baseResponse;
            List <HarperACL.Customer>   customers;

            using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
            {
                customers = (from a in context.Customers
                             join b in context.NetMemberships
                             on a.cusID equals b.cusID
                             where a.cusUserName != null &&
                             b.nmbDateEnd >= DateTime.Now &&
                             a.cusFirstName == "" &&
                             a.cusLastName == ""
                             select a).ToList();
            }
            foreach (HarperACL.Customer customer in customers)
            {
                u            = customer.cusUserName;
                p            = currentProvider.GetPassword(u, "");
                p            = HarperCRYPTO.Cryptography.EncryptData(p);
                auth         = new HarperACL.Authenticator(u, p, false, false, false);
                baseResponse = auth.Login();
                if (baseResponse.TypedResponse != null &&
                    baseResponse.TypedResponse.Success &&
                    (baseResponse.TypedResponse as SupportClasses.LoginResponse).Authenticated)
                {
                    good++;
                }
                else
                {
                    bad++;
                }
                System.Threading.Thread.Sleep(10);
            }
            Assert.AreEqual(true, true);
        }
Esempio n. 2
0
        public void BulkEncrypt()
        {
            GateKeeperProvider        currentProvider = (GateKeeperProvider)Membership.Provider;
            string                    u;
            string                    p;
            List <HarperACL.Customer> customers;

            using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
            {
                customers = (from a in context.Customers
                             join b in context.NetMemberships
                             on a.cusID equals b.cusID
                             where  (a.cusEncryptedPassword == null || a.cusEncryptedPassword == "") &&
                             b.nmbDateEnd >= DateTime.Now &&
                             a.cusDateUpdated < DateTime.Now.AddDays(-2)
                             select a).ToList();

                foreach (HarperACL.Customer customer in customers)
                {
                    if (!string.IsNullOrEmpty(customer.cusUserName))
                    {
                        string z = currentProvider.GetPassword(customer.cusUserName, "");
                        if (!string.IsNullOrEmpty(z))
                        {
                            string enc = HarperCRYPTO.Cryptography.EncryptData(z);
                            if (!string.IsNullOrEmpty(enc))
                            {
                                customer.cusEncryptedPassword = enc;
                                customer.cusDateUpdated       = DateTime.Now;
                            }
                        }
                    }
                }
                context.SubmitChanges();
            }
            Assert.AreEqual(true, true);
        }