Search in sources :

Example 31 with PolicyInformation

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

the class JPolicyInformation method editSelectedPolicyInformation.

private void editSelectedPolicyInformation() {
    int selectedRow = jtPolicyInformation.getSelectedRow();
    if (selectedRow != -1) {
        PolicyInformation policyInfo = (PolicyInformation) jtPolicyInformation.getValueAt(selectedRow, 0);
        Container container = getTopLevelAncestor();
        try {
            DPolicyInformationChooser dPolicyNameChooser = null;
            if (container instanceof JDialog) {
                dPolicyNameChooser = new DPolicyInformationChooser((JDialog) container, title, policyInfo);
                dPolicyNameChooser.setLocationRelativeTo(container);
                dPolicyNameChooser.setVisible(true);
            } else if (container instanceof JFrame) {
                dPolicyNameChooser = new DPolicyInformationChooser((JFrame) container, title, policyInfo);
                dPolicyNameChooser.setLocationRelativeTo(container);
                dPolicyNameChooser.setVisible(true);
            }
            PolicyInformation newPolicyInfo = dPolicyNameChooser.getPolicyInformation();
            if (newPolicyInfo == null) {
                return;
            }
            policyInformation.remove(policyInfo);
            policyInformation.add(newPolicyInfo);
            populate();
            selectPolicyInformationInTable(newPolicyInfo);
        } 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) PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) JFrame(javax.swing.JFrame) IOException(java.io.IOException) Point(java.awt.Point) JDialog(javax.swing.JDialog) DError(org.kse.gui.error.DError)

Example 32 with PolicyInformation

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

the class PolicyInformationTableCellRend method getTableCellRendererComponent.

/**
 * Returns the rendered cell.
 *
 * @param jtPolicyInformation
 *            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 jtPolicyInformation, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    JLabel cell = (JLabel) super.getTableCellRendererComponent(jtPolicyInformation, value, isSelected, hasFocus, row, col);
    PolicyInformation policyInformation = (PolicyInformation) value;
    try {
        String policyInformationStr = PolicyInformationUtil.toString(policyInformation);
        cell.setText(policyInformationStr);
        cell.setToolTipText(policyInformationStr);
    } 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 : PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) JLabel(javax.swing.JLabel) IOException(java.io.IOException) EmptyBorder(javax.swing.border.EmptyBorder)

Example 33 with PolicyInformation

use of org.openecard.bouncycastle.asn1.x509.PolicyInformation in project j2objc by google.

the class PolicyChecker method removeInvalidNodes.

/**
 * Removes those nodes which do not intersect with the initial policies
 * specified by the user.
 *
 * @param rootNode the root node of the valid policy tree
 * @param certIndex the index of the certificate being processed
 * @param initPolicies the Set of policies required by the user
 * @param currCertPolicies the CertificatePoliciesExtension of the
 * certificate being processed
 * @returns the root node of the valid policy tree after modification
 * @exception CertPathValidatorException Exception thrown if error occurs.
 */
private static PolicyNodeImpl removeInvalidNodes(PolicyNodeImpl rootNode, int certIndex, Set<String> initPolicies, CertificatePoliciesExtension currCertPolicies) throws CertPathValidatorException {
    List<PolicyInformation> policyInfo = null;
    try {
        policyInfo = currCertPolicies.get(CertificatePoliciesExtension.POLICIES);
    } catch (IOException ioe) {
        throw new CertPathValidatorException("Exception while " + "retrieving policyOIDs", ioe);
    }
    boolean childDeleted = false;
    for (PolicyInformation curPolInfo : policyInfo) {
        String curPolicy = curPolInfo.getPolicyIdentifier().getIdentifier().toString();
        if (debug != null)
            debug.println("PolicyChecker.processPolicies() " + "processing policy second time: " + curPolicy);
        Set<PolicyNodeImpl> validNodes = rootNode.getPolicyNodesValid(certIndex, curPolicy);
        for (PolicyNodeImpl curNode : validNodes) {
            PolicyNodeImpl parentNode = (PolicyNodeImpl) curNode.getParent();
            if (parentNode.getValidPolicy().equals(ANY_POLICY)) {
                if ((!initPolicies.contains(curPolicy)) && (!curPolicy.equals(ANY_POLICY))) {
                    if (debug != null)
                        debug.println("PolicyChecker.processPolicies() " + "before deleting: policy tree = " + rootNode);
                    parentNode.deleteChild(curNode);
                    childDeleted = true;
                    if (debug != null)
                        debug.println("PolicyChecker.processPolicies() " + "after deleting: policy tree = " + rootNode);
                }
            }
        }
    }
    if (childDeleted) {
        rootNode.prune(certIndex);
        if (!rootNode.getChildren().hasNext()) {
            rootNode = null;
        }
    }
    return rootNode;
}
Also used : CertPathValidatorException(java.security.cert.CertPathValidatorException) PolicyInformation(sun.security.x509.PolicyInformation) IOException(java.io.IOException)

Aggregations

PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)21 IOException (java.io.IOException)19 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)13 CertPathValidatorException (java.security.cert.CertPathValidatorException)12 ArrayList (java.util.ArrayList)12 HashSet (java.util.HashSet)7 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)7 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)7 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)7 PolicyInformation (sun.security.x509.PolicyInformation)7 X509Certificate (java.security.cert.X509Certificate)6 Enumeration (java.util.Enumeration)6 Iterator (java.util.Iterator)6 List (java.util.List)6 Set (java.util.Set)6 ExtCertPathValidatorException (org.bouncycastle.jce.exception.ExtCertPathValidatorException)6 GeneralSecurityException (java.security.GeneralSecurityException)4 CertificatePolicies (org.bouncycastle.asn1.x509.CertificatePolicies)4 IssuingDistributionPoint (org.bouncycastle.asn1.x509.IssuingDistributionPoint)4 PolicyQualifierInfo (org.bouncycastle.asn1.x509.PolicyQualifierInfo)4