Search in sources :

Example 6 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project Spark by igniterealtime.

the class CertificateModel method NameConstraintsExtractor.

private String NameConstraintsExtractor(ASN1Primitive primitive) {
    NameConstraints nc = NameConstraints.getInstance(primitive);
    StringBuilder value = new StringBuilder();
    if (nc.getPermittedSubtrees() != null) {
        value.append(Res.getString("cert.extension.name.constraints.permitted.subtrees")).append(": \n");
        for (GeneralSubtree subtree : nc.getPermittedSubtrees()) {
            value.append(subtree.toString()).append("\n");
        }
    }
    if (nc.getExcludedSubtrees() != null) {
        value.append(Res.getString("cert.extension.name.constraints.excluded.subtrees")).append(": \n");
        for (GeneralSubtree subtree : nc.getExcludedSubtrees()) {
            value.append(subtree.toString()).append("\n");
        }
    }
    return value.toString();
}
Also used : NameConstraints(org.bouncycastle.asn1.x509.NameConstraints) GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree)

Example 7 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project keystore-explorer by kaikramer.

the class DGeneralSubtreeChooser method okPressed.

private void okPressed() {
    GeneralName base = jgnBase.getGeneralName();
    if (base == null) {
        JOptionPane.showMessageDialog(this, res.getString("DGeneralSubtreeChooser.BaseValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    int minimum = -1;
    String minimumStr = jtfMinimum.getText().trim();
    if (minimumStr.length() == 0) {
        JOptionPane.showMessageDialog(this, res.getString("DGeneralSubtreeChooser.MinimumValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (minimumStr.length() > 0) {
        try {
            minimum = Integer.parseInt(minimumStr);
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, res.getString("DGeneralSubtreeChooser.InvalidMinimumValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (minimum < 0) {
            JOptionPane.showMessageDialog(this, res.getString("DGeneralSubtreeChooser.InvalidMinimumValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return;
        }
    }
    int maximum = -1;
    String maximumStr = jtfMaximum.getText().trim();
    if (maximumStr.length() > 0) {
        try {
            maximum = Integer.parseInt(maximumStr);
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, res.getString("DGeneralSubtreeChooser.InvalidMaximumValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (maximum < 0) {
            JOptionPane.showMessageDialog(this, res.getString("DGeneralSubtreeChooser.InvalidMaximumValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return;
        }
    }
    BigInteger asn1Minimum = (minimum != -1) ? BigInteger.valueOf(minimum) : null;
    BigInteger asn1Maximum = (maximum != -1) ? BigInteger.valueOf(maximum) : null;
    generalSubtree = new GeneralSubtree(base, asn1Minimum, asn1Maximum);
    closeDialog();
}
Also used : BigInteger(java.math.BigInteger) JGeneralName(org.kse.gui.crypto.generalname.JGeneralName) GeneralName(org.bouncycastle.asn1.x509.GeneralName) GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree)

Example 8 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project keystore-explorer by kaikramer.

the class GeneralSubtreesTableCellRend method getTableCellRendererComponent.

/**
 * Returns the rendered cell.
 *
 * @param jtGeneralSubtrees The JTable
 * @param value             The value to assign to the cell
 * @param isSelected        True if cell is selected
 * @param row               The row of the cell to render
 * @param col               The column of the cell to render
 * @param hasFocus          If true, render cell appropriately
 * @return The renderered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jtGeneralSubtrees, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    JLabel cell = (JLabel) super.getTableCellRendererComponent(jtGeneralSubtrees, value, isSelected, hasFocus, row, col);
    GeneralSubtree generalSubtree = (GeneralSubtree) value;
    if (col == 0) {
        cell.setText(GeneralNameUtil.safeToString(generalSubtree.getBase(), false));
    } else if (col == 1) {
        if (generalSubtree.getMinimum() != null) {
            String minimumStr = "" + generalSubtree.getMinimum().intValue();
            cell.setText(minimumStr);
            cell.setToolTipText(minimumStr);
        } else {
            cell.setText("-");
        }
    } else {
        if (generalSubtree.getMaximum() != null) {
            String maximumStr = "" + generalSubtree.getMaximum().intValue();
            cell.setText(maximumStr);
            cell.setToolTipText(maximumStr);
        } else {
            cell.setText("-");
        }
    }
    cell.setBorder(new EmptyBorder(0, 5, 0, 5));
    return cell;
}
Also used : JLabel(javax.swing.JLabel) GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree) EmptyBorder(javax.swing.border.EmptyBorder)

Example 9 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project keystore-explorer by kaikramer.

the class GeneralSubtreesTableModel method load.

/**
 * Load the GeneralSubtreesTableModel with general subtrees.
 *
 * @param generalSubtrees The general subtrees
 */
public void load(GeneralSubtrees generalSubtrees) {
    List<GeneralSubtree> generalSubtreesList = generalSubtrees.getGeneralSubtrees();
    Collections.sort(generalSubtreesList, new GeneralSubtreeBaseComparator());
    data = new Object[generalSubtreesList.size()][3];
    int i = 0;
    for (GeneralSubtree generalSubtree : generalSubtreesList) {
        data[i][0] = generalSubtree;
        data[i][1] = generalSubtree;
        data[i][2] = generalSubtree;
        i++;
    }
    fireTableDataChanged();
}
Also used : GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree)

Example 10 with GeneralSubtree

use of com.github.zhenwei.core.asn1.x509.GeneralSubtree in project keystore-explorer by kaikramer.

the class JGeneralSubtrees method addPressed.

private void addPressed() {
    Container container = getTopLevelAncestor();
    DGeneralSubtreeChooser dGeneralSubtreeChooser = null;
    if (container instanceof JDialog) {
        dGeneralSubtreeChooser = new DGeneralSubtreeChooser((JDialog) container, title, null);
    } else {
        dGeneralSubtreeChooser = new DGeneralSubtreeChooser((JFrame) container, title, null);
    }
    dGeneralSubtreeChooser.setLocationRelativeTo(container);
    dGeneralSubtreeChooser.setVisible(true);
    GeneralSubtree newGeneralSubtree = dGeneralSubtreeChooser.getGeneralSubtree();
    if (newGeneralSubtree == null) {
        return;
    }
    generalSubtrees.getGeneralSubtrees().add(newGeneralSubtree);
    populate();
    selectGeneralSubtreeInTable(newGeneralSubtree);
}
Also used : Container(java.awt.Container) JFrame(javax.swing.JFrame) GeneralSubtree(org.bouncycastle.asn1.x509.GeneralSubtree) JDialog(javax.swing.JDialog)

Aggregations

GeneralSubtree (org.bouncycastle.asn1.x509.GeneralSubtree)18 BigInteger (java.math.BigInteger)7 GeneralName (org.bouncycastle.asn1.x509.GeneralName)6 NameConstraints (org.bouncycastle.asn1.x509.NameConstraints)6 IOException (java.io.IOException)5 X509Certificate (java.security.cert.X509Certificate)5 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 X500Name (org.bouncycastle.asn1.x500.X500Name)4 GeneralSecurityException (java.security.GeneralSecurityException)3 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)3 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)3 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)3 ASN1IA5String (com.github.zhenwei.core.asn1.ASN1IA5String)2 ASN1OctetString (com.github.zhenwei.core.asn1.ASN1OctetString)2 ASN1Sequence (com.github.zhenwei.core.asn1.ASN1Sequence)2 CRLDistPoint (com.github.zhenwei.core.asn1.x509.CRLDistPoint)2 DistributionPoint (com.github.zhenwei.core.asn1.x509.DistributionPoint)2 GeneralSubtree (com.github.zhenwei.core.asn1.x509.GeneralSubtree)2