Search in sources :

Example 6 with SmartcardIoConnection

use of es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection in project jmulticard by ctt-gob-es.

the class TestDoubleSign method testDoubleSign.

static void testDoubleSign() throws Exception {
    final Provider p = new DnieProvider(new SmartcardIoConnection());
    Security.addProvider(p);
    // $NON-NLS-1$
    final KeyStore ks = KeyStore.getInstance("DNI");
    ks.load(null, PASSWORD);
    final Enumeration<String> aliases = ks.aliases();
    while (aliases.hasMoreElements()) {
        System.out.println(aliases.nextElement());
    }
    // $NON-NLS-1$
    Signature signature = Signature.getInstance("SHA1withRSA");
    // $NON-NLS-1$
    signature.initSign((PrivateKey) ks.getKey("CertFirmaDigital", PASSWORD));
    // $NON-NLS-1$
    signature.update("Hola Mundo!!".getBytes());
    signature.sign();
    // $NON-NLS-1$
    System.out.println("Primera firma generada correctamente");
    // $NON-NLS-1$
    signature = Signature.getInstance("SHA1withRSA");
    // $NON-NLS-1$
    signature.initSign((PrivateKey) ks.getKey("CertFirmaDigital", PASSWORD));
    // $NON-NLS-1$
    signature.update("Hola Mundo 2!!".getBytes());
    signature.sign();
    // $NON-NLS-1$
    System.out.println("Segunda firma generada correctamente");
}
Also used : DnieProvider(es.gob.jmulticard.jse.provider.DnieProvider) Signature(java.security.Signature) SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection) KeyStore(java.security.KeyStore) DnieProvider(es.gob.jmulticard.jse.provider.DnieProvider) Provider(java.security.Provider)

Example 7 with SmartcardIoConnection

use of es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection in project jmulticard by ctt-gob-es.

the class TestPaceDnie method main.

/**
 * Main.
 * @param args No se usa.
 * @throws Exception En cualquier error.
 */
public static void main(final String[] args) throws Exception {
    final ApduConnection conn = new SmartcardIoConnection();
    // $NON-NLS-1$
    final CachePasswordCallback cpc = new CachePasswordCallback("password".toCharArray());
    final Dnie dni = DnieFactory.getDnie(conn, cpc, new JseCryptoHelper(), null);
    // $NON-NLS-1$
    System.out.println("Canal PACE abierto");
    // $NON-NLS-1$ //$NON-NLS-2$
    dni.changePIN("password", "1234512345");
    // $NON-NLS-1$
    System.out.println("Se ha realizado el cambio de PIN correctamente");
}
Also used : Dnie(es.gob.jmulticard.card.dnie.Dnie) SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection) ApduConnection(es.gob.jmulticard.apdu.connection.ApduConnection)

Example 8 with SmartcardIoConnection

use of es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection in project jmulticard by ctt-gob-es.

the class TestCardOS method main.

/**
 * Main.
 * @param args No se usa.
 * @throws Exception En cualquier error.
 */
public static void main(final String[] args) throws Exception {
    final CardOS cardos = new CardOS(new SmartcardIoConnection());
    System.out.println(cardos.getCardName());
    System.out.println(Arrays.asList(cardos.getAliases()));
// System.out.println(tui.getPrivateKey(tui.getAliases()[0]));
}
Also used : CardOS(es.gob.jmulticard.card.cardos.CardOS) SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection)

Example 9 with SmartcardIoConnection

use of es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection in project jmulticard by ctt-gob-es.

the class TestTui method main.

/**
 * Main.
 * @param args No se usa.
 * @throws Exception En cualquier error.
 */
public static void main(final String[] args) throws Exception {
    final TuiR5 tui = new TuiR5(new SmartcardIoConnection(), // $NON-NLS-1$
    new TestTui.CachePasswordCallback("1111".toCharArray()));
    System.out.println(tui.getCardName());
    System.out.println(Arrays.asList(tui.getAliases()));
    System.out.println(tui.getPrivateKey(tui.getAliases()[0]));
}
Also used : SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection) TuiR5(es.gob.jmulticard.card.gemalto.tuir5.TuiR5)

Example 10 with SmartcardIoConnection

use of es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection in project jmulticard by ctt-gob-es.

the class TestStBit4IdCamerfirma method main.

/**
 * Prueba general de la tarjeta.
 * @param args No se usa.
 * @throws Exception En cualquier error.
 */
public static void main(final String[] args) throws Exception {
    final ApduConnection conn = new SmartcardIoConnection();
    final StCard card = new StCard(conn);
    card.verifyPin(new CachePasswordCallback(PIN.toCharArray()));
}
Also used : StCard(es.gob.jmulticard.card.bit4id.stcm.StCard) SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection) ApduConnection(es.gob.jmulticard.apdu.connection.ApduConnection)

Aggregations

SmartcardIoConnection (es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection)14 Ignore (org.junit.Ignore)5 Test (org.junit.Test)5 ApduConnection (es.gob.jmulticard.apdu.connection.ApduConnection)4 PrivateKeyReference (es.gob.jmulticard.card.PrivateKeyReference)3 SmartCafePkcs15Applet (es.gob.jmulticard.card.gide.smartcafe.SmartCafePkcs15Applet)3 KeyStore (java.security.KeyStore)3 Provider (java.security.Provider)3 Signature (java.security.Signature)3 Dnie (es.gob.jmulticard.card.dnie.Dnie)2 Ceres (es.gob.jmulticard.card.fnmt.ceres.Ceres)2 DnieProvider (es.gob.jmulticard.jse.provider.DnieProvider)2 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)1 CryptoCard (es.gob.jmulticard.card.CryptoCard)1 StCard (es.gob.jmulticard.card.bit4id.stcm.StCard)1 CardOS (es.gob.jmulticard.card.cardos.CardOS)1 TuiR5 (es.gob.jmulticard.card.gemalto.tuir5.TuiR5)1 Iso7816FourCard (es.gob.jmulticard.card.iso7816four.Iso7816FourCard)1 CeresProvider (es.gob.jmulticard.jse.provider.ceres.CeresProvider)1 LoadStoreParameter (java.security.KeyStore.LoadStoreParameter)1