Search in sources :

Example 11 with ApduConnection

use of es.gob.jmulticard.apdu.connection.ApduConnection in project jmulticard by ctt-gob-es.

the class JMultiCardProviderFactory method getProvider.

/**
 * Obtiene el proveedor (con la conexión por defecto) correspondiente
 * a la primera tarjeta encontrada en el sistema.
 * @return Proveedor (con la conexión por defecto) correspondiente
 *         a la primera tarjeta encontrada insertada o <code>null</code> si
 *         no hay ninguna insertada, no ha lector de tarjetas o no se
 *         encuentra ninguna tarjeta soportada.
 */
public static Provider getProvider() {
    final ApduConnection conn = new SmartcardIoConnection();
    final long[] terminals;
    try {
        terminals = conn.getTerminals(false);
    } catch (final ApduConnectionException e1) {
        LOGGER.warning(// $NON-NLS-1$
        "No se ha podido obtener la lista de lectores de tarjetas del sistema: " + e1);
        return null;
    }
    byte[] atr = null;
    for (final long terminal : terminals) {
        conn.setTerminal((int) terminal);
        try {
            atr = conn.reset();
        } catch (final Exception e) {
            continue;
        }
    }
    return getProvider(atr);
}
Also used : SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection) ApduConnection(es.gob.jmulticard.apdu.connection.ApduConnection) ApduConnectionException(es.gob.jmulticard.apdu.connection.ApduConnectionException) ApduConnectionException(es.gob.jmulticard.apdu.connection.ApduConnectionException)

Example 12 with ApduConnection

use of es.gob.jmulticard.apdu.connection.ApduConnection in project jmulticard by ctt-gob-es.

the class SmartCafeKeyStoreImpl method engineLoad.

/**
 * {@inheritDoc}
 */
@Override
public void engineLoad(final InputStream stream, final char[] password) throws IOException {
    // Ponemos la conexion por defecto
    final ApduConnection conn = new es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection();
    // Aqui se realiza el acceso e inicializacion de la tarjeta
    this.cryptoCard = new SmartCafePkcs15Applet(conn, new JseCryptoHelper());
    if (password != null) {
        this.cryptoCard.setPasswordCallback(new CachePasswordCallback(password));
    }
    this.aliases = Arrays.asList(this.cryptoCard.getAliases());
}
Also used : SmartCafePkcs15Applet(es.gob.jmulticard.card.gide.smartcafe.SmartCafePkcs15Applet) JseCryptoHelper(es.gob.jmulticard.JseCryptoHelper) ApduConnection(es.gob.jmulticard.apdu.connection.ApduConnection)

Aggregations

ApduConnection (es.gob.jmulticard.apdu.connection.ApduConnection)12 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)5 CryptoCardException (es.gob.jmulticard.card.CryptoCardException)5 JseCryptoHelper (es.gob.jmulticard.JseCryptoHelper)4 SmartcardIoConnection (es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection)4 IOException (java.io.IOException)4 PinException (es.gob.jmulticard.card.PinException)3 Cwa14890Connection (es.gob.jmulticard.apdu.connection.cwa14890.Cwa14890Connection)2 Cwa14890OneV2Connection (es.gob.jmulticard.apdu.connection.cwa14890.Cwa14890OneV2Connection)2 AuthenticationModeLockedException (es.gob.jmulticard.card.AuthenticationModeLockedException)2 BadPinException (es.gob.jmulticard.card.BadPinException)2 Dnie (es.gob.jmulticard.card.dnie.Dnie)2 SmartCafePkcs15Applet (es.gob.jmulticard.card.gide.smartcafe.SmartCafePkcs15Applet)2 ProviderException (java.security.ProviderException)2 Cwa14890OneV1Connection (es.gob.jmulticard.apdu.connection.cwa14890.Cwa14890OneV1Connection)1 StCard (es.gob.jmulticard.card.bit4id.stcm.StCard)1 CeresSc (es.gob.jmulticard.card.dnie.CeresSc)1 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)1 KeyStore (java.security.KeyStore)1 PasswordProtection (java.security.KeyStore.PasswordProtection)1