Package javax.smartcardio

Examples of javax.smartcardio.Card


  // CONSTRUCTOR
  public TopUpTerminal(){
    TerminalFactory    tf;
    CardTerminals      ct;
    List<CardTerminal> cs;
    Card card;

    loadBlacklist();
    CARD_LEGIT=false;
    cID="0";
    sg = Signature.getInstance(Signature.ALG_DES_MAC8_ISO9797_M2, false);
    try {
      cp = Cipher.getInstance("AES/ECB/NoPadding");
    } catch (Exception e) {
      Utilities.writeToLogs(home,"[E] "+e.toString());     
    }
    try {
      tf = TerminalFactory.getDefault();
      ct = tf.terminals();
      cs = ct.list(CardTerminals.State.CARD_PRESENT);
      if (cs.isEmpty()){
        Utilities.writeToLogs(home,"[E] No terminal with a card found!");
        System.out.println("[-] No terminal with a card found!");
        return;
      }
      for(CardTerminal c : cs){
        if (c.isCardPresent()){
          try{
            card = c.connect("*");
            try{
              ch =card.getBasicChannel();
              ResponseAPDU resp = ch.transmit(SELECT_APDU);
              terminal=c;

              if (resp.getSW() !=  0x9000){
                Utilities.writeToLogs(home,"[E] Problems: Card Device not selectable != 0x9000");
View Full Code Here


  // CONSTRUCTOR
  public PaymentTerminal(){
    TerminalFactory    tf;
    CardTerminals      ct;
    List<CardTerminal> cs;
    Card card;

    loadBlacklist();
    CARD_LEGIT=false;
    cID="0";
    sg = Signature.getInstance(Signature.ALG_DES_MAC8_ISO9797_M2, false);
    try {
      cp = Cipher.getInstance("AES/ECB/NoPadding");
    } catch (Exception e) {
      Utilities.writeToLogs(home,"[E] "+e.toString());     
    }
    try {
      tf = TerminalFactory.getDefault();
      ct = tf.terminals();
      cs = ct.list(CardTerminals.State.CARD_PRESENT);
      if (cs.isEmpty()){
        Utilities.writeToLogs(home,"[E] No terminal with a card found!");
        System.out.println("[-] No terminal with a card found!");
        return;
      }
      for(CardTerminal c : cs){
        if (c.isCardPresent()){
          try{
            card = c.connect("*");
            try{
              ch =card.getBasicChannel();
              ResponseAPDU resp = ch.transmit(SELECT_APDU);
              terminal=c;

              if (resp.getSW() !=  0x9000){
                Utilities.writeToLogs(home,"[E] Problems: Card Device not selectable != 0x9000");
View Full Code Here

  @Override
  public void initInitiatorDep() throws IOException {
    while (!Thread.interrupted()) {
      try {
        Card card = cardTerminal.connect("direct");
        scl3711 = new Scl3711(card);
        notifyStatus(TerminalStatus.WAITING);
        log.info("Waiting...");
        try {
          Scl3711NfcipManager nfcipManager = new Scl3711NfcipManager(scl3711);
          NFCIPConnection nfcipConnection = nfcipManager.connectAsInitiator();
          handleNfcipConnection(nfcipConnection);
        }
        catch (Exception e) {
        }
        finally {
          log.info("Disconnect from card");
          card.disconnect(true);
          notifyStatus(TerminalStatus.DISCONNECTED);
        }
      }
      catch (CardException e) {
        throw new IOException(e);
View Full Code Here

    while (!Thread.interrupted()) {
      log.info("Waiting...");
      notifyStatus(TerminalStatus.WAITING);
      try {
        if (cardTerminal.waitForCardPresent(500)) {
          Card card = null;
          try {
            card = cardTerminal.connect("*");
            byte[] historicalBytes = card.getATR().getHistoricalBytes();
            if (historicalBytes[9] == (byte)0xff && historicalBytes[10] == (byte)0x40) {
              openLlcpStack(card);
            }
            else {
              handleMfCard(card);
            }
          }
          catch (Exception e) {
            e.printStackTrace();
          }
          finally {
            if (card != null) {
              card.disconnect(true);
            }
            try {
              while (cardTerminal.isCardPresent()) {
                try {
                  Thread.sleep(500);
View Full Code Here

  @Override
  public void initTargetDep() throws IOException {
    try {
      while (true) {
        Card card = cardTerminal.connect("direct");
        ApduReaderWriter apduReaderWriter = new ApduReaderWriter(card, false);
        try {
          log.info("Waiting...");
          connectAsTarget(apduReaderWriter);
        }
        catch (Exception e1) {
          e1.printStackTrace();
          try {
            Thread.sleep(1000);
          }
          catch (InterruptedException e) {
            break;
          }
        }
        finally {
          card.disconnect(true);
        }
      }
    }
    catch (CardException e) {
      throw new IOException(e);
View Full Code Here

    }
  }

  public boolean waitForCard(int timeout) throws CardException, MfException, IOException, InterruptedException {
    if (cardTerminal.waitForCardPresent(timeout)) {
      Card card = cardTerminal.connect("*");
      CardResolver cardResolver = new CardResolver();
      MfCard mfCard = cardResolver.resolvecard(card);
      cardListener.cardDetected(mfCard, readerWriter);
      return true;
    }
View Full Code Here

  public void run() {
    while (!Thread.interrupted()) {
      notifyStatus(TerminalStatus.WAITING);
      try {
        if (cardTerminal.waitForCardPresent(500)) {
          Card card = null;
          try {
            card = cardTerminal.connect("*");
            notifyStatus(TerminalStatus.CONNECTED);
            handleCard(card);
          }
 
View Full Code Here

  public void run() {
    while (!Thread.interrupted()) {
      notifyStatus(TerminalStatus.WAITING);

      try {
        Card card = cardTerminal.connect("direct");

        byte[] historicalBytes = card.getATR().getHistoricalBytes();
        TagType tagType = AcsTagUtils.identifyTagType(historicalBytes);

        ApduTagReaderWriter readerWriter = new ApduTagReaderWriter(new AcsDirectChannelTag(tagType,
            historicalBytes, card));

        try {
          TamaNfcIpCommunicator nfcIpCommunicator = new TamaNfcIpCommunicator(readerWriter, readerWriter);
          nfcIpCommunicator.setNfcId(LlcpConstants.nfcId3t);
          nfcIpCommunicator.setFelicaParams(LlcpConstants.felicaParams);
          nfcIpCommunicator.setMifareParams(LlcpConstants.mifareParams);
          nfcIpCommunicator.setGeneralBytes(LlcpConstants.generalBytes);
          NFCIPConnection nfcipConnection = nfcIpCommunicator.connectAsTarget();
          handleNfcipConnection(nfcipConnection);

          //          tagListener.onTag(new AcsTag(tagType, historicalBytes, card));
        }
        catch (Exception e1) {
          card.disconnect(true);
          e1.printStackTrace();
          try {
            Thread.sleep(1000);
          }
          catch (InterruptedException e) {
View Full Code Here

            // establish a connection with the card
            if(!terminal.waitForCardPresent(500)) {
                System.out.println("no card inserted");
                return;
            }
            Card card = terminal.connect("*");
          
            try {

                System.out.println("card: " + card);
                System.out.println("proto: " + card.getProtocol());
                System.out.println("ATR-h: " + Converter.hexDump(card.getATR().getHistoricalBytes()));
                System.out.println("ATR: " + Converter.hexDump(card.getATR().getBytes()));
                CardChannel channel = card.getBasicChannel();
                System.out.println("Channel: " + channel.toString());
                System.out.println("Channel number: " + channel.getChannelNumber());

                 execTestScript(channel);

            } finally {
                card.disconnect(false);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

     * Создает объект сарткарты по терминалу, если в нем есть смарткарта
     * @param terminal
     * @return
     */
    public static SmartCard getInstance(CardTerminal terminal) {
        Card card = null;
        try {
            if (terminal.isCardPresent()) {
                card = terminal.connect("*");
            }
            if(card != null) {
View Full Code Here

TOP

Related Classes of javax.smartcardio.Card

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.