Пример #1
0
        public ActionResult Coupon()
        {
            return(View());

            PassGenerator generator = new PassGenerator();

            CouponPassGeneratorRequest request = new CouponPassGeneratorRequest();

            request.PassTypeIdentifier = "pass.passverse.com.public";
            request.CertThumbprint     = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation       = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;
            request.SerialNumber       = "121211";
            request.Description        = "My first pass";
            request.OrganizationName   = "Tomas McGuinness";
            request.TeamIdentifier     = "R5QS56362W";
            request.LogoText           = "My Pass";
            request.BackgroundColor    = "rgb(0,0,0)";
            request.ForegroundColor    = "rgb(255,255,255)";

            request.AssociatedStoreIdentifiers.Add(551768476);

            // override icon and icon retina
            request.Images.Add(PassbookImage.Icon, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/icon.png")));
            request.Images.Add(PassbookImage.IconRetina, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/[email protected]")));

            request.AddBarcode(BarcodeType.PKBarcodeFormatPDF417, "01927847623423234234", "UTF-8", "01927847623423234234");

            byte[] generatedPass = generator.Generate(request);

            return(new FileContentResult(generatedPass, "application/vnd.apple.pkpass"));
        }
Пример #2
0
        //https://webServiceURL/version/passes/passTypeIdentifier/serialNumber
        public HttpResponseMessage GetPass(string version, string passTypeIdentifier, string serialNumber)
        {
            EventPassGeneratorRequest request = new EventPassGeneratorRequest();

            request.Identifier       = "pass.tomsamcguinness.events";
            request.CertThumbprint   = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation     = System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser;
            request.SerialNumber     = "121212111";
            request.Description      = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier   = "Team America";
            request.LogoText         = "My Pass";
            request.BackgroundColor  = "#000000";
            request.ForegroundColor  = "#FFFFFF";

            request.ImagesPath = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/");

            // Specific information
            //
            request.EventName      = "Jeff Wayne's War of the Worlds";
            request.SeatingSection = 10;
            request.DoorsOpen      = new DateTime(2012, 11, 04, 11, 30, 00); // move the date!
            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            request.AuthenticationToken = "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc";
            request.WebServiceUrl       = "http://192.168.1.3:81/api/";

            PassGenerator generator     = new PassGenerator();
            Pass          generatedPass = generator.Generate(request);

            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new ObjectContent <Byte[]>(generatedPass.GetPackage(), new BinaryFormatter());
            return(response);
        }
Пример #3
0
        public ActionResult Coupon()
        {
            PassGenerator generator = new PassGenerator();

            CouponPassGeneratorRequest request = new CouponPassGeneratorRequest();

            request.PassTypeIdentifier     = "pass.passverse.com.public";
            request.Certificate            = System.IO.File.ReadAllBytes(@"C:\Development\TestMDM\Certificates\SSL Certificates\SSL.pfx");
            request.CertificatePassword    = "******";
            request.AppleWWDRCACertificate = System.IO.File.ReadAllBytes(@"C:\Users\gtmx\Downloads\AppleIncRootCertificate.cer");
            request.SerialNumber           = "121211";
            request.Description            = "My first pass";
            request.OrganizationName       = "Tomas McGuinness";
            request.TeamIdentifier         = "R5QS56362W";
            request.LogoText        = "My Pass";
            request.BackgroundColor = "rgb(0,0,0)";
            request.ForegroundColor = "rgb(255,255,255)";

            request.AssociatedStoreIdentifiers.Add(551768476);
            request.AppLaunchURL = "something-goes-here";

            // override icon and icon retina
            request.Images.Add(PassbookImage.Icon, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/icon.png")));
            request.Images.Add(PassbookImage.Icon2X, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/[email protected]")));
            request.Images.Add(PassbookImage.Icon3X, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/[email protected]")));

            request.AddBarcode(BarcodeType.PKBarcodeFormatPDF417, "01927847623423234234", "UTF-8", "01927847623423234234");

            byte[] generatedPass = generator.Generate(request);

            return(new FileContentResult(generatedPass, "application/vnd.apple.pkpass"));
        }
Пример #4
0
        public ActionResult EventTicket()
        {
            PassGenerator generator = new PassGenerator();

            EventPassGeneratorRequest request = new EventPassGeneratorRequest();

            request.Identifier       = "pass.tomsamcguinness.events";
            request.CertThumbprint   = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation     = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;
            request.SerialNumber     = "121211";
            request.Description      = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier   = "R5QS56362W";
            request.LogoText         = "My Pass";
            request.BackgroundColor  = "rgb(255,255,255)";
            request.ForegroundColor  = "rgb(0,0,0)";

            // override icon and icon retina
            request.Images.Add(PassbookImage.Icon, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/icon.png")));
            request.Images.Add(PassbookImage.IconRetina, System.IO.File.ReadAllBytes(Server.MapPath("~/Icons/[email protected]")));

            request.EventName      = "Jeff Wayne's War of the Worlds";
            request.SeatingSection = 10;
            request.DoorsOpen      = new DateTime(2012, 11, 03, 11, 30, 00);

            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            byte[] generatedPass = generator.Generate(request);
            return(new FileContentResult(generatedPass, "application/vnd.apple.pkpass"));
        }
Пример #5
0
        public void ValidatePassword_ValidPassword_True()
        {
            Password = Generator.Generate(TestUserId);
            var validatedPassword = Validator.ValidatePassword(TestUserId, Password);

            Assert.IsTrue(validatedPassword);
        }
Пример #6
0
        protected bool SetSessionKey()
        {
            bool bRez = true;

            if (HttpContext.Current.Session[Constants.SessionID] == null)
            {
                using (Nostralogia2._1.SMParamKeeper.SMParamKeeperServClient serv = new Nostralogia2._1.SMParamKeeper.SMParamKeeperServClient())
                {
                    PassGenerator passgen = new PassGenerator();
                    passgen.Numbers         = true;
                    passgen.NumberSymbols   = Constants.LengthSalt;
                    passgen.SmallLetters    = true;
                    passgen.CapitalsLetters = true;
                    passgen.SpecialSymbols  = true;
                    passgen.Generate();
                    String salt = passgen.Pass;
                    HttpContext.Current.Session[Constants.SessionSalt] = salt;

                    passgen.NumberSymbols = Constants.LengthPassphrase;
                    passgen.Generate();
                    String pass = passgen.Pass;
                    HttpContext.Current.Session[Constants.SessionPass] = pass;

                    DateTime dt = DateTime.Now.AddHours(24);
                    try
                    {
                        serv.SetSessionKey(ADUtilities.GetSessionGUID(), salt, pass, String.Format("{0}-{1}-{2}", dt.Year, dt.Month, dt.Day));
                    }
                    catch (Exception ex)
                    {
                        bRez = false;
                        FormatAndLogMessage("SetSessionKey", ex.Message);
                    }
                }
            }
            return(bRez);
        }
Пример #7
0
        public void SecondBasic()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory; //Assembly.GetExecutingAssembly().Location;
            var    cwd  = new DirectoryInfo(path).Parent.Parent.Parent;

            path = cwd.FullName;

            var images = new SerializableDictionary <Enums.PassbookImageType, byte[]>();

            images.Add(Enums.PassbookImageType.Icon, File.ReadAllBytes(path + "\\resources\\eon4u-logo.png"));
            images.Add(Enums.PassbookImageType.IconRetina, File.ReadAllBytes(path + "\\resources\\eon4u-logo.png"));
            images.Add(Enums.PassbookImageType.LogoRetina, File.ReadAllBytes(path + "\\resources\\eon4u-logo.png"));
            images.Add(Enums.PassbookImageType.Logo, File.ReadAllBytes(path + "\\resources\\eon4u-logo.png"));

            var p = new Pass <StoreCardPassStyle>
            {
                SerialNumber     = "123456789",
                Description      = "test",
                OrganizationName = "Test",
                BackgroundColor  = "rgb(102,153,51)",
                LabelColor       = "rgb(255,255,255)",
                ForegroundColor  = "rgb(255,255,255)",
                PassStyle        = new StoreCardPassStyle
                {
                    PrimaryFields = new List <Field>
                    {
                        new StandardField("name", "A", "K")
                    }
                },
                //Barcode = new Barcode(BarcodeType.PKBarcodeFormatQR, "C03FC299-9D27-47EC-A30C-FA8A0A595C09", "ISO-8859-1", "TO JE TEXT OD SPODAJ"),
                Barcodes = new List <Barcode>
                {
                    new Barcode(BarcodeType.PKBarcodeFormatQR, "C03FC299-9D27-47EC-A30C-FA8A0A595C09", "ISO-8859-1")
                },
                Images = images,
            };


            var pass  = Helpers.LoadCertificateFromBytes(File.ReadAllBytes(path + "\\resources\\pass.com.eon4u.p12"), "eon4u");
            var apple = Helpers.LoadCertificateFromBytes(File.ReadAllBytes(path + "\\resources\\AppleWWDRCA.cer"));
            var opt   = new PassGeneratorOptions {
                PassCert = pass, AppleCert = apple
            };

            var passGenerator = new PassGenerator(opt);

            byte[] pkPass = passGenerator.Generate(p);
            File.WriteAllBytes(path + "\\resources\\pass.pkpass", pkPass);
        }
Пример #8
0
        public ActionResult BoardingCard()
        {
            PassGenerator generator = new PassGenerator();

            BoardingCardGeneratorRequest request = new BoardingCardGeneratorRequest();

            request.Identifier       = "pass.tomsamcguinness.events";
            request.CertThumbprint   = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation     = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;
            request.FormatVersion    = 1;
            request.SerialNumber     = "121212111";
            request.Description      = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier   = "R5QS56362W";
            request.LogoText         = "My Pass";
            request.BackgroundColor  = "#000000";
            request.ForegroundColor  = "#FFFFFF";

            request.BackgroundFile       = Server.MapPath(@"~/Icons/Starbucks/background.png");
            request.BackgroundRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.IconFile       = Server.MapPath(@"~/Icons/Starbucks/icon.png");
            request.IconRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.LogoFile       = Server.MapPath(@"~/Icons/Starbucks/logo.png");
            request.LogoRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            // Specific information
            //
            request.Origin     = "San Francisco";
            request.OriginCode = "SFO";

            request.Destination     = "London";
            request.DestinationCode = "LDN";

            request.Seat          = "7A";
            request.BoardingGate  = "F12";
            request.PassengerName = "John Appleseed";

            request.TransitType = TransitType.PKTransitTypeAir;

            request.AuthenticationToken = "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc";
            request.WebServiceUrl       = "http://192.168.1.59:82/api/";

            Pass generatedPass = generator.Generate(request);

            return(new FileContentResult(generatedPass.GetPackage(), "application/vnd.apple.pkpass"));
        }
        //https://webServiceURL/version/passes/passTypeIdentifier/serialNumber
        public HttpResponseMessage GetPass(string version, string passTypeIdentifier, string serialNumber)
        {
            StoreCardGeneratorRequest request = new StoreCardGeneratorRequest();

            request.Identifier       = "pass.tomsamcguinness.events";
            request.CertThumbprint   = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation     = System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser;
            request.FormatVersion    = 1;
            request.SerialNumber     = "121212111";
            request.Description      = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier   = "Team America";
            request.LogoText         = "My Pass";
            request.BackgroundColor  = "#000000";
            request.ForegroundColor  = "#FFFFFF";

            request.BackgroundFile       = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/background.png");
            request.BackgroundRetinaFile = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.IconFile       = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/icon.png");
            request.IconRetinaFile = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.LogoFile       = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/logo.png");
            request.LogoRetinaFile = HttpContext.Current.Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            // Specific information
            //
            request.Balance    = 121.12;
            request.OwnersName = "Tomas McGuinness";
            request.Title      = "Starbucks";
            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            request.AuthenticationToken = "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc";
            request.WebServiceUrl       = "http://192.168.1.3:81/api/";

            PassGenerator generator     = new PassGenerator();
            Pass          generatedPass = generator.Generate(request);

            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new ObjectContent <Byte[]>(generatedPass.GetPackage(), new BinaryFormatter());
            return(response);
        }
Пример #10
0
        public ActionResult StoreCard()
        {
            PassGenerator generator = new PassGenerator();

            StoreCardGeneratorRequest request = new StoreCardGeneratorRequest();

            request.Identifier       = "pass.tomsamcguinness.events";
            request.CertThumbprint   = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation     = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;
            request.FormatVersion    = 1;
            request.SerialNumber     = "121212111";
            request.Description      = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier   = "R5QS56362W";
            request.LogoText         = "My Pass";
            request.BackgroundColor  = "#000000";
            request.ForegroundColor  = "#FFFFFF";

            request.BackgroundFile       = Server.MapPath(@"~/Icons/Starbucks/background.png");
            request.BackgroundRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.IconFile       = Server.MapPath(@"~/Icons/Starbucks/icon.png");
            request.IconRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.LogoFile       = Server.MapPath(@"~/Icons/Starbucks/logo.png");
            request.LogoRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            // Specific information
            //
            request.Balance    = 100.12;
            request.OwnersName = "Tomas McGuinness";
            request.Title      = "Starbucks";
            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            request.AuthenticationToken = "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc";
            request.WebServiceUrl       = "http://192.168.1.59:82/api/";

            Pass generatedPass = generator.Generate(request);

            return(new FileContentResult(generatedPass.GetPackage(), "application/vnd.apple.pkpass"));
        }
Пример #11
0
        protected IHttpActionResult GeneratePass(PassProvider provider, string serialNumber)
        {
            PassGeneratorRequest request = provider.GetPass(serialNumber);

            if (request != null)
            {
                // Passbook webService is configured, enable it in the generated pass
                if (!string.IsNullOrEmpty(mServiceUrl))
                {
                    request.WebServiceUrl       = mServiceUrl;
                    request.AuthenticationToken = GenerateAuthorizationToken(provider.PassTypeIdentifier, request.SerialNumber);
                }

                PassGenerator passGenerator = new PassGenerator();
                byte[]        pass          = passGenerator.Generate(request);

                return(new PassbookContentResult(pass));
            }

            return(null);
        }
Пример #12
0
        public ActionResult EventTicket()
        {
            PassGenerator generator = new PassGenerator();

            EventPassGeneratorRequest request = new EventPassGeneratorRequest();

            request.Identifier       = "pass.tomsamcguinness.events";
            request.CertThumbprint   = ConfigurationManager.AppSettings["PassBookCertificateThumbprint"];
            request.CertLocation     = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;
            request.FormatVersion    = 1;
            request.SerialNumber     = "121211";
            request.Description      = "My first pass";
            request.OrganizationName = "Tomas McGuinness";
            request.TeamIdentifier   = "R5QS56362W";
            request.LogoText         = "My Pass";
            request.BackgroundColor  = "#FFFFFF";
            request.ForegroundColor  = "#000000";

            request.BackgroundFile       = Server.MapPath(@"~/Icons/Starbucks/background.png");
            request.BackgroundRetinaFile = Server.MapPath(@"~/Icons/Starbucks/[email protected]");

            request.IconFile       = Server.MapPath(@"~/Icons/icon.png");
            request.IconRetinaFile = Server.MapPath(@"~/Icons/[email protected]");

            request.LogoFile       = Server.MapPath(@"~/Icons/logo.png");
            request.LogoRetinaFile = Server.MapPath(@"~/Icons/[email protected]");

            request.EventName      = "Jeff Wayne's War of the Worlds";
            request.SeatingSection = 10;
            request.DoorsOpen      = new DateTime(2012, 11, 03, 11, 30, 00);

            request.AddBarCode("01927847623423234234", BarcodeType.PKBarcodeFormatPDF417, "UTF-8", "01927847623423234234");

            Pass generatedPass = generator.Generate(request);

            return(new FileContentResult(generatedPass.GetPackage(), "application/vnd.apple.pkpass"));
        }
Пример #13
0
        public byte[] GetPass2(HttpContextBase context, CouponInfoResponse coupponInfo)
        {
            var generator = new PassGenerator();

            var request = new CouponPassGeneratorRequest
            {
                Identifier     = ConfigurationManager.AppSettings["Identifier"],
                CertThumbprint =
                    ConfigurationManager.AppSettings["PassBookCertificateThumbprint"].Replace(" ", String.Empty),
                CertLocation               = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine,
                SerialNumber               = coupponInfo.Id.ToString(CultureInfo.InvariantCulture),
                Description                = coupponInfo.ProductDescription,
                OrganizationName           = ConfigurationManager.AppSettings["OrganizationName"],
                TeamIdentifier             = ConfigurationManager.AppSettings["TeamIdentifier"],
                BackgroundColor            = "rgb(229,1,80)",
                ForegroundColor            = "rgb(255,255,255)",
                LabelColor                 = "rgb(255,255,255)",
                AssociatedStoreIdentifiers = new List <int>(1)
                {
                    ConfigManager.AppleAppid
                }
            };


            // override icon and icon retina
            request.Images.Add(PassbookImage.Icon, System.IO.File.ReadAllBytes(context.Server.MapPath("~/Icons/coupon/icon.png")));
            request.Images.Add(PassbookImage.Logo, System.IO.File.ReadAllBytes(context.Server.MapPath("~/Icons/coupon/logo.png")));
            request.AddBarCode(coupponInfo.CouponId, BarcodeType.PKBarcodeFormatPDF417, "iso-8859-1" /*"UTF-8"*/, coupponInfo.CouponId);
            request.SuppressStripShine = false;

            //获取品牌 ,获取 STORE
            var store  = GetStore(coupponInfo);
            var brands = GetBrand(coupponInfo);

            string bName = String.Empty;

            //折扣部分
            if (brands.Count > 0)
            {
                bName = brands[0].Name;
            }

            if (coupponInfo.SourceType == (int)SourceType.Product)
            {
                request.AddPrimaryField(new StandardField("primary1", bName, coupponInfo.ProductName));
            }

            if (coupponInfo.SourceType == (int)SourceType.Promotion)
            {
                request.AddPrimaryField(new StandardField("primary1", String.Empty, coupponInfo.ProductName));
            }

            //有效期

            request.AddSecondaryField(new DateField("secondary1", "有效期", coupponInfo.ValidStartDate, FieldDateTimeStyle.PKDateStyleLong, FieldDateTimeStyle.PKDateStyleNone));
            //
            request.AddSecondaryField(new StandardField("secondary2", String.Empty, "-"));

            request.AddSecondaryField(new DateField("secondary3", String.Empty, coupponInfo.ValidEndDate, FieldDateTimeStyle.PKDateStyleLong, FieldDateTimeStyle.PKDateStyleNone));

            request.AddBackField(new StandardField("back info1", coupponInfo.ProductName, coupponInfo.ProductDescription));
            request.AddBackField(new StandardField("back info2", "有效期", String.Format("{0} - {1}", coupponInfo.ValidStartDate.ToString("yyyy-M-d"), coupponInfo.ValidEndDate.ToString("yyyy-M-d"))));

            if (store != null)
            {
                request.LogoText = store.Name;//couponName;

                request.AddBackField(new StandardField("address", "地址", store.Location));
                request.AddBackField(new StandardField("ad2", "联系电话", store.Tel));
                var relevantest = String.Format("您附近的{0}正在做促销,详情进店查看", store.Name);
                request.Locations.Add(
                    new Location
                {
                    Latitude     = (double)store.Latitude,
                    Longitude    = (double)store.Longitude,
                    RelevantText = relevantest
                });

                if (store.GpsLat != null && store.GpsLng != null)
                {
                    request.Locations.Add(new Location
                    {
                        Latitude     = (double)store.GpsLat.Value,
                        Longitude    = (double)store.GpsLng.Value,
                        RelevantText = relevantest
                    });
                }
            }

            byte[] generatedPass = generator.Generate(request);

            return(generatedPass);

            //return null;
        }