use of es.gob.jmulticard.asn1.Asn1Exception in project keystore-explorer by kaikramer.
the class DViewCrl method asn1DumpPressed.
private void asn1DumpPressed() {
try {
DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, crl);
dViewAsn1Dump.setLocationRelativeTo(this);
dViewAsn1Dump.setVisible(true);
} catch (Asn1Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
use of es.gob.jmulticard.asn1.Asn1Exception in project keystore-explorer by kaikramer.
the class DViewCsr method asn1DumpPressed.
private void asn1DumpPressed() {
try {
DViewAsn1Dump dViewAsn1Dump;
if (pkcs10Csr != null) {
dViewAsn1Dump = new DViewAsn1Dump(this, pkcs10Csr);
} else {
dViewAsn1Dump = new DViewAsn1Dump(this, spkacCsr);
}
dViewAsn1Dump.setLocationRelativeTo(this);
dViewAsn1Dump.setVisible(true);
} catch (Asn1Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
use of es.gob.jmulticard.asn1.Asn1Exception in project keystore-explorer by kaikramer.
the class DViewPrivateKey method asn1DumpPressed.
private void asn1DumpPressed() {
try {
DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, privateKey);
dViewAsn1Dump.setLocationRelativeTo(this);
dViewAsn1Dump.setVisible(true);
} catch (Asn1Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
use of es.gob.jmulticard.asn1.Asn1Exception in project keystore-explorer by kaikramer.
the class DViewExtensions method asn1DumpPressed.
private void asn1DumpPressed() {
int selectedRow = jtExtensions.getSelectedRow();
if (selectedRow == -1) {
return;
}
String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId();
byte[] value = extensions.getExtensionValue(oid);
boolean criticality = (Boolean) jtExtensions.getValueAt(selectedRow, 0);
X509Ext extension = new X509Ext(oid, value, criticality);
try {
DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, extension);
dViewAsn1Dump.setLocationRelativeTo(this);
dViewAsn1Dump.setVisible(true);
} catch (Asn1Exception ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
use of es.gob.jmulticard.asn1.Asn1Exception in project jmulticard by ctt-gob-es.
the class Ceres method preload.
private void preload() throws ApduConnectionException, Iso7816FourCardException, IOException, CertificateException, Asn1Exception, TlvException {
// Nos vamos al raiz antes de nada
selectMasterFile();
// Leemos el CDF
final byte[] cdfBytes = selectFileByLocationAndRead(CDF_LOCATION);
// Cargamos el CDF
Pkcs15Cdf cdf = new CeresCdf();
try {
cdf.setDerValue(cdfBytes);
} catch (final Exception e) {
// Si ha fallado la inicializacion del CDF tipo CERES probamos con el CDF generico PKCS#15,
// presente en las nuevas tarjetas FNMT-CERES
cdf = new Cdf();
cdf.setDerValue(cdfBytes);
}
// Leemos los certificados segun las rutas del CDF
this.certs = new LinkedHashMap<>(cdf.getCertificateCount());
this.aliasByCertAndKeyId = new LinkedHashMap<>(cdf.getCertificateCount());
for (int i = 0; i < cdf.getCertificateCount(); i++) {
final Location l = new Location(// $NON-NLS-1$ //$NON-NLS-2$
cdf.getCertificatePath(i).replace("\\", "").trim());
X509Certificate cert;
try {
cert = CompressionUtils.getCertificateFromCompressedOrNotData(selectFileByLocationAndRead(l));
} catch (final IOException e) {
// $NON-NLS-1$
LOGGER.warning("No se ha encontrado un certificado referenciado, se pasa al siguiente: " + e);
continue;
}
// $NON-NLS-1$
final String alias = i + " " + cert.getSerialNumber();
this.aliasByCertAndKeyId.put(HexUtils.hexify(cdf.getCertificateId(i), false), alias);
this.certs.put(alias, cert);
}
// Leemos el PrKDF
final byte[] prkdfValue = selectFileByLocationAndRead(PRKDF_LOCATION);
// Establecemos el valor del PrKDF
Pkcs15PrKdf prkdf = new CeresPrKdf();
try {
prkdf.setDerValue(prkdfValue);
} catch (final Exception e) {
// Si no carga el estructura PrKDF especifica de CERES probamos con la
// generica PKCS#15, presente en las ultimas versiones de la tarjeta
prkdf = new PrKdf();
prkdf.setDerValue(prkdfValue);
}
this.keys = new LinkedHashMap<>();
for (int i = 0; i < prkdf.getKeyCount(); i++) {
final String alias = this.aliasByCertAndKeyId.get(HexUtils.hexify(prkdf.getKeyId(i), false));
if (alias != null) {
this.keys.put(alias, Byte.valueOf(prkdf.getKeyReference(i)));
}
}
// Sincronizamos claves y certificados
hideCertsWithoutKey();
}
Aggregations