Examples of Apdu


Examples of com.sun.javacard.apduio.Apdu

   * @throws IOException
   * @throws CadTransportException
   */
  private void send(byte ins, byte P1, byte P2, byte lc, byte[] data, byte le)
  throws IOException, CadTransportException {
    apdu = new Apdu();
    apdu.command[Apdu.CLA] = CLA_PURSEAPPLET;
    apdu.command[Apdu.INS] = ins;
    apdu.command[Apdu.P1] = P1;
    apdu.command[Apdu.P2] = P2;
    apdu.setLc(lc);
View Full Code Here

Examples of com.sun.javacard.apduio.Apdu

        int choix = System.in.read();
        while (!(choix >= '1' && choix <= '4')) {
          choix = System.in.read();
        }
       
        apdu = new Apdu();
        apdu.command[Apdu.CLA] = PurseClientJC.CLA_PURSEAPPLET;
        apdu.command[Apdu.P1] = 0x00;
        apdu.command[Apdu.P2] = 0x00;
       
        switch (choix) {
View Full Code Here

Examples of com.sun.javacard.apduio.Apdu

      return;
    }
  }
 
  private void select() {
    apdu = new Apdu();
    apdu.command[Apdu.CLA] = 0x00;
    apdu.command[Apdu.INS] = (byte) 0xA4;
    apdu.command[Apdu.P1] = 0x04;
    apdu.command[Apdu.P2] = 0x00;
    byte[] appletAID = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00 };
View Full Code Here

Examples of uk.co.nimp.smartcard.Apdu

    }
    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

Examples of uk.co.nimp.smartcard.Apdu

        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

Examples of uk.co.nimp.smartcard.Apdu

            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

Examples of uk.co.nimp.smartcard.Apdu

                    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

Examples of uk.co.nimp.smartcard.Apdu

                    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

Examples of uk.co.nimp.smartcard.Apdu

                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

Examples of uk.co.nimp.smartcard.Apdu

    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
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.