Java Code Examples for javax.smartcardio.Card#endExclusive()

The following examples show how to use javax.smartcardio.Card#endExclusive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PCSCUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
   TerminalFactory factory = TerminalFactory.getDefault();
   List<CardTerminal> terminals = factory.terminals().list();
   LOG.debug("Terminals: " + terminals);
   Card card = null;
   Iterator i$ = terminals.iterator();

   while(i$.hasNext()) {
      CardTerminal terminal = (CardTerminal)i$.next();
      if (terminal.isCardPresent()) {
         card = terminal.connect("*");
         if (card != null && matchesEidAtr(card.getATR())) {
            break;
         }
      }
   }

   if (card == null) {
      throw new CardNotPresentException("EID is not present");
   } else {
      card.beginExclusive();
      LOG.debug("card: " + card);
      CardChannel cardChannel = card.getBasicChannel();
      ResponseAPDU responseApdu = cardChannel.transmit(commandApdu);
      if (108 == responseApdu.getSW1()) {
         LOG.debug("sleeping...");

         try {
            Thread.sleep(10L);
         } catch (InterruptedException var7) {
            throw new be.ehealth.technicalconnector.exception.InterruptedException("Cannot sleep", var7);
         }

         responseApdu = cardChannel.transmit(commandApdu);
      }

      card.endExclusive();
      card.disconnect(false);
      return responseApdu;
   }
}
 
Example 2
Source File: PCSCUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
   TerminalFactory factory = TerminalFactory.getDefault();
   List<CardTerminal> terminals = factory.terminals().list();
   LOG.debug("Terminals: " + terminals);
   Card card = null;
   Iterator i$ = terminals.iterator();

   while(i$.hasNext()) {
      CardTerminal terminal = (CardTerminal)i$.next();
      if (terminal.isCardPresent()) {
         card = terminal.connect("*");
         if (card != null && matchesEidAtr(card.getATR())) {
            break;
         }
      }
   }

   if (card == null) {
      throw new CardNotPresentException("EID is not present");
   } else {
      card.beginExclusive();
      LOG.debug("card: " + card);
      CardChannel cardChannel = card.getBasicChannel();
      ResponseAPDU responseApdu = cardChannel.transmit(commandApdu);
      if (108 == responseApdu.getSW1()) {
         LOG.debug("sleeping...");

         try {
            Thread.sleep(10L);
         } catch (InterruptedException var7) {
            throw new be.ehealth.technicalconnector.exception.InterruptedException("Cannot sleep", var7);
         }

         responseApdu = cardChannel.transmit(commandApdu);
      }

      card.endExclusive();
      card.disconnect(false);
      return responseApdu;
   }
}
 
Example 3
Source File: PCSCUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
   TerminalFactory factory = TerminalFactory.getDefault();
   List<CardTerminal> terminals = factory.terminals().list();
   LOG.debug("Terminals: " + terminals);
   Card card = null;
   Iterator i$ = terminals.iterator();

   while(i$.hasNext()) {
      CardTerminal terminal = (CardTerminal)i$.next();
      if (terminal.isCardPresent()) {
         card = terminal.connect("*");
         if (card != null && matchesEidAtr(card.getATR())) {
            break;
         }
      }
   }

   if (card == null) {
      throw new CardNotPresentException("EID is not present");
   } else {
      card.beginExclusive();
      LOG.debug("card: " + card);
      CardChannel cardChannel = card.getBasicChannel();
      ResponseAPDU responseApdu = cardChannel.transmit(commandApdu);
      if (108 == responseApdu.getSW1()) {
         LOG.debug("sleeping...");

         try {
            Thread.sleep(10L);
         } catch (InterruptedException var7) {
            throw new be.ehealth.technicalconnector.exception.InterruptedException("Cannot sleep", var7);
         }

         responseApdu = cardChannel.transmit(commandApdu);
      }

      card.endExclusive();
      card.disconnect(false);
      return responseApdu;
   }
}
 
Example 4
Source File: PCSCUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
   TerminalFactory factory = TerminalFactory.getDefault();
   List<CardTerminal> terminals = factory.terminals().list();
   LOG.debug("Terminals: " + terminals);
   Card card = null;
   Iterator i$ = terminals.iterator();

   while(i$.hasNext()) {
      CardTerminal terminal = (CardTerminal)i$.next();
      if (terminal.isCardPresent()) {
         card = terminal.connect("*");
         if (card != null && matchesEidAtr(card.getATR())) {
            break;
         }
      }
   }

   if (card == null) {
      throw new CardNotPresentException("EID is not present");
   } else {
      card.beginExclusive();
      LOG.debug("card: " + card);
      CardChannel cardChannel = card.getBasicChannel();
      ResponseAPDU responseApdu = cardChannel.transmit(commandApdu);
      if (108 == responseApdu.getSW1()) {
         LOG.debug("sleeping...");

         try {
            Thread.sleep(10L);
         } catch (InterruptedException var7) {
            throw new be.ehealth.technicalconnector.exception.InterruptedException("Cannot sleep", var7);
         }

         responseApdu = cardChannel.transmit(commandApdu);
      }

      card.endExclusive();
      card.disconnect(false);
      return responseApdu;
   }
}
 
Example 5
Source File: PCSCUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private static ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
   TerminalFactory factory = TerminalFactory.getDefault();
   List<CardTerminal> terminals = factory.terminals().list();
   LOG.debug("Terminals: " + terminals);
   Card card = null;
   Iterator i$ = terminals.iterator();

   while(i$.hasNext()) {
      CardTerminal terminal = (CardTerminal)i$.next();
      if (terminal.isCardPresent()) {
         card = terminal.connect("*");
         if (card != null && matchesEidAtr(card.getATR())) {
            break;
         }
      }
   }

   if (card == null) {
      throw new CardNotPresentException("EID is not present");
   } else {
      card.beginExclusive();
      LOG.debug("card: " + card);
      CardChannel cardChannel = card.getBasicChannel();
      ResponseAPDU responseApdu = cardChannel.transmit(commandApdu);
      if (108 == responseApdu.getSW1()) {
         LOG.debug("sleeping...");

         try {
            Thread.sleep(10L);
         } catch (InterruptedException var7) {
            throw new org.taktik.connector.technical.exception.InterruptedException("Cannot sleep", var7);
         }

         responseApdu = cardChannel.transmit(commandApdu);
      }

      card.endExclusive();
      card.disconnect(false);
      return responseApdu;
   }
}