use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DGenerateKeyPairCert method generateCertificate.
private boolean generateCertificate() {
Date validityStart = jdtValidityStart.getDateTime();
Date validityEnd = jdtValidityEnd.getDateTime();
String serialNumberStr = jtfSerialNumber.getText().trim();
if (serialNumberStr.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DGenerateKeyPairCert.ValReqSerialNumber.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return false;
}
BigInteger serialNumber;
try {
serialNumber = new BigInteger(serialNumberStr);
if (serialNumber.compareTo(BigInteger.ONE) < 0) {
JOptionPane.showMessageDialog(this, res.getString("DGenerateKeyPairCert.SerialNumberNonZero.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return false;
}
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(this, res.getString("DGenerateKeyPairCert.SerialNumberNotInteger.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return false;
}
X500Name x500Name = jdnName.getDistinguishedName();
if (x500Name == null || x500Name.toString().isEmpty()) {
JOptionPane.showMessageDialog(this, res.getString("DGenerateKeyPairCert.NameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return false;
}
try {
SignatureType signatureType = ((SignatureType) jcbSignatureAlgorithm.getSelectedItem());
X509CertificateGenerator generator;
if (jrbVersion1.isSelected()) {
generator = new X509CertificateGenerator(VERSION1);
} else {
generator = new X509CertificateGenerator(VERSION3);
}
// self-signed or signed by other key pair?
if (issuerPrivateKey == null) {
certificate = generator.generateSelfSigned(x500Name, validityStart, validityEnd, keyPair.getPublic(), keyPair.getPrivate(), signatureType, serialNumber, extensions, provider);
} else {
certificate = generator.generate(x500Name, X500NameUtils.x500PrincipalToX500Name(issuerCert.getSubjectX500Principal()), validityStart, validityEnd, keyPair.getPublic(), issuerPrivateKey, signatureType, serialNumber, extensions, provider);
}
} catch (CryptoException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(getParent());
dError.setVisible(true);
closeDialog();
}
return true;
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DBasicConstraints method okPressed.
private void okPressed() {
boolean ca = jcbSubjectIsCa.isSelected();
int pathLengthConstraint = -1;
String pathLengthConstraintStr = jtfPathLengthConstraint.getText().trim();
if (pathLengthConstraintStr.length() > 0) {
try {
pathLengthConstraint = Integer.parseInt(pathLengthConstraintStr);
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(this, res.getString("DBasicConstraints.InvalidLengthValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
if (pathLengthConstraint < 0) {
JOptionPane.showMessageDialog(this, res.getString("DBasicConstraints.InvalidLengthValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
}
BasicConstraints basicConstraints;
if (pathLengthConstraint != -1) {
// pathLengthConstraint set automatically means ca=true
basicConstraints = new BasicConstraints(pathLengthConstraint);
} else {
basicConstraints = new BasicConstraints(ca);
}
try {
value = basicConstraints.getEncoded(ASN1Encoding.DER);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
closeDialog();
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DCertificatePolicies method okPressed.
private void okPressed() {
List<PolicyInformation> policyInformation = jpiCertificatePolicies.getPolicyInformation();
if (policyInformation.size() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DCertificatePolicies.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
CertificatePolicies certificatePolicies = new CertificatePolicies(policyInformation.toArray(new PolicyInformation[policyInformation.size()]));
try {
value = certificatePolicies.getEncoded(ASN1Encoding.DER);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
closeDialog();
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DNetscapeBaseUrl method okPressed.
private void okPressed() {
String netscapeBaseUrlStr = jtfNetscapeBaseUrl.getText().trim();
if (netscapeBaseUrlStr.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DNetscapeBaseUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
DERIA5String netscapeBaseUrl = new DERIA5String(netscapeBaseUrlStr);
try {
value = netscapeBaseUrl.getEncoded(ASN1Encoding.DER);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
closeDialog();
}
use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.
the class DNetscapeCaPolicyUrl method okPressed.
private void okPressed() {
String netscapeCaPolicyUrlStr = jtfNetscapeCaPolicyUrl.getText().trim();
if (netscapeCaPolicyUrlStr.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DNetscapeCaPolicyUrl.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
return;
}
DERIA5String netscapeCaPolicyUrl = new DERIA5String(netscapeCaPolicyUrlStr);
try {
value = netscapeCaPolicyUrl.getEncoded(ASN1Encoding.DER);
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
return;
}
closeDialog();
}
Aggregations