Search in sources :

Example 1 with X509Ext

use of org.kse.crypto.x509.X509Ext in project keystore-explorer by kaikramer.

the class ExtensionsTableModel method load.

/**
 * Load the ExtensionsTableModel with X.509 extensions.
 *
 * @param extensions
 *            The X.509 extensions
 */
public void load(X509Extension extensions) {
    Set<String> critExts = extensions.getCriticalExtensionOIDs();
    Set<String> nonCritExts = extensions.getNonCriticalExtensionOIDs();
    // Rows will be sorted by extension name
    List<X509Ext> sortedExts = new ArrayList<X509Ext>();
    for (Iterator<String> itr = critExts.iterator(); itr.hasNext(); ) {
        String extOid = itr.next();
        byte[] value = extensions.getExtensionValue(extOid);
        X509Ext ext = new X509Ext(new ASN1ObjectIdentifier(extOid), value, true);
        sortedExts.add(ext);
    }
    for (Iterator<String> itr = nonCritExts.iterator(); itr.hasNext(); ) {
        String extOid = itr.next();
        byte[] value = extensions.getExtensionValue(extOid);
        X509Ext ext = new X509Ext(new ASN1ObjectIdentifier(extOid), value, false);
        sortedExts.add(ext);
    }
    Collections.sort(sortedExts, new ExtensionNameComparator());
    data = new Object[sortedExts.size()][3];
    int i = 0;
    for (Iterator<X509Ext> itrSortedExts = sortedExts.iterator(); itrSortedExts.hasNext(); ) {
        X509Ext ext = itrSortedExts.next();
        loadRow(ext, i);
        i++;
    }
    fireTableDataChanged();
}
Also used : ArrayList(java.util.ArrayList) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) X509Ext(org.kse.crypto.x509.X509Ext)

Example 2 with X509Ext

use of org.kse.crypto.x509.X509Ext in project keystore-explorer by kaikramer.

the class DViewExtensions method updateExtensionValue.

private void updateExtensionValue() {
    int selectedRow = jtExtensions.getSelectedRow();
    if (selectedRow == -1) {
        jepExtensionValue.setText("");
        jbAsn1.setEnabled(false);
    } else {
        String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId();
        byte[] value = extensions.getExtensionValue(oid);
        boolean criticality = (Boolean) jtExtensions.getValueAt(selectedRow, 0);
        X509Ext ext = new X509Ext(oid, value, criticality);
        try {
            jepExtensionValue.setText("<html><body>" + ext.getStringValue().replace(X509Ext.INDENT.getIndentChar().toString(), "&nbsp;").replace(X509Ext.NEWLINE, "<br/>") + "</body></html>");
        } catch (Exception ex) {
            jepExtensionValue.setText("");
            DError dError = new DError(this, ex);
            dError.setLocationRelativeTo(this);
            dError.setVisible(true);
        }
        jepExtensionValue.setCaretPosition(0);
        jbAsn1.setEnabled(true);
    }
}
Also used : ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) CryptoException(org.kse.crypto.CryptoException) Asn1Exception(org.kse.utilities.asn1.Asn1Exception) IOException(java.io.IOException) X509Ext(org.kse.crypto.x509.X509Ext) DError(org.kse.gui.error.DError)

Example 3 with X509Ext

use of org.kse.crypto.x509.X509Ext 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);
    }
}
Also used : DViewAsn1Dump(org.kse.gui.dialogs.DViewAsn1Dump) IOException(java.io.IOException) Asn1Exception(org.kse.utilities.asn1.Asn1Exception) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) X509Ext(org.kse.crypto.x509.X509Ext) DError(org.kse.gui.error.DError)

Aggregations

ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)3 X509Ext (org.kse.crypto.x509.X509Ext)3 IOException (java.io.IOException)2 DError (org.kse.gui.error.DError)2 Asn1Exception (org.kse.utilities.asn1.Asn1Exception)2 ArrayList (java.util.ArrayList)1 CryptoException (org.kse.crypto.CryptoException)1 DViewAsn1Dump (org.kse.gui.dialogs.DViewAsn1Dump)1