Example usage for javax.smartcardio CardTerminal getName

List of usage examples for javax.smartcardio CardTerminal getName

Introduction

In this page you can find the example usage for javax.smartcardio CardTerminal getName.

Prototype

public abstract String getName();

Source Link

Document

Returns the unique name of this terminal.

Usage

From source file:net.java.jless.smartcard.SCIOSmartcard.java

/**
 * Constructor taking {@link javax.smartcardio.CardTerminal }.
 * Calls {@link CardTerminal#connect(String)} with <code>"*"</code>.
 * @param terminal card terminal//from www .ja  va 2s.  c  o m
 * @throws CardException if error connecting
 */
public SCIOSmartcard(CardTerminal terminal) throws CardException {
    this(terminal.connect("*"), terminal.getName());
}

From source file:test.integ.be.fedict.commons.eid.client.CardAndTerminalManagerExercises.java

@Override
public void terminalAttached(final CardTerminal terminalAttached) {
    LOG.debug("Terminal Attached [" + terminalAttached.getName() + "]");
}

From source file:test.integ.be.fedict.commons.eid.client.CardAndTerminalManagerExercises.java

@Override
public void terminalDetached(final CardTerminal terminalDetached) {
    LOG.debug("Terminal Detached [" + terminalDetached.getName() + "]");
}

From source file:test.integ.be.fedict.commons.eid.client.CardAndTerminalManagerExercises.java

@Override
public void cardRemoved(final CardTerminal terminalWithCardRemoved) {
    LOG.debug("Card Removed From [" + terminalWithCardRemoved.getName() + "]");
}

From source file:test.integ.be.fedict.commons.eid.client.CardAndTerminalManagerExercises.java

@Override
public void cardInserted(final CardTerminal cardTerminal, final Card card) {
    if (card != null) {
        LOG.debug("Card [" + StringUtils.atrToString(card.getATR()) + "] Inserted Into Terminal ["
                + cardTerminal.getName() + "]");
    } else {/*from w w w .  j  a va2 s  . c  o m*/
        LOG.debug("Card present but failed to connect()");
    }
}

From source file:davmail.util.ClientCertificateTest.java

public void testCardReaders() throws CardException {
    for (CardTerminal terminal : TerminalFactory.getDefault().terminals().list()) {
        System.out.println("Card terminal: " + terminal.getName() + " "
                + (terminal.isCardPresent() ? "Card present" : "No card"));
        terminal.waitForCardPresent(10);
        if (terminal.isCardPresent()) {
            Card c = null;//from   w  w  w. j a  v  a2s .  c  o m
            try {
                c = terminal.connect("T=0");
            } catch (Exception e) {
                // failover
                c = terminal.connect("T=1");
            }

            ATR atr = c.getATR();

            byte[] bytes = atr.getBytes();
            System.out.print("card:");

            for (byte b : bytes) {
                System.out.print(" " + Integer.toHexString(b & 0xff));
            }
            System.out.println();

        }
    }
}

From source file:com.cem.echo.Echo.java

protected boolean getCertificateList(CallbackContext callbackContext) {
    System.out.println("-----getcertlist: entrance deneme");

    List<String> certs = new ArrayList<String>();

    try {/*from w w w. j a va 2s  .c  om*/
        /*            InputStream lisansStream = cordova.getActivity().getResources().openRawResource(cordova.getActivity().getResources().getIdentifier("lisans", "raw", cordova.getActivity().getPackageName()));
                    LicenseUtil.setLicenseXml(lisansStream);
                    lisansStream.close();*/

        Resources activityRes = cordova.getActivity().getResources();
        int lisansid = activityRes.getIdentifier("lisans", "raw", cordova.getActivity().getPackageName());
        InputStream lisansStream = activityRes.openRawResource(lisansid);
        LicenseUtil.setLicenseXml(lisansStream);
        lisansStream.close();

        System.out.println("-----getcertlist: lisans aldik");

        mTerminalHandler = new SCDTerminalHandler(cordova.getActivity());

        mAPDUSmartCard = new APDUSmartCard(mTerminalHandler);
        mAPDUSmartCard.setDisableSecureMessaging(true);

        CardTerminal[] terminalList = mAPDUSmartCard.getTerminalList();

        CardTerminal cardTerminal = terminalList[0];

        //System.out.println("hehehe " + terminalList[0]);

        mAPDUSmartCard.openSession(cardTerminal);
        String readerName = cardTerminal.getName();
        List<byte[]> signCertValueList = mAPDUSmartCard.getSignatureCertificates();

        certificateList = new ArrayList<ECertificate>();

        for (byte[] signCertValue : signCertValueList) {
            ECertificate signCert = new ECertificate(signCertValue);
            //Sadece nitelikli sertifikalar ekiliyor.
            //Kanuni geerlilii olmayan sertifikalarla imza atlmak istenirse bu kontrol kaldrlabilir.
            //  if(signCert.isQualifiedCertificate()){
            certificateList.add(signCert);
            System.out.println("Sertifika Sahibi :" + signCert.getSubject().getCommonNameAttribute());
            certs.add(signCert.getSubject().getCommonNameAttribute());
            //}
        }
    } catch (Exception e) {
        e.printStackTrace();
        PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR);
        pluginResult.setKeepCallback(true);
        callbackContext.sendPluginResult(pluginResult);
        //callbackContext.error("Sertifikalar alrken bir hata olutu.");
        return false;
    }

    String[] res = new String[certs.size()];
    certs.toArray(res);

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, new JSONArray(certs));
    pluginResult.setKeepCallback(true);
    callbackContext.sendPluginResult(pluginResult);
    //callbackContext.success(new JSONArray(certs));
    return true;
}

From source file:de.willuhn.jameica.hbci.passports.pintan.Controller.java

/**
 * Liefert eine Auswahl verfuegbarer Kartenleser-Bezeichnungen.
 * @return eine Auswahl verfuegbaren Kartenleser-Bezeichnungen.
 * @throws RemoteException/*w w  w  .  ja  v a2s  .  c  o m*/
 */
public SelectInput getCardReaders() throws RemoteException {
    if (this.cardReaders != null)
        return this.cardReaders;

    List<String> available = new ArrayList<String>();

    // Erste Zeile Leerer Eintrag.
    // Damit das Feld auch dann leer bleiben kann, wenn der User nur einen
    // Kartenleser hat. Der sollte dann nicht automatisch vorselektiert
    // werden, da dessen Bezeichnung sonst unnoetigerweise hart gespeichert wird
    available.add("");
    try {
        TerminalFactory terminalFactory = TerminalFactory.getDefault();
        CardTerminals terminals = terminalFactory.terminals();
        if (terminals != null) {
            List<CardTerminal> list = terminals.list();
            if (list != null && list.size() > 0) {
                for (CardTerminal t : list) {
                    String name = StringUtils.trimToNull(t.getName());
                    if (name != null)
                        available.add(name);
                }
            }
        }
    } catch (Throwable t) {
        Logger.info("unable to determine card reader list: " + t.getMessage());
        Logger.write(Level.DEBUG, "stacktrace for debugging purpose", t);
    }

    this.cardReaders = new SelectInput(available, this.getConfig().getCardReader());
    this.cardReaders.setEditable(true);
    this.cardReaders.setComment(i18n.tr("nur ntig, wenn mehrere Leser vorhanden"));
    this.cardReaders.setName(i18n.tr("Identifier des PC/SC-Kartenlesers"));
    return this.cardReaders;
}