Search in sources :

Example 6 with PolicyQualifierInfo

use of org.bouncycastle.asn1.x509.PolicyQualifierInfo in project keystore-explorer by kaikramer.

the class DPolicyInformationChooser method okPressed.

private void okPressed() {
    ASN1ObjectIdentifier policyIdentifer = joiPolicyIdentifier.getObjectId();
    if (policyIdentifer == null) {
        JOptionPane.showMessageDialog(this, res.getString("DPolicyInformationChooser.PolicyIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    List<PolicyQualifierInfo> policyQualifierInfo = jpqPolicyQualifiers.getPolicyQualifierInfo();
    if (policyQualifierInfo.size() > 0) {
        ASN1EncodableVector policyQualifiersVec = new ASN1EncodableVector();
        for (PolicyQualifierInfo policyQualInfo : policyQualifierInfo) {
            try {
                policyQualifiersVec.add(policyQualInfo);
            } catch (Exception ex) {
                DError dError = new DError(this, ex);
                dError.setLocationRelativeTo(this);
                dError.setVisible(true);
                return;
            }
        }
        DERSequence policyQualifiersSeq = new DERSequence(policyQualifiersVec);
        policyInformation = new PolicyInformation(policyIdentifer, policyQualifiersSeq);
    } else {
        policyInformation = new PolicyInformation(policyIdentifer);
    }
    closeDialog();
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 7 with PolicyQualifierInfo

use of org.bouncycastle.asn1.x509.PolicyQualifierInfo in project keystore-explorer by kaikramer.

the class DPolicyQualifierInfoChooser method populate.

private void populate(PolicyQualifierInfo policyQualifierInfo) throws IOException {
    if (policyQualifierInfo == null) {
        jrbCps.setSelected(true);
    } else {
        ASN1ObjectIdentifier policyQualifierId = policyQualifierInfo.getPolicyQualifierId();
        if (policyQualifierId.equals(new ASN1ObjectIdentifier(PKIX_CPS_POINTER_QUALIFIER.oid()))) {
            jrbCps.setSelected(true);
            jtfCps.setText(((DERIA5String) policyQualifierInfo.getQualifier()).getString());
            jtfCps.setCaretPosition(0);
        } else if (policyQualifierId.equals(new ASN1ObjectIdentifier(PKIX_USER_NOTICE_QUALIFIER.oid()))) {
            jrbUserNotice.setSelected(true);
            ASN1Encodable userNoticeObj = policyQualifierInfo.getQualifier();
            UserNotice userNotice = UserNotice.getInstance(userNoticeObj);
            junUserNotice.setUserNotice(userNotice);
        } else {
            jrbCps.setSelected(true);
        }
    }
}
Also used : UserNotice(org.bouncycastle.asn1.x509.UserNotice) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 8 with PolicyQualifierInfo

use of org.bouncycastle.asn1.x509.PolicyQualifierInfo in project keystore-explorer by kaikramer.

the class JPolicyQualifierInfo method removeSelectedPolicyQualifierInfo.

private void removeSelectedPolicyQualifierInfo() {
    int selectedRow = jtPolicyQualifierInfo.getSelectedRow();
    if (selectedRow != -1) {
        PolicyQualifierInfo policyQualInfo = (PolicyQualifierInfo) jtPolicyQualifierInfo.getValueAt(selectedRow, 0);
        policyQualifierInfo.remove(policyQualInfo);
        reloadPolicyQualifierInfoTable();
        selectFirstPolicyQualifierInfoInTable();
        updateButtonControls();
    }
}
Also used : PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) Point(java.awt.Point)

Example 9 with PolicyQualifierInfo

use of org.bouncycastle.asn1.x509.PolicyQualifierInfo in project keystore-explorer by kaikramer.

the class JPolicyQualifierInfo method editSelectedPolicQualifier.

private void editSelectedPolicQualifier() {
    int selectedRow = jtPolicyQualifierInfo.getSelectedRow();
    if (selectedRow != -1) {
        PolicyQualifierInfo policyQualInfo = (PolicyQualifierInfo) jtPolicyQualifierInfo.getValueAt(selectedRow, 0);
        Container container = getTopLevelAncestor();
        try {
            DPolicyQualifierInfoChooser dPolicyQualifierInfoChooser = null;
            if (container instanceof JDialog) {
                dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JDialog) container, title, policyQualInfo);
                dPolicyQualifierInfoChooser.setLocationRelativeTo(container);
                dPolicyQualifierInfoChooser.setVisible(true);
            } else if (container instanceof JFrame) {
                dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JFrame) container, title, policyQualInfo);
                dPolicyQualifierInfoChooser.setLocationRelativeTo(container);
                dPolicyQualifierInfoChooser.setVisible(true);
            }
            PolicyQualifierInfo newPolicyQualifierInfo = dPolicyQualifierInfoChooser.getPolicyQualifierInfo();
            if (newPolicyQualifierInfo == null) {
                return;
            }
            policyQualifierInfo.remove(policyQualInfo);
            policyQualifierInfo.add(newPolicyQualifierInfo);
            populate();
            selectPolicyQualifierInfoInTable(newPolicyQualifierInfo);
        } catch (IOException ex) {
            DError dError = null;
            if (container instanceof JDialog) {
                dError = new DError((JDialog) container, ex);
            } else {
                dError = new DError((JFrame) container, ex);
            }
            dError.setLocationRelativeTo(container);
            dError.setVisible(true);
        }
    }
}
Also used : Container(java.awt.Container) JFrame(javax.swing.JFrame) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) IOException(java.io.IOException) Point(java.awt.Point) JDialog(javax.swing.JDialog) DError(org.kse.gui.error.DError)

Example 10 with PolicyQualifierInfo

use of org.bouncycastle.asn1.x509.PolicyQualifierInfo in project keystore-explorer by kaikramer.

the class PolicyQualifierInfoTableCellRend method getTableCellRendererComponent.

/**
 * Returns the rendered cell.
 *
 * @param jtPolicyQualifierInfo
 *            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 jtPolicyQualifierInfo, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    JLabel cell = (JLabel) super.getTableCellRendererComponent(jtPolicyQualifierInfo, value, isSelected, hasFocus, row, col);
    PolicyQualifierInfo policyQualifierInfo = (PolicyQualifierInfo) value;
    try {
        String policyQualifierInfoStr = PolicyInformationUtil.toString(policyQualifierInfo);
        cell.setText(policyQualifierInfoStr);
        cell.setToolTipText(policyQualifierInfoStr);
    } catch (IOException ex) {
        // We build this data so should not
        throw new RuntimeException(ex);
    // happen
    }
    cell.setHorizontalAlignment(LEFT);
    cell.setBorder(new EmptyBorder(0, 5, 0, 5));
    return cell;
}
Also used : JLabel(javax.swing.JLabel) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) IOException(java.io.IOException) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

PolicyQualifierInfo (org.bouncycastle.asn1.x509.PolicyQualifierInfo)12 IOException (java.io.IOException)7 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)7 UserNotice (org.bouncycastle.asn1.x509.UserNotice)6 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)5 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)4 DERIA5String (org.bouncycastle.asn1.DERIA5String)4 DERSequence (org.bouncycastle.asn1.DERSequence)4 PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)4 DError (org.kse.gui.error.DError)4 ArrayList (java.util.ArrayList)3 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)3 Container (java.awt.Container)2 Point (java.awt.Point)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PolicyQualifierInfo (java.security.cert.PolicyQualifierInfo)2 Enumeration (java.util.Enumeration)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 JDialog (javax.swing.JDialog)2