use of es.gob.jmulticard.card.gide.smartcafe.SmartCafePrivateKeyReference in project jmulticard by ctt-gob-es.
the class SmartCafeKeyStoreImpl method engineGetKey.
/**
* {@inheritDoc}
*/
@Override
public Key engineGetKey(final String alias, final char[] password) {
if (!engineContainsAlias(alias)) {
return null;
}
if (password != null) {
// Establecemos el PasswordCallback
final PasswordCallback pwc = new CachePasswordCallback(password);
this.cryptoCard.setPasswordCallback(pwc);
}
final PrivateKeyReference pkRef = this.cryptoCard.getPrivateKey(alias);
if (!(pkRef instanceof SmartCafePrivateKeyReference)) {
throw new ProviderException(// $NON-NLS-1$
"La clave obtenida de la tarjeta no es del tipo '" + SmartCafePrivateKeyReference.class.getName() + // $NON-NLS-1$
"', se ha obtenido: " + // $NON-NLS-1$
(pkRef != null ? pkRef.getClass().getName() : "null"));
}
return new SmartCafePrivateKey((SmartCafePrivateKeyReference) pkRef, this.cryptoCard);
}
Aggregations