Beispiel #1
0
        /*
         * Prints address info present in the card (requires address pin)
         */
        public void ShowAddressInfo()
        {
            //The number of tries that the user has (updated with each call to verifyPin)
            uint triesLeft = uint.MaxValue;

            //Get the collection of card PINs
            PTEID_Pins pins = eidCard.getPins();

            //Get the specific PIN we want
            PTEID_Pin pin = pins.getPinByPinRef(PTEID_Pin.ADDR_PIN);

            //If the method verifyPin is called with "" as the first argument it prompts the middleware GUI for the user to insert its PIN
            //Otherwise we can provide the PIN as the first argument and the end result will be the same
            if (pin.verifyPin("", ref triesLeft, true))
            {
                //SDK class that handles address related information
                PTEID_Address address = eidCard.getAddr();
                Console.WriteLine("\n\nReading address details of: " + eid.getGivenName() + " " + eid.getSurname() + ":");

                if (address.isNationalAddress())
                {
                    Console.WriteLine("---National Address---");
                    Console.WriteLine("District:                       " + address.getDistrict());
                    Console.WriteLine("District (code):                " + address.getDistrictCode());
                    Console.WriteLine("Municipality:                   " + address.getMunicipality());
                    Console.WriteLine("Municipality (code):            " + address.getMunicipalityCode());
                    Console.WriteLine("Parish:                         " + address.getCivilParish());
                    Console.WriteLine("Parish (code):                  " + address.getCivilParishCode());
                    Console.WriteLine("Street Type (Abbreviated):      " + address.getAbbrStreetType());
                    Console.WriteLine("Street Type:                    " + address.getStreetType());
                    Console.WriteLine("Street Name:                    " + address.getStreetName());
                    Console.WriteLine("Building Type (Abbreviated):    " + address.getAbbrBuildingType());
                    Console.WriteLine("Building Type:                  " + address.getBuildingType());
                    Console.WriteLine("Door nº:                        " + address.getDoorNo());
                    Console.WriteLine("Floor:                          " + address.getFloor());
                    Console.WriteLine("Side:                           " + address.getSide());
                    Console.WriteLine("Locality:                       " + address.getLocality());
                    Console.WriteLine("Place:                          " + address.getPlace());
                    Console.WriteLine("Postal code:                    " + address.getZip4() + "-" + address.getZip3());
                    Console.WriteLine("Postal Locality:                " + address.getPostalLocality());
                }
                else
                {
                    Console.WriteLine("---Foreign Address---");
                    Console.WriteLine("Address:     " + address.getForeignAddress());
                    Console.WriteLine("City:        " + address.getForeignCity());
                    Console.WriteLine("Locality:    " + address.getForeignLocality());
                    Console.WriteLine("Postal Code: " + address.getForeignPostalCode());
                    Console.WriteLine("Region:      " + address.getForeignRegion());
                    Console.WriteLine("Country:     " + address.getForeignCountry());
                }
            }
        }
        /*
         * Saves all card info in XML format and prints it to a file
         */
        public void SaveXML()
        {
            //The number of tries that the user has (updated with each call to verifyPin)
            uint triesLeft = uint.MaxValue;

            //Sets of the card PINs
            PTEID_Pins pins = eidCard.getPins();

            //Gets the specific PIN we want
            //ADDR_PIN - Address Pin
            //AUTH_PIN - Authentication Pin
            //SIGN_PIN - Signature Pin
            PTEID_Pin pin = pins.getPinByPinRef(PTEID_Pin.ADDR_PIN);

            //If the method verifyPin is called with "" as the first argument it prompts the middleware GUI for the user to insert its PIN
            //Otherwise we can send the PIN as the first argument and the end result will be the same
            if (pin.verifyPin("", ref triesLeft, true))
            {
                //Selects information to be requested in XML format
                //You can add or remove fields at will
                PTEID_XmlUserRequestedInfo requestedInfo = new PTEID_XmlUserRequestedInfo();

                XMLUserData[] data = new XMLUserData[] { XMLUserData.XML_PHOTO, XMLUserData.XML_NAME, XMLUserData.XML_GIVEN_NAME,
                                                         XMLUserData.XML_SURNAME, XMLUserData.XML_NIC, XMLUserData.XML_EXPIRY_DATE, XMLUserData.XML_GENDER, XMLUserData.XML_HEIGHT,
                                                         XMLUserData.XML_NATIONALITY, XMLUserData.XML_DATE_OF_BIRTH, XMLUserData.XML_GIVEN_NAME_FATHER, XMLUserData.XML_SURNAME_FATHER,
                                                         XMLUserData.XML_GIVEN_NAME_MOTHER, XMLUserData.XML_SURNAME_MOTHER, XMLUserData.XML_ACCIDENTAL_INDICATIONS, XMLUserData.XML_DOCUMENT_NO,
                                                         XMLUserData.XML_TAX_NO, XMLUserData.XML_SOCIAL_SECURITY_NO, XMLUserData.XML_HEALTH_NO, XMLUserData.XML_MRZ1, XMLUserData.XML_MRZ2,
                                                         XMLUserData.XML_MRZ3, XMLUserData.XML_CARD_VERSION, XMLUserData.XML_CARD_NUMBER_PAN, XMLUserData.XML_ISSUING_DATE, XMLUserData.XML_ISSUING_ENTITY,
                                                         XMLUserData.XML_DOCUMENT_TYPE, XMLUserData.XML_LOCAL_OF_REQUEST, XMLUserData.XML_VERSION, XMLUserData.XML_DISTRICT, XMLUserData.XML_MUNICIPALITY,
                                                         XMLUserData.XML_CIVIL_PARISH, XMLUserData.XML_ABBR_STREET_TYPE, XMLUserData.XML_STREET_TYPE, XMLUserData.XML_STREET_NAME, XMLUserData.XML_ABBR_BUILDING_TYPE,
                                                         XMLUserData.XML_BUILDING_TYPE, XMLUserData.XML_DOOR_NO, XMLUserData.XML_FLOOR, XMLUserData.XML_SIDE, XMLUserData.XML_PLACE, XMLUserData.XML_LOCALITY,
                                                         XMLUserData.XML_ZIP4, XMLUserData.XML_ZIP3, XMLUserData.XML_POSTAL_LOCALITY, XMLUserData.XML_PERSONAL_NOTES, XMLUserData.XML_FOREIGN_COUNTRY,
                                                         XMLUserData.XML_FOREIGN_ADDRESS, XMLUserData.XML_FOREIGN_CITY, XMLUserData.XML_FOREIGN_REGION, XMLUserData.XML_FOREIGN_LOCALITY, XMLUserData.XML_FOREIGN_POSTAL_CODE };

                //Adds each field of the vector to the request
                foreach (XMLUserData field in data)
                {
                    requestedInfo.add(field);
                }

                //Gets the XML information from the card and transforms it to a string
                PTEID_CCXML_Doc ccxml     = eidCard.getXmlCCDoc(requestedInfo);
                String          resultXml = ccxml.getCCXML();

                using (var streamWriter = new StreamWriter("../../files/info.xml", false))
                {
                    streamWriter.WriteLine(resultXml);
                    streamWriter.Close();
                }

                Console.WriteLine("Your XML info has been saved successfully in files/info.xml.");
            }
        }
Beispiel #3
0
        public static int VerifyPIN(byte pinId, String strPin)
        {
            uint tries_left = 0;
            int  triesLeft  = 0;

            if (readerContext != null)
            {
                //PIN ID = 1 is legacy from IAS 1.01 cards
                if (pinId != 1 && pinId != PTEID_AUTH_PIN && pinId != PTEID_SIGNATURE_PIN && pinId != PTEID_ADDRESS_PIN)
                {
                    return(0);
                }
                try {
                    PTEID_Pins pins = idCard.getPins();
                    for (uint pinIdx = 0; pinIdx < pins.count(); pinIdx++)
                    {
                        PTEID_Pin pin = pins.getPinByNumber(pinIdx);
                        if (pin.getPinRef() == pinId)
                        {
                            bool ret = pin.verifyPin(strPin, ref tries_left, false);
                            if (!ret)
                            {
                                if (tries_left == 0)
                                {
                                    throw new PteidException(SC_ERROR_AUTH_METHOD_BLOCKED);
                                }
                                else
                                {
                                    throw new PteidException(SC_ERROR_PIN_CODE_INCORRECT);
                                }
                            }
                            triesLeft = (int)tries_left;
                        }
                    }
                    return(triesLeft);
                } catch (PTEID_Exception ex) {
                    handleUnderlyingException(ex);
                }
            }
            return(triesLeft);
        }
Beispiel #4
0
        public static PteidAddr GetAddr()
        {
            try
            {
                uint       ul   = 0;
                PTEID_Pins pins = idCard.getPins();
                for (uint i = 0; i < pins.count(); i++)
                {
                    PTEID_Pin pin = pins.getPinByNumber(i);
                    if (pin.getPinRef() == PTEID_ADDRESS_PIN)
                    {
                        if (pin.verifyPin("", ref ul, false))
                        {
                            return(new PteidAddr(idCard.getAddr()));
                        }
                        else
                        {
                            if (ul == 0)
                            {
                                throw new PteidException(SC_ERROR_AUTH_METHOD_BLOCKED);
                            }
                            else
                            {
                                throw new PteidException(SC_ERROR_PIN_CODE_INCORRECT);
                            }
                        }
                    }
                }
            }
            catch (PTEID_Exception ex)
            {
                handleUnderlyingException(ex);
            }

            //Fix build: should never happen
            return(null);
        }