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");
}
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");
}
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]));
}
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]));
}
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()));
}
Aggregations