Examples of Apdu


Examples of uk.co.nimp.smartcard.Apdu

                        List<GenericTerminal> terminals = manager.list();
                        MP300TC2Terminal terminal = (MP300TC2Terminal) 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(MP300TC2Terminal.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

Examples of uk.co.nimp.smartcard.Apdu

        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

Examples of uk.co.nimp.smartcard.Apdu

                                }
                                args=args.substring(2);
                                args=AStringUtilities.removeLeadingBlanks(args);
                                args=removeTrailingBlanksAndComments(args);
                                //args=args.replace(" ", "");//to allow formating of lc data
                                Apdu apdu=new Apdu(cla,ins,p1,p2,lc,le);
                                if(0<lc){//we should find some data here
                                    apdu.setLcData(args, " ");
                                    if(lc!=apdu.getLc())
                                        throw new RuntimeException("LC field indicate "+lc+
                                                " bytes but "+apdu.getLc()+" bytes of data have been found.");
                                    args="";
                                }
                                //no args allowed here
                                if(false==args.isEmpty())
                                    throw new RuntimeException(COMMAND+" take at most 7 arguments. This may due to a mismatch between Lc and Lc Data length");
View Full Code Here

Examples of uk.co.nimp.smartcard.Apdu

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

Examples of uk.co.nimp.smartcard.Apdu

        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

Examples of uk.co.nimp.smartcard.Apdu

            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

Examples of uk.co.nimp.smartcard.Apdu

                            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

Examples of uk.co.nimp.smartcard.Apdu

        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

Examples of uk.co.nimp.smartcard.Apdu

            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

Examples of uk.co.nimp.smartcard.Apdu

        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
TOP
Copyright © 2018 www.massapi.com. 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.