Package uk.co.nimp.smartcard

Examples of uk.co.nimp.smartcard.Apdu$CardResponse


import uk.co.nimp.smartcard.UnexpectedCardResponseException;

public class GetChallengeTask extends AbstractSmartCardTask {

    public int execute(GenericTerminal gt) throws ScardException {
        Apdu getChallengeApdu = new Apdu("0084000010");
        getChallengeApdu.setExpectedSw(Iso7816.SW_SUCCESS);
        try {
            for (int i = 0; i < nRun; i++) {//it is up to each task to define how it handles the nRun standard argument
                gt.sendApdu(getChallengeApdu);
            }
        } catch (UnexpectedCardResponseException ex) {
View Full Code Here


        if (0 == terminals.size()) {
            System.out.println("PcSc terminal not detected.");
            return;
        }
        GenericTerminal terminal = terminals.get(0);
        Apdu test=new Apdu("001C0000");
        terminal.coldConnect();
        System.out.println("connected to "+terminal+ " using protocol "+GenericTerminal.getProtocolName(terminal.getProtocol()));
        long start=System.currentTimeMillis();
        for(int i=0;i<1000;i++){
            terminal.sendApdu(test);
View Full Code Here

            return;
        }
        GenericTerminal terminal = terminals.get(2);
        System.out.println("Try to connected to "+terminal);
       
        Apdu test=new Apdu("001C0000");
        terminal.coldConnect();
        System.out.println("connected to "+terminal+ " using protocol "+GenericTerminal.getProtocolName(terminal.getProtocol()));
        PcScTerminal pcScTerminal=(PcScTerminal)terminal;
        byte []answer=PcScTerminalManager.SCardGetAttrib(pcScTerminal.cardId,SCARD_ATTR_VENDOR_IFD_SERIAL_NO);
        System.out.println(AStringUtilities.bytesToHex(answer));
View Full Code Here

                            throw new RuntimeException("MP300 TC3 not found");
                        MP300TC3Terminal terminal = (MP300TC3Terminal) terminals.get(0);
                        terminal.addLogHandler(new ScardPrintStreamLogHandler(System.out));
                        System.out.println("Try to connect to " + terminal.getName());
                        terminal.coldConnect();
                        Apdu apdu = new Apdu(0x00, 0x8A, 0x00, 0x44, 0x02);
                        terminal.sendApdu(apdu);
                        //manager.batchInterfaceTest();
                        spyTest(terminal);
                    } catch (ScardException ex) {
                        Logger.getLogger(MP300TC3Terminal.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

        status = win32Mp300ComDll.MPS_OpenLog(terminal.couplerId, EN_C1 | EN_C2 | EN_C3 | EN_C7 | EN_CHAR_ISO | EN_ETU, 0);
        if (RET_OK != status) {
            throw new ScardException("MPS_OpenLog returned " + status);
        }

        Apdu apdu = new Apdu(0x00, 0x8A, 0x00, 0x44, 0x02);
        terminal.sendApdu(apdu);

        status = win32Mp300ComDll.MPS_CloseLog(terminal.couplerId);
        if (RET_OK != status) {
            throw new ScardException("MPS_CloseLog returned " + status);
View Full Code Here

            contactTerminal.setFrequency(3000000);
            contactTerminal.setVoltage(5000);
        }
        for (int i = 0; i < 10; i++) {
            terminal.coldConnect();
            Apdu apdu = new Apdu(0x00, 0x1A, 0x00, 0x00, 0x04);
            terminal.sendApdu(apdu);
            if (0x9000 != apdu.getSw()) {
                throw new RuntimeException();
            }
            byte data[] = {(byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78};
            apdu = new Apdu(0x00, 0x1C, 0x00, 0x00, data);
            terminal.sendApdu(apdu);
            if (0x9000 != apdu.getSw()) {
                throw new RuntimeException();
            }
            apdu = new Apdu(0x00, 0x1A, 0x00, 0x00, 0x04);
            terminal.sendApdu(apdu);
            if (0x9000 != apdu.getSw()) {
                throw new RuntimeException();
            }
        }
        terminal.logLine(ScardLogHandler.LOG_INFO, "speedTest duration: " + ATimeUtilities.getUserFriendlyTimeUs(System.nanoTime() - start));
    }
View Full Code Here

        terminal.coldConnect();
        System.out.println("connected to "+terminal+ " using protocol "+GenericTerminal.getProtocolName(terminal.getProtocol()));

        long start=System.currentTimeMillis();
        Apdu readApdu=new Apdu();
        int maxLe=0x100;
        int base=0x500000;
        int size=0x024000;
        readApdu.setIns(0x0A);
        readApdu.setExpectedLe(maxLe);
        readApdu.setExpectedSw(0x9000);

        int nLoops=size/maxLe;
        int nLast=size%maxLe;
        File fout=new File(ATimeUtilities.getTimeTagMillisecond()+".bin");
        System.out.println("Output file:");
        System.out.println(fout.getCanonicalPath());
       
        FileOutputStream fos = new FileOutputStream(fout);
        int address=base;
        for(int i=0;i<nLoops;i++){
            setHeader(readApdu,address);
            terminal.sendApdu(readApdu);
            fos.write(readApdu.getLeData());
            address+=maxLe;
        }
        if(nLast>0){
            readApdu.setExpectedLe(nLast);
            setHeader(readApdu,address);
        }
        fos.close();
        long end=System.currentTimeMillis();
        long delta=end-start;
View Full Code Here

                }
            }
            terminals = manager.list();
            terminals = manager.list();
            System.out.println("Try to connect to " + terminal.getName());
            Apdu apdu;
            terminal.coldConnect();
            GenericContactTerminal contactTerminal=terminal;
            contactTerminal.logFrequency();
            contactTerminal.logVoltage();

            apdu = new Apdu(0x00, 0x8A, 0x00, 0x44, 0x02);
            terminal.sendApdu(apdu);

            /*apdu = new Apdu(0x00, 0x32, 0x01, 0x03, 0x00);
            terminal.sendApdu(apdu);
            apdu = new Apdu(0x00, 0x7E, 0x00, 0x00, 0x00);
            terminal.sendApdu(apdu);*/
            apdu = new Apdu("FC39000720000010000051C000FFEEFFEE0000000802AA0051C000000010000000000800AA");
            terminal.sendApdu(apdu);
           
            terminal.logLine(ScardLogHandler.LOG_INFO, "Force clock to 5MHz");
            contactTerminal.setFrequency(5000000);
            contactTerminal.logFrequency(false);
            contactTerminal.logFrequency(true);
            if(5000000!=contactTerminal.getFrequency(true)) throw new RuntimeException();
            terminal.logLine(ScardLogHandler.LOG_INFO, "Force clock to low");
            contactTerminal.setClkPin(false);
            contactTerminal.logFrequency(false);
            contactTerminal.logFrequency(true);
            if(0!=contactTerminal.getFrequency(true)) throw new RuntimeException();
            terminal.logLine(ScardLogHandler.LOG_INFO, "Force clock to high");
            contactTerminal.setClkPin(true);
            contactTerminal.logFrequency(true);
            if(0!=contactTerminal.getFrequency(true)) throw new RuntimeException();
            terminal.logLine(ScardLogHandler.LOG_INFO, "Force clock to 3MHz");
            contactTerminal.setFrequency(3000000);
            contactTerminal.logFrequency(false);
            contactTerminal.logFrequency(true);
            if(3000000!=contactTerminal.getFrequency(true)) throw new RuntimeException();

            terminal.logLine(ScardLogHandler.LOG_INFO, "Force voltage to 1620mV");
            contactTerminal.setVoltage(1620);
            contactTerminal.logVoltage();
            apdu = new Apdu(0x00, 0x8A, 0x00, 0xDC, 0x01);
            terminal.sendApdu(apdu);
            terminal.logLine(ScardLogHandler.LOG_INFO, "Force voltage to 3000mV");
            contactTerminal.setVoltage(3000);
            contactTerminal.logVoltage();
            terminal.sendApdu(apdu);
View Full Code Here

TOP

Related Classes of uk.co.nimp.smartcard.Apdu$CardResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.