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