use of es.gob.jmulticard.card.fnmt.ceres.Ceres in project jmulticard by ctt-gob-es.
the class TestCeres method testCeresUIPasswordCallbackSpecialCharsOnPin.
/**
* Prueba de introducción de PIN por UI, para comprobación de PIN
* con caracteres especiales.
* @throws Exception En cualquier error.
*/
@SuppressWarnings("static-method")
@Test
@Ignore
public void testCeresUIPasswordCallbackSpecialCharsOnPin() throws Exception {
final Ceres ceres = new Ceres(new SmartcardIoConnection(), new JseCryptoHelper());
ceres.setPasswordCallback(// $NON-NLS-1$
new PasswordCallback("PIN de la tarjeta CERES", false));
System.out.println(ceres.getCardName());
System.out.println(Arrays.asList(ceres.getAliases()));
System.out.println(ceres.getCertificate(ceres.getAliases()[0]));
final PrivateKeyReference pkr = ceres.getPrivateKey(ceres.getAliases()[0]);
System.out.println(HexUtils.hexify(// $NON-NLS-1$//$NON-NLS-2$
ceres.sign("hola".getBytes(), "SHA1withRSA", pkr), true));
}
use of es.gob.jmulticard.card.fnmt.ceres.Ceres in project jmulticard by ctt-gob-es.
the class CeresKeyStoreImpl method engineLoad.
/**
* {@inheritDoc}
*/
@Override
public void engineLoad(final KeyStore.LoadStoreParameter param) throws IOException {
if (param != null) {
final ProtectionParameter pp = param.getProtectionParameter();
if (pp instanceof KeyStore.CallbackHandlerProtection) {
if (((KeyStore.CallbackHandlerProtection) pp).getCallbackHandler() == null) {
// $NON-NLS-1$
throw new IllegalArgumentException("El CallbackHandler no puede ser nulo");
}
this.cryptoCard = new Ceres(CeresProvider.getDefaultApduConnection(), new JseCryptoHelper());
this.cryptoCard.setCallbackHandler(((KeyStore.CallbackHandlerProtection) pp).getCallbackHandler());
} else if (pp instanceof KeyStore.PasswordProtection) {
final PasswordCallback pwc = new CeresPasswordCallback((PasswordProtection) pp);
this.cryptoCard = new Ceres(CeresProvider.getDefaultApduConnection(), new JseCryptoHelper());
this.cryptoCard.setPasswordCallback(pwc);
} else {
// $NON-NLS-1$
Logger.getLogger("es.gob.jmulticard").warning(// $NON-NLS-1$ //$NON-NLS-2$
"Se ha proporcionado un LoadStoreParameter de tipo no soportado, se ignorara: " + (pp != null ? pp.getClass().getName() : "NULO"));
}
} else {
this.cryptoCard = new Ceres(CeresProvider.getDefaultApduConnection(), new JseCryptoHelper());
}
userCertAliases = Arrays.asList(this.cryptoCard.getAliases());
}
use of es.gob.jmulticard.card.fnmt.ceres.Ceres in project jmulticard by ctt-gob-es.
the class CeresKeyStoreImpl method engineLoad.
/**
* {@inheritDoc}
*/
@Override
public void engineLoad(final InputStream stream, final char[] password) throws IOException {
// Aqui se realiza el acceso e inicializacion de la tarjeta
this.cryptoCard = new Ceres(getApduConnection(), new JseCryptoHelper());
// Precargamos los alias
loadAliases();
}
use of es.gob.jmulticard.card.fnmt.ceres.Ceres in project jmulticard by ctt-gob-es.
the class TestCeres method main.
/**
* Main.
* @param args No se usa.
* @throws Exception En cualquier error.
*/
public static void main(final String[] args) throws Exception {
final Ceres ceres = new Ceres(new SmartcardIoConnection(), new JseCryptoHelper());
ceres.setPasswordCallback(new CachePasswordCallback(PIN.toCharArray()));
System.out.println(ceres.getCardName());
System.out.println(Arrays.asList(ceres.getAliases()));
System.out.println(ceres.getCertificate(ceres.getAliases()[0]));
final PrivateKeyReference pkr = ceres.getPrivateKey(ceres.getAliases()[0]);
System.out.println(HexUtils.hexify(// $NON-NLS-1$//$NON-NLS-2$
ceres.sign("hola".getBytes(), "SHA1withRSA", pkr), true));
}
Aggregations