use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DViewCertificate method asn1DumpPressed.
private void asn1DumpPressed() {
X509Certificate cert = getSelectedCertificate();
try {
DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, cert);
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 org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DViewCertificate method populateDetails.
private void populateDetails() {
X509Certificate cert = getSelectedCertificate();
if (cert == null) {
jdnSubject.setEnabled(false);
jdnIssuer.setEnabled(false);
jbViewPublicKeyDetails.setEnabled(false);
jcfFingerprint.setEnabled(false);
jbExtensions.setEnabled(false);
jbPem.setEnabled(false);
jbAsn1.setEnabled(false);
jtfVersion.setText("");
jdnSubject.setDistinguishedName(null);
jdnIssuer.setDistinguishedName(null);
jtfSerialNumber.setText("");
jtfValidFrom.setText("");
jtfValidUntil.setText("");
jtfPublicKey.setText("");
jtfSignatureAlgorithm.setText("");
jcfFingerprint.setEncodedCertificate(null);
} else {
jdnSubject.setEnabled(true);
jdnIssuer.setEnabled(true);
jbViewPublicKeyDetails.setEnabled(true);
jbExtensions.setEnabled(true);
jbPem.setEnabled(true);
jbAsn1.setEnabled(true);
try {
Date currentDate = new Date();
Date startDate = cert.getNotBefore();
Date endDate = cert.getNotAfter();
boolean notYetValid = currentDate.before(startDate);
boolean noLongerValid = currentDate.after(endDate);
jtfVersion.setText(Integer.toString(cert.getVersion()));
jtfVersion.setCaretPosition(0);
jdnSubject.setDistinguishedName(X500NameUtils.x500PrincipalToX500Name(cert.getSubjectX500Principal()));
jdnIssuer.setDistinguishedName(X500NameUtils.x500PrincipalToX500Name(cert.getIssuerX500Principal()));
jtfSerialNumber.setText("0x" + new BigInteger(1, cert.getSerialNumber().toByteArray()).toString(16).toUpperCase());
jtfSerialNumber.setCaretPosition(0);
jtfValidFrom.setText(StringUtils.formatDate(startDate));
if (notYetValid) {
jtfValidFrom.setText(MessageFormat.format(res.getString("DViewCertificate.jtfValidFrom.notyetvalid.text"), jtfValidFrom.getText()));
jtfValidFrom.setForeground(Color.red);
} else {
jtfValidFrom.setForeground(jtfVersion.getForeground());
}
jtfValidFrom.setCaretPosition(0);
jtfValidUntil.setText(StringUtils.formatDate(endDate));
if (noLongerValid) {
jtfValidUntil.setText(MessageFormat.format(res.getString("DViewCertificate.jtfValidUntil.expired.text"), jtfValidUntil.getText()));
jtfValidUntil.setForeground(Color.red);
} else {
jtfValidUntil.setForeground(jtfVersion.getForeground());
}
jtfValidUntil.setCaretPosition(0);
KeyInfo keyInfo = KeyPairUtil.getKeyInfo(cert.getPublicKey());
jtfPublicKey.setText(keyInfo.getAlgorithm());
Integer keySize = keyInfo.getSize();
if (keySize != null) {
jtfPublicKey.setText(MessageFormat.format(res.getString("DViewCertificate.jtfPublicKey.text"), jtfPublicKey.getText(), "" + keySize));
} else {
jtfPublicKey.setText(MessageFormat.format(res.getString("DViewCertificate.jtfPublicKey.text"), jtfPublicKey.getText(), "?"));
}
jtfPublicKey.setCaretPosition(0);
jtfSignatureAlgorithm.setText(X509CertUtil.getCertificateSignatureAlgorithm(cert));
jtfSignatureAlgorithm.setCaretPosition(0);
byte[] encodedCertificate;
try {
encodedCertificate = cert.getEncoded();
} catch (CertificateEncodingException ex) {
throw new CryptoException(res.getString("DViewCertificate.NoGetEncodedCert.exception.message"), ex);
}
jcfFingerprint.setEncodedCertificate(encodedCertificate);
jcfFingerprint.setFingerprintAlg(ApplicationSettings.getInstance().getCertificateFingerprintType());
Set<?> critExts = cert.getCriticalExtensionOIDs();
Set<?> nonCritExts = cert.getNonCriticalExtensionOIDs();
if (critExts != null && critExts.size() != 0 || nonCritExts != null && nonCritExts.size() != 0) {
jbExtensions.setEnabled(true);
} else {
jbExtensions.setEnabled(false);
}
} catch (CryptoException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
dispose();
}
}
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DViewCsr method pubKeyDetailsPressed.
private void pubKeyDetailsPressed() {
try {
PublicKey publicKey = null;
if (pkcs10Csr != null) {
publicKey = getPkcs10PublicKey();
} else {
publicKey = spkacCsr.getPublicKey();
}
DViewPublicKey dViewPublicKey = new DViewPublicKey(this, res.getString("DViewCsr.PubKeyDetails.Title"), publicKey);
dViewPublicKey.setLocationRelativeTo(this);
dViewPublicKey.setVisible(true);
} catch (CryptoException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DViewPrivateKey method pemEncodingPressed.
private void pemEncodingPressed() {
try {
DViewPem dViewCsrPem = new DViewPem(this, res.getString("DViewPrivateKey.Pem.Title"), privateKey);
dViewCsrPem.setLocationRelativeTo(this);
dViewCsrPem.setVisible(true);
} catch (CryptoException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DViewPublicKey method asn1DumpPressed.
private void asn1DumpPressed() {
try {
DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, publicKey);
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);
}
}
Aggregations