use of com.github.zhenwei.core.asn1.x509.AccessDescription in project keystore-explorer by kaikramer.
the class DAuthorityInformationAccess method prepopulateWithValue.
private void prepopulateWithValue(byte[] value) throws IOException {
AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess.getInstance(value);
List<AccessDescription> accessDescriptionList = new ArrayList<>(Arrays.asList(authorityInformationAccess.getAccessDescriptions()));
jadAccessDescriptions.setAccessDescriptions(accessDescriptionList);
}
use of com.github.zhenwei.core.asn1.x509.AccessDescription in project keystore-explorer by kaikramer.
the class AccessDescriptionsTableCellRend method getTableCellRendererComponent.
/**
* Returns the rendered cell.
*
* @param jtAccessDescriptions 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 jtAccessDescriptions, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
JLabel cell = (JLabel) super.getTableCellRendererComponent(jtAccessDescriptions, value, isSelected, hasFocus, row, col);
AccessDescription accessDescription = (AccessDescription) value;
if (col == 0) {
cell.setText(accessDescription.getAccessMethod().getId());
} else {
cell.setText(GeneralNameUtil.safeToString(accessDescription.getAccessLocation(), false));
}
cell.setHorizontalAlignment(LEFT);
cell.setBorder(new EmptyBorder(0, 5, 0, 5));
return cell;
}
use of com.github.zhenwei.core.asn1.x509.AccessDescription in project keystore-explorer by kaikramer.
the class JAccessDescriptions method editSelectedAccessDescription.
private void editSelectedAccessDescription() {
int selectedRow = jtAccessDescriptions.getSelectedRow();
if (selectedRow != -1) {
AccessDescription accessDescription = (AccessDescription) jtAccessDescriptions.getValueAt(selectedRow, 0);
Container container = getTopLevelAncestor();
DAccessDescriptionChooser dAccessDescriptionChooser = null;
if (container instanceof JDialog) {
dAccessDescriptionChooser = new DAccessDescriptionChooser((JDialog) container, title, accessDescription);
} else {
dAccessDescriptionChooser = new DAccessDescriptionChooser((JFrame) container, title, accessDescription);
}
dAccessDescriptionChooser.setLocationRelativeTo(container);
dAccessDescriptionChooser.setVisible(true);
AccessDescription newAccessDescription = dAccessDescriptionChooser.getAccessDescription();
if (newAccessDescription == null) {
return;
}
accessDescriptions.remove(accessDescription);
accessDescriptions.add(newAccessDescription);
populate();
selectAccessDescriptionInTable(newAccessDescription);
}
}
use of com.github.zhenwei.core.asn1.x509.AccessDescription in project keystore-explorer by kaikramer.
the class X509Ext method getSubjectInformationAccessStringValue.
private static String getSubjectInformationAccessStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* SubjectInfoAccessSyntax ::= ASN1Sequence SIZE (1..MAX) OF
* AccessDescription
*
* AccessDescription ::= ASN1Sequence { accessMethod OBJECT IDENTIFIER,
* accessLocation GeneralName }
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
SubjectInfoAccess subjectInfoAccess = SubjectInfoAccess.getInstance(value);
int accessDesc = 0;
for (AccessDescription accessDescription : subjectInfoAccess.getAccessDescriptionList()) {
accessDesc++;
// Convert OID to access method
ASN1ObjectIdentifier accessMethod = accessDescription.getAccessMethod();
AccessMethodType accessMethodType = AccessMethodType.resolveOid(accessMethod.getId());
String accessMethodStr = null;
if (accessMethodType != null) {
accessMethodStr = accessMethodType.friendly();
} else {
// Unrecognised Access Method OID
accessMethodStr = ObjectIdUtil.toString(accessMethod);
}
GeneralName accessLocation = accessDescription.getAccessLocation();
String accessLocationStr = GeneralNameUtil.toString(accessLocation);
sb.append(MessageFormat.format(res.getString("SubjectInformationAccess"), accessDesc));
sb.append(NEWLINE);
sb.append(INDENT);
sb.append(MessageFormat.format(res.getString("AccessMethod"), accessMethodStr));
sb.append(NEWLINE);
sb.append(INDENT);
sb.append(res.getString("AccessLocation"));
sb.append(NEWLINE);
sb.append(INDENT);
sb.append(INDENT);
sb.append(accessLocationStr);
sb.append(NEWLINE);
}
return sb.toString();
}
use of com.github.zhenwei.core.asn1.x509.AccessDescription in project keystore-explorer by kaikramer.
the class SubjectInfoAccess method toASN1Primitive.
@Override
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector vec = new ASN1EncodableVector();
Iterator<AccessDescription> it = accessDescriptions.iterator();
while (it.hasNext()) {
vec.add(it.next().toASN1Primitive());
}
return new DERSequence(vec);
}
Aggregations