Search in sources :

Example 11 with AccessDescription

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);
}
Also used : AuthorityInformationAccess(org.bouncycastle.asn1.x509.AuthorityInformationAccess) AccessDescription(org.bouncycastle.asn1.x509.AccessDescription) ArrayList(java.util.ArrayList)

Example 12 with AccessDescription

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;
}
Also used : AccessDescription(org.bouncycastle.asn1.x509.AccessDescription) JLabel(javax.swing.JLabel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 13 with AccessDescription

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);
    }
}
Also used : Container(java.awt.Container) AccessDescription(org.bouncycastle.asn1.x509.AccessDescription) JFrame(javax.swing.JFrame) Point(java.awt.Point) JDialog(javax.swing.JDialog)

Example 14 with AccessDescription

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();
}
Also used : AccessDescription(org.bouncycastle.asn1.x509.AccessDescription) DERBitString(org.bouncycastle.asn1.DERBitString) ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) DERGeneralString(org.bouncycastle.asn1.DERGeneralString) ASN1IA5String(org.bouncycastle.asn1.ASN1IA5String) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) ASN1BitString(org.bouncycastle.asn1.ASN1BitString) DEROctetString(org.bouncycastle.asn1.DEROctetString) ASN1BMPString(org.bouncycastle.asn1.ASN1BMPString) DERIA5String(org.bouncycastle.asn1.DERIA5String) ASN1PrintableString(org.bouncycastle.asn1.ASN1PrintableString) GeneralName(org.bouncycastle.asn1.x509.GeneralName) IssuingDistributionPoint(org.bouncycastle.asn1.x509.IssuingDistributionPoint) CRLDistPoint(org.bouncycastle.asn1.x509.CRLDistPoint) DistributionPoint(org.bouncycastle.asn1.x509.DistributionPoint) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 15 with AccessDescription

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);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) AccessDescription(org.bouncycastle.asn1.x509.AccessDescription) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Aggregations

AccessDescription (org.bouncycastle.asn1.x509.AccessDescription)30 AuthorityInformationAccess (org.bouncycastle.asn1.x509.AuthorityInformationAccess)16 GeneralName (org.bouncycastle.asn1.x509.GeneralName)15 IOException (java.io.IOException)8 DERIA5String (org.bouncycastle.asn1.DERIA5String)8 ArrayList (java.util.ArrayList)7 DEROctetString (org.bouncycastle.asn1.DEROctetString)6 AccessDescription (sun.security.x509.AccessDescription)6 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)5 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)5 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)5 X509Certificate (java.security.cert.X509Certificate)4 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)4 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)4 CertStore (java.security.cert.CertStore)3 CertStoreException (java.security.cert.CertStoreException)3 ASN1String (org.bouncycastle.asn1.ASN1String)3 DERSequence (org.bouncycastle.asn1.DERSequence)3 AccessDescription (com.github.zhenwei.core.asn1.x509.AccessDescription)2 GeneralName (com.github.zhenwei.core.asn1.x509.GeneralName)2