Example #1
0
        public void StoreDataToApplication(GPStoreData irfi)
        {
            byte p1 = (byte)StoreDataRequestP1Enum.DGIformatofthecommanddatafield;

            if (irfi.IsLastBlock)
            {
                p1 = (byte)(p1 | (byte)StoreDataRequestP1Enum.LastOrOnlyCommand);
            }

            GPStoreDataReqest   ir       = new GPStoreDataReqest(irfi.Serialize(), p1, irfi.DataBlock);
            GPStoreDataResponse response = SendCommand(ir) as GPStoreDataResponse;

            if (!response.Succeeded)
            {
                throw new Exception("Failure storing data to application, SW=" + response.SW + " (" + response.SWTranslation + ")");
            }
        }
        public static void GPPersoFromXmlTest(string xml)
        {
            perso perso = XMLUtil <perso> .Deserialize(xml);

            perso.application.ToList().ForEach(app =>
            {
                installType it         = app.commands.install;
                INSTALL_PARAM_C9_GP ip = null;
                if (it.tokens != null)
                {
                    if (it.tokens.tlvxml != null)
                    {
                        ip             = new INSTALL_PARAM_C9_GP();
                        valueC9Type c9 = it.tokens.tlvxml.valueC9;
                        if (c9.C9_ApplicationInstanceSpecified)
                        {
                            ip.Value.ApplicationInstance = MapC9_ApplicationInstanceEnum(c9.C9_ApplicationInstance);
                        }
                        if (c9.C9_PinSharingSpecified)
                        {
                            ip.Value.PinSharing = MapC9_PinSharingEnum(c9.C9_PinSharing);
                        }
                        if (c9.C9_InterfacesAvailableSpecified)
                        {
                            ip.Value.InterfacesAvailable = MapC9_InterfacesAvailableEnum(c9.C9_InterfacesAvailable);
                        }
                    }
                }

                GPInstallRequestDataForInstall irfi = new GPInstallRequestDataForInstall()
                {
                    ExecutableLoadFileAID = it.ExecutableLoadFileAID,
                    ExecutableModuleAID   = it.ExecutableModuleAID,
                    ApplicationAID        = it.ApplicationAID,
                    Privileges            = Formatting.HexStringToByteArray(it.Privileges),
                    InstallToken          = Formatting.HexStringToByteArray(it.InstallToken),
                    InstallParamC9        = ip,
                };

                //select
                //auth
                GPInstallRequest ir = new GPInstallRequest((byte)InstallRequestP1Enum.LastOrOnlyCommand | (byte)InstallRequestP1Enum.ForMakeSelectable | (byte)InstallRequestP1Enum.ForInstall)
                {
                    CommandData = irfi.Serialize()
                };
                System.Diagnostics.Debug.WriteLine(ir.ToPrintString());

                //select
                //auth
                app.commands.storeData.ToList().ForEach(command =>
                {
                    GPStoreData sd = new GPStoreData
                    {
                        DGI = Formatting.HexStringToByteArray(command.DGI)
                    };
                    if (command.data != null)
                    {
                        sd.DataBytes = Formatting.HexStringToByteArray(command.data);
                    }
                    else
                    {
                        sd.Data = DeserList(command.tlvxml);
                    }
                    GPStoreDataReqest sdr = new GPStoreDataReqest
                    {
                        CommandData = sd.Serialize()
                    };
                    System.Diagnostics.Debug.WriteLine(sdr.ToPrintString());
                });
            });
        }