use of org.kse.crypto.x509.X509ExtensionType in project keystore-explorer by kaikramer.
the class DAddExtensions method addPressed.
private void addPressed() {
DAddExtensionType dAddExtensionType = new DAddExtensionType(this, extensions);
dAddExtensionType.setLocationRelativeTo(this);
dAddExtensionType.setVisible(true);
X509ExtensionType extensionTypeToAdd = dAddExtensionType.getExtensionType();
if (extensionTypeToAdd == null) {
return;
}
boolean isCritical = dAddExtensionType.isExtensionCritical();
byte[] extensionValue = null;
DExtension dExtension = null;
switch(extensionTypeToAdd) {
case AUTHORITY_INFORMATION_ACCESS:
{
dExtension = new DAuthorityInformationAccess(this);
break;
}
case AUTHORITY_KEY_IDENTIFIER:
{
dExtension = new DAuthorityKeyIdentifier(this, authorityPublicKey, authorityCertName, authorityCertSerialNumber);
break;
}
case BASIC_CONSTRAINTS:
{
dExtension = new DBasicConstraints(this);
break;
}
case CERTIFICATE_POLICIES:
{
dExtension = new DCertificatePolicies(this);
break;
}
case EXTENDED_KEY_USAGE:
{
dExtension = new DExtendedKeyUsage(this);
break;
}
case INHIBIT_ANY_POLICY:
{
dExtension = new DInhibitAnyPolicy(this);
break;
}
case ISSUER_ALTERNATIVE_NAME:
{
dExtension = new DIssuerAlternativeName(this);
break;
}
case KEY_USAGE:
{
dExtension = new DKeyUsage(this);
break;
}
case NAME_CONSTRAINTS:
{
dExtension = new DNameConstraints(this);
break;
}
case NETSCAPE_BASE_URL:
{
dExtension = new DNetscapeBaseUrl(this);
break;
}
case NETSCAPE_CA_POLICY_URL:
{
dExtension = new DNetscapeCaPolicyUrl(this);
break;
}
case NETSCAPE_CA_REVOCATION_URL:
{
dExtension = new DNetscapeCaRevocationUrl(this);
break;
}
case NETSCAPE_CERTIFICATE_RENEWAL_URL:
{
dExtension = new DNetscapeCertificateRenewalUrl(this);
break;
}
case NETSCAPE_CERTIFICATE_TYPE:
{
dExtension = new DNetscapeCertificateType(this);
break;
}
case NETSCAPE_COMMENT:
{
dExtension = new DNetscapeComment(this);
break;
}
case NETSCAPE_REVOCATION_URL:
{
dExtension = new DNetscapeRevocationUrl(this);
break;
}
case NETSCAPE_SSL_SERVER_NAME:
{
dExtension = new DNetscapeSslServerName(this);
break;
}
case POLICY_CONSTRAINTS:
{
dExtension = new DPolicyConstraints(this);
break;
}
case POLICY_MAPPINGS:
{
dExtension = new DPolicyMappings(this);
break;
}
case PRIVATE_KEY_USAGE_PERIOD:
{
dExtension = new DPrivateKeyUsagePeriod(this);
break;
}
case SUBJECT_ALTERNATIVE_NAME:
{
dExtension = new DSubjectAlternativeName(this);
break;
}
case SUBJECT_INFORMATION_ACCESS:
{
dExtension = new DSubjectInformationAccess(this);
break;
}
case SUBJECT_KEY_IDENTIFIER:
{
dExtension = new DSubjectKeyIdentifier(this, subjectPublicKey);
break;
}
default:
{
return;
}
}
dExtension.setLocationRelativeTo(this);
dExtension.setVisible(true);
extensionValue = dExtension.getValue();
if (extensionValue == null) {
return;
}
extensions.addExtension(extensionTypeToAdd.oid(), isCritical, extensionValue);
reloadExtensionsTable();
selectExtensionInTable(extensionTypeToAdd.oid());
updateButtonControls();
}
use of org.kse.crypto.x509.X509ExtensionType in project keystore-explorer by kaikramer.
the class DAddExtensionType method initComponents.
private void initComponents() {
jpExtensionTypes = new JPanel(new BorderLayout(5, 5));
jpExtensionTypes.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jlExtensionTypes = new JLabel(res.getString("DAddExtensionType.jlExtensionTypes.text"));
jltExtensionTypes = new JList<X509ExtensionType>();
// Longest name to define constant width
jltExtensionTypes.setPrototypeCellValue(NETSCAPE_CERTIFICATE_RENEWAL_URL);
jltExtensionTypes.setToolTipText(res.getString("DAddExtensionType.jltExtensionTypes.tooltip"));
jltExtensionTypes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jltExtensionTypes.setBorder(new EtchedBorder());
jltExtensionTypes.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
maybeAddExtension(evt);
}
});
jspExtensionTypes = new JScrollPane(jltExtensionTypes);
jcbCriticalExtension = new JCheckBox(res.getString("DAddExtensionType.jcbCriticalExtension.text"));
jcbCriticalExtension.setMnemonic(res.getString("DAddExtensionType.jcbCriticalExtension.mnemonic").charAt(0));
jcbCriticalExtension.setToolTipText(res.getString("DAddExtensionType.jcbCriticalExtension.tooltip"));
jpExtensionTypes.add(jlExtensionTypes, BorderLayout.NORTH);
jpExtensionTypes.add(jspExtensionTypes, BorderLayout.CENTER);
jpExtensionTypes.add(jcbCriticalExtension, BorderLayout.SOUTH);
jbOK = new JButton(res.getString("DAddExtensionType.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jbCancel = new JButton(res.getString("DAddExtensionType.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
populateExtensionTypes();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jpExtensionTypes, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
setResizable(false);
getRootPane().setDefaultButton(jbOK);
pack();
}
use of org.kse.crypto.x509.X509ExtensionType in project keystore-explorer by kaikramer.
the class DAddExtensionType method populateExtensionTypes.
private void populateExtensionTypes() {
// Population is the supported set minus those already added
ArrayList<X509ExtensionType> availableExtensions = new ArrayList<X509ExtensionType>();
for (X509ExtensionType extentionType : SUPPORTED_EXTENSIONS) {
if (extensions.getExtensionValue(extentionType.oid()) == null) {
availableExtensions.add(extentionType);
}
}
jltExtensionTypes.setListData(availableExtensions.toArray(new X509ExtensionType[availableExtensions.size()]));
if (availableExtensions.size() > 0) {
jltExtensionTypes.setSelectedIndex(0);
}
}
use of org.kse.crypto.x509.X509ExtensionType in project keystore-explorer by kaikramer.
the class DAddExtensions method editSelectedExtension.
private void editSelectedExtension() {
try {
int selectedRow = jtExtensions.getSelectedRow();
if (selectedRow != -1) {
String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId();
X509ExtensionType extensionType = X509ExtensionType.resolveOid(oid);
byte[] extensionValue = extensions.getExtensionValue(oid);
boolean isCritical = extensions.getCriticalExtensionOIDs().contains(oid);
byte[] newExtensionValue = null;
DExtension dExtension = null;
switch(extensionType) {
case AUTHORITY_INFORMATION_ACCESS:
{
dExtension = new DAuthorityInformationAccess(this, extensionValue);
break;
}
case AUTHORITY_KEY_IDENTIFIER:
{
dExtension = new DAuthorityKeyIdentifier(this, extensionValue, authorityPublicKey);
break;
}
case BASIC_CONSTRAINTS:
{
dExtension = new DBasicConstraints(this, extensionValue);
break;
}
case CERTIFICATE_POLICIES:
{
dExtension = new DCertificatePolicies(this, extensionValue);
break;
}
case EXTENDED_KEY_USAGE:
{
dExtension = new DExtendedKeyUsage(this, extensionValue);
break;
}
case INHIBIT_ANY_POLICY:
{
dExtension = new DInhibitAnyPolicy(this, extensionValue);
break;
}
case ISSUER_ALTERNATIVE_NAME:
{
dExtension = new DIssuerAlternativeName(this, extensionValue);
break;
}
case KEY_USAGE:
{
dExtension = new DKeyUsage(this, extensionValue);
break;
}
case NAME_CONSTRAINTS:
{
dExtension = new DNameConstraints(this, extensionValue);
break;
}
case NETSCAPE_BASE_URL:
{
dExtension = new DNetscapeBaseUrl(this, extensionValue);
break;
}
case NETSCAPE_CERTIFICATE_RENEWAL_URL:
{
dExtension = new DNetscapeCertificateRenewalUrl(this, extensionValue);
break;
}
case NETSCAPE_CA_POLICY_URL:
{
dExtension = new DNetscapeCaPolicyUrl(this, extensionValue);
break;
}
case NETSCAPE_CA_REVOCATION_URL:
{
dExtension = new DNetscapeCaRevocationUrl(this, extensionValue);
break;
}
case NETSCAPE_CERTIFICATE_TYPE:
{
dExtension = new DNetscapeCertificateType(this, extensionValue);
break;
}
case NETSCAPE_COMMENT:
{
dExtension = new DNetscapeComment(this, extensionValue);
break;
}
case NETSCAPE_REVOCATION_URL:
{
dExtension = new DNetscapeRevocationUrl(this, extensionValue);
break;
}
case NETSCAPE_SSL_SERVER_NAME:
{
dExtension = new DNetscapeSslServerName(this, extensionValue);
break;
}
case POLICY_CONSTRAINTS:
{
dExtension = new DPolicyConstraints(this, extensionValue);
break;
}
case POLICY_MAPPINGS:
{
dExtension = new DPolicyMappings(this, extensionValue);
break;
}
case PRIVATE_KEY_USAGE_PERIOD:
{
dExtension = new DPrivateKeyUsagePeriod(this, extensionValue);
break;
}
case SUBJECT_ALTERNATIVE_NAME:
{
dExtension = new DSubjectAlternativeName(this, extensionValue);
break;
}
case SUBJECT_INFORMATION_ACCESS:
{
dExtension = new DSubjectInformationAccess(this, extensionValue);
break;
}
case SUBJECT_KEY_IDENTIFIER:
{
dExtension = new DSubjectKeyIdentifier(this, extensionValue, subjectPublicKey);
break;
}
default:
{
return;
}
}
dExtension.setLocationRelativeTo(this);
dExtension.setVisible(true);
newExtensionValue = dExtension.getValue();
if (newExtensionValue == null) {
return;
}
extensions.addExtension(oid, isCritical, newExtensionValue);
reloadExtensionsTable();
selectExtensionInTable(oid);
updateButtonControls();
}
} catch (IOException ex) {
DError dError = new DError(this, ex);
dError.setLocationRelativeTo(this);
dError.setVisible(true);
}
}
Aggregations