Search in sources :

Example 26 with PolicyInformation

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

the class PolicyInformationUtil method toString.

// @formatter:off
/*
	 * PolicyInformation ::= ASN1Sequence { policyIdentifier CertPolicyId,
	 * policyQualifiers ASN1Sequence SIZE (1..MAX) OF PolicyQualifierInfo
	 * OPTIONAL }
	 *
	 * CertPolicyId ::= OBJECT IDENTIFIER
	 *
	 * PolicyQualifierInfo ::= ASN1Sequence { policyQualifierId
	 * PolicyQualifierId, qualifier ANY DEFINED BY policyQualifierId }
	 *
	 * -- policyQualifierIds for Internet policy qualifiers
	 *
	 * id-qt OBJECT IDENTIFIER ::= { id-pkix 2 } id-qt-cps OBJECT IDENTIFIER ::=
	 * { id-qt 1 } id-qt-unotice OBJECT IDENTIFIER ::= { id-qt 2 }
	 *
	 * PolicyQualifierId ::= OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice )
	 *
	 * Qualifier ::= CHOICE { cPSuri CPSuri, userNotice UserNotice }
	 *
	 * CPSuri ::= DERIA5String
	 *
	 * UserNotice ::= ASN1Sequence { noticeRef NoticeReference OPTIONAL,
	 * explicitText DisplayText OPTIONAL}
	 *
	 * NoticeReference ::= ASN1Sequence { organization DisplayText,
	 * noticeNumbers ASN1Sequence OF ASN1Integer }
	 *
	 * DisplayText ::= CHOICE { ia5String DERIA5String (SIZE (1..200)),
	 * visibleString VisibleString (SIZE (1..200)), bmpString BMPString (SIZE
	 * (1..200)), utf8String UTF8String (SIZE (1..200)) }
	 */
// @formatter:on
/**
 * Get string representation of policy information.
 *
 * @param policyInformation
 *            Policy information
 * @return String representation of policy information
 * @throws IOException
 *             If policy information is invalid
 */
public static String toString(PolicyInformation policyInformation) throws IOException {
    StringBuffer sbPolicyInformation = new StringBuffer();
    ASN1ObjectIdentifier policyIdentifier = policyInformation.getPolicyIdentifier();
    sbPolicyInformation.append(MessageFormat.format(res.getString("PolicyInformationUtil.PolicyIdentifier"), policyIdentifier.getId()));
    ASN1Sequence policyQualifiers = policyInformation.getPolicyQualifiers();
    if (policyQualifiers != null) {
        sbPolicyInformation.append(", ");
        StringBuffer sbPolicyQualifiers = new StringBuffer();
        for (int i = 0; i < policyQualifiers.size(); i++) {
            PolicyQualifierInfo policyQualifierInfo = PolicyQualifierInfo.getInstance(policyQualifiers.getObjectAt(i));
            sbPolicyQualifiers.append(toString(policyQualifierInfo));
            if ((i + 1) < policyQualifiers.size()) {
                sbPolicyQualifiers.append(", ");
            }
        }
        sbPolicyInformation.append(MessageFormat.format(res.getString("PolicyInformationUtil.PolicyQualifiers"), sbPolicyQualifiers));
    }
    return sbPolicyInformation.toString();
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 27 with PolicyInformation

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

the class DPolicyInformationChooser method populate.

private void populate(PolicyInformation policyInformation) throws IOException {
    if (policyInformation != null) {
        joiPolicyIdentifier.setObjectId(policyInformation.getPolicyIdentifier());
        ASN1Sequence policyQualifierInfoSeq = policyInformation.getPolicyQualifiers();
        if (policyQualifierInfoSeq != null) {
            List<PolicyQualifierInfo> policyQualifierInfo = new ArrayList<PolicyQualifierInfo>();
            for (int i = 0; i < policyQualifierInfoSeq.size(); i++) {
                PolicyQualifierInfo policyQualInfo = PolicyQualifierInfo.getInstance(policyQualifierInfoSeq.getObjectAt(i));
                policyQualifierInfo.add(policyQualInfo);
            }
            jpqPolicyQualifiers.setPolicyQualifierInfo(policyQualifierInfo);
        }
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) ArrayList(java.util.ArrayList) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo)

Example 28 with PolicyInformation

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

the class JPolicyInformation method addPressed.

private void addPressed() {
    Container container = getTopLevelAncestor();
    try {
        DPolicyInformationChooser dPolicyInformationChooser = null;
        if (container instanceof JDialog) {
            dPolicyInformationChooser = new DPolicyInformationChooser((JDialog) container, title, null);
            dPolicyInformationChooser.setLocationRelativeTo(container);
            dPolicyInformationChooser.setVisible(true);
        } else if (container instanceof JFrame) {
            dPolicyInformationChooser = new DPolicyInformationChooser((JFrame) container, title, null);
            dPolicyInformationChooser.setLocationRelativeTo(container);
            dPolicyInformationChooser.setVisible(true);
        }
        PolicyInformation newPolicyInfo = dPolicyInformationChooser.getPolicyInformation();
        if (newPolicyInfo == null) {
            return;
        }
        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) JFrame(javax.swing.JFrame) PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) IOException(java.io.IOException) JDialog(javax.swing.JDialog) DError(org.kse.gui.error.DError)

Example 29 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 30 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)

Aggregations

PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)20 IOException (java.io.IOException)16 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)13 ArrayList (java.util.ArrayList)12 CertPathValidatorException (java.security.cert.CertPathValidatorException)10 HashSet (java.util.HashSet)7 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)7 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)7 Enumeration (java.util.Enumeration)6 Iterator (java.util.Iterator)6 List (java.util.List)6 Set (java.util.Set)6 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)6 ExtCertPathValidatorException (org.bouncycastle.jce.exception.ExtCertPathValidatorException)6 X509Certificate (java.security.cert.X509Certificate)5 PolicyInformation (sun.security.x509.PolicyInformation)5 GeneralSecurityException (java.security.GeneralSecurityException)4 IssuingDistributionPoint (org.bouncycastle.asn1.x509.IssuingDistributionPoint)4 PolicyQualifierInfo (org.bouncycastle.asn1.x509.PolicyQualifierInfo)4 DError (org.kse.gui.error.DError)4