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();
}
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();
}
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;
}
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();
}
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);
}
Aggregations