Package uk.co.nimp.smartcard

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


    }
    Apdu manualApdu;

    protected Apdu makeManualApdu(boolean includeLc, boolean includeLe, boolean showErrorMessages) {
        //try to make an apdu
        Apdu out = null;
        try {
            String header = (String) apduHeaderTextField.getText();
            header = header.replaceAll("\\s", "");
            header = header.replaceAll("-", "");
            Apdu apdu = new Apdu();
            apdu.setHeader(header);
            apdu.setLcData(CardReaderManagerView.this.lcDataEditor.getText().replaceAll("\\s", "").replaceAll("-", ""));
            String le = CardReaderManagerView.this.leTextField.getText().replaceAll("\\s", "").replaceAll("-", "");
            if (!le.isEmpty()) {
                apdu.setExpectedLe(Integer.parseInt(le, 16));

            }
            out = apdu;
        } catch (Throwable ex) {
            if (showErrorMessages) {
                String msg = "Cannot parse the APDU, action cancelled:\n" + ex;
                JOptionPane.showMessageDialog(null, msg, "Incorrect input", JOptionPane.INFORMATION_MESSAGE);
            }
        }
        manualApdu = out;
        if (null == out) {
            if (this.isActiveTerminalReady()) {
                enableSendApduButtons(false);
            }
            this.sendApduButton.setToolTipText("APDU not recognized");
            this.sendApduNoLeButton.setToolTipText("APDU not recognized");
            this.sendApduNoLcButton.setToolTipText("APDU not recognized");
            return out;
        }
        String toolTip = out.toString().replace("\n", "<br>");
        toolTip = "<html>" + toolTip + "</html>";
        this.sendApduButton.setToolTipText(toolTip);
        Apdu outNoLe = out.clone();
        outNoLe.setExpectedLe(0);
        toolTip = outNoLe.toString().replace("\n", "<br>");
        toolTip = "<html>" + toolTip + "</html>";
        this.sendApduNoLeButton.setToolTipText(toolTip);
        Apdu outNoLc = out.clone();
        outNoLc.setLcData(new byte[0]);
        toolTip = outNoLc.toString().replace("\n", "<br>");
        toolTip = "<html>" + toolTip + "</html>";
        this.sendApduNoLcButton.setToolTipText(toolTip);
        if (this.isActiveTerminalReady()) {
            enableSendApduButtons(true);
        }
View Full Code Here


        String apduString = (String) CardReaderManagerView.this.apduComboBox.getSelectedItem();
        if ((null == apduString) || apduString.isEmpty()) {
            return;

        }
        Apdu apdu = new Apdu(apduString);
        CardReaderManagerView.this.lcDataEditor.setText(apdu.getLcDataAsString());
        String header = apdu.getClaAsString() + " ";
        header += apdu.getInsAsString() + " ";
        header += apdu.getP1AsString() + " ";
        header += apdu.getP2AsString();
        CardReaderManagerView.this.apduHeaderTextField.setText(header);
        CardReaderManagerView.this.leTextField.setText(apdu.getExpectedLeAsHexString());
    }
View Full Code Here

            throw new RuntimeException("sendApduAction invoked but log.gettI().isBusy() return true");
        }

        log.gettI().setReserved(true);
        this.enableCardRelatedComponents();
        Apdu apdu = makeManualApdu(sendLc, sendLe, true);
        if (null == apdu) {
            log.gettI().setReserved(false);
            this.enableCardRelatedComponents();
            return null;
        }
        DefaultComboBoxModel model = (DefaultComboBoxModel) this.apduComboBox.getModel();
        String header = AStringUtilities.bytesToHex(apdu.getCommandAPDU().getBytes());

        boolean present = false;
        for (int i = 0; i < model.getSize(); i++) {
            if (header.equals((String) model.getElementAt(i))) {
                present = true;
View Full Code Here

                    Logger.getLogger(RemoteTerminal.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            System.out.println("Try to coldConnect to " + terminal.getName());
            terminal.coldConnect();
            Apdu apdu = new Apdu(0x00, 0x8A, 0x00, 0x44, 0x02);
            terminal.sendApdu(apdu);
        } catch (ScardException ex) {
            Logger.getLogger(VirtualTerminal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here

                    Logger.getLogger(Star265Terminal.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            System.out.println("Try to coldConnect to " + star265.getName());
            star265.coldConnect();
            Apdu apdu = new Apdu(0x00, 0x8A, 0x00, 0x44, 0x02);
            star265.sendApdu(apdu);
        } catch (ScardException ex) {
            Logger.getLogger(Star265Terminal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (CardException ex) {
            Logger.getLogger(Star265Terminal.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

                fos = new FileOutputStream(targetFile);
                try {
                    gt.logLine(ScardLogHandler.LOG_INFO, "targetFile:" + targetFile.getCanonicalPath());
                    gt.logLine(ScardLogHandler.LOG_INFO, "dataSize=" + dataSize + " bytes");
                    gt.logLine(ScardLogHandler.LOG_INFO, "maxLeDataSize=" + maxLeDataSize + " bytes");
                    Apdu getChallengeApdu = new Apdu(getRandomDataCmd);
                    getChallengeApdu.setExpectedLe(maxLeDataSize);
                    if(!ignoreSw)
                        getChallengeApdu.setExpectedSw(Iso7816.SW_SUCCESS);
                    int nLoops = dataSize / maxLeDataSize;
                    for (int i = 0; i < nLoops; i++) {
                        if(coldReset) gt.coldConnect();
                        gt.sendApdu(getChallengeApdu);
                        fos.write(getChallengeApdu.getLeData());//write raw data to file
                    }
                    int remaining = dataSize % maxLeDataSize;
                    if (remaining > 0) {
                        getChallengeApdu.setExpectedLe(remaining);
                        gt.sendApdu(getChallengeApdu);
                        fos.write(getChallengeApdu.getLeData());//write raw data to file
                    }
                    fos.close();
                    for (String AIS31Test : AIS31Tests) {
                        gt.logLine(ScardLogHandler.LOG_INFO, "Launch AIS31 test condition '" + AIS31Test + "' on file "+targetFile);
                        execAis31Test(AIS31Test, AIS31Verbose, targetFile);
View Full Code Here

    class GetRnDDataCmdArgHandler implements ArgHandler {

        public boolean inspectArg(Arg arg, CommandLine cl) {
            getRandomDataCmd = arg.getString(ARG_SET_GETRNDDATACMD);
            Apdu getChallengeApdu = new Apdu(getRandomDataCmd);
            if (getChallengeApdu.getExpectedLe() != 256) {
                throw new InvalidCommandLineException("Command to get random data must have LE=256, other case are not supported");
            }
            return true;
        }
View Full Code Here

                        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

        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

                                }
                                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

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.