Search in sources :

Example 1 with CryptoCard

use of es.gob.jmulticard.card.CryptoCard in project jmulticard by ctt-gob-es.

the class TestAccv method testReadCertificates.

/**
 * Prueba de lectura de certificados.
 * @throws Exception En cualquier error.
 */
@SuppressWarnings("static-method")
@Test
@Ignore
public void testReadCertificates() throws Exception {
    final CryptoCard card = new SmartCafePkcs15Applet(new SmartcardIoConnection(), new JseCryptoHelper());
    final String[] aliases = card.getAliases();
    if (aliases.length < 1) {
        // $NON-NLS-1$
        System.out.println("La tarjeta no tiene certificados");
        return;
    }
    final String selectedAlias = aliases[0];
    // $NON-NLS-1$
    System.out.println("Alias encontrados:");
    for (final String alias : aliases) {
        // $NON-NLS-1$
        System.out.println("  " + alias);
    }
    System.out.println();
    final X509Certificate c = card.getCertificate(selectedAlias);
    // $NON-NLS-1$
    System.out.println("Primer certificado encontrado: " + AOUtil.getCN(c));
}
Also used : SmartCafePkcs15Applet(es.gob.jmulticard.card.gide.smartcafe.SmartCafePkcs15Applet) CryptoCard(es.gob.jmulticard.card.CryptoCard) SmartcardIoConnection(es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection) X509Certificate(java.security.cert.X509Certificate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CryptoCard (es.gob.jmulticard.card.CryptoCard)1 SmartCafePkcs15Applet (es.gob.jmulticard.card.gide.smartcafe.SmartCafePkcs15Applet)1 SmartcardIoConnection (es.gob.jmulticard.jse.smartcardio.SmartcardIoConnection)1 X509Certificate (java.security.cert.X509Certificate)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1