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); } } }
/** * Get string representation of policy qualifier info. * * @param policyQualifierInfo * Policy qualifier info * @return String representation of policy qualifier info * @throws IOException * If policy qualifier info is invalid */ public static String toString(PolicyQualifierInfo policyQualifierInfo) throws IOException { StringBuffer sbPolicyQualifier = new StringBuffer(); ASN1ObjectIdentifier policyQualifierId = policyQualifierInfo.getPolicyQualifierId(); CertificatePolicyQualifierType certificatePolicyQualifierType = CertificatePolicyQualifierType .resolveOid(policyQualifierId.getId()); if (certificatePolicyQualifierType == PKIX_CPS_POINTER_QUALIFIER) { DERIA5String cpsPointer = ((DERIA5String) policyQualifierInfo.getQualifier()); sbPolicyQualifier .append(MessageFormat.format(res.getString("PolicyInformationUtil.CpsPointer"), cpsPointer)); } else if (certificatePolicyQualifierType == PKIX_USER_NOTICE_QUALIFIER) { ASN1Encodable userNoticeObj = policyQualifierInfo.getQualifier(); UserNotice userNotice = UserNotice.getInstance(userNoticeObj); sbPolicyQualifier.append(MessageFormat.format(res.getString("PolicyInformationUtil.UserNotice"), toString(userNotice))); } return sbPolicyQualifier.toString(); }
/** * Load the PolicyQualifierInfoTableModel with policy qualifier info. * * @param policyQualifierInfo * The policy qualifier info */ public void load(List<PolicyQualifierInfo> policyQualifierInfo) { PolicyQualifierInfo[] policyQualifierInfoArray = policyQualifierInfo .toArray(new PolicyQualifierInfo[policyQualifierInfo.size()]); Arrays.sort(policyQualifierInfoArray, new PolicyQualifierInfoComparator()); data = new Object[policyQualifierInfoArray.length][1]; int i = 0; for (PolicyQualifierInfo policyQualInfo : policyQualifierInfoArray) { data[i][0] = policyQualInfo; i++; } fireTableDataChanged(); }
/** * 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) { throw new RuntimeException(ex); // We build this data so should not // happen } cell.setHorizontalAlignment(LEFT); cell.setBorder(new EmptyBorder(0, 5, 0, 5)); return cell; }
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); } } }
static void setCertificatePoliciesExtension(X509v3CertificateBuilder certificateBuilder, boolean isCritical, boolean anyPolicy, String cpsURI) throws IOException { if (anyPolicy) { PolicyQualifierInfo policyQualifierInfo = new PolicyQualifierInfo(cpsURI); PolicyInformation policyInformation = new PolicyInformation(PolicyQualifierId.id_qt_cps, new DERSequence(policyQualifierInfo)); CertificatePolicies certificatePolicies = new CertificatePolicies(policyInformation); certificateBuilder.addExtension(Extension.certificatePolicies, isCritical, certificatePolicies); } }
/** * 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(); }
@Override public int compare(PolicyQualifierInfo policyQualifierInfo1, PolicyQualifierInfo policyQualifierInfo2) { try { return PolicyInformationUtil.toString(policyQualifierInfo1).compareToIgnoreCase( PolicyInformationUtil.toString(policyQualifierInfo2)); } catch (IOException ex) { throw new RuntimeException(ex); // We build this data so should // not happen } }
private void populate() { if (policyQualifierInfo == null) { policyQualifierInfo = new ArrayList<PolicyQualifierInfo>(); } reloadPolicyQualifierInfoTable(); selectFirstPolicyQualifierInfoInTable(); updateButtonControls(); }
private void addPressed() { Container container = getTopLevelAncestor(); try { DPolicyQualifierInfoChooser dPolicyQualifierInfoChooser = null; if (container instanceof JDialog) { dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JDialog) container, title, null); dPolicyQualifierInfoChooser.setLocationRelativeTo(container); dPolicyQualifierInfoChooser.setVisible(true); } else if (container instanceof JFrame) { dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JFrame) container, title, null); dPolicyQualifierInfoChooser.setLocationRelativeTo(container); dPolicyQualifierInfoChooser.setVisible(true); } PolicyQualifierInfo newPolicyQualifierInfo = dPolicyQualifierInfoChooser.getPolicyQualifierInfo(); if (newPolicyQualifierInfo == null) { return; } 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); } }
private void removeSelectedPolicyQualifierInfo() { int selectedRow = jtPolicyQualifierInfo.getSelectedRow(); if (selectedRow != -1) { PolicyQualifierInfo policyQualInfo = (PolicyQualifierInfo) jtPolicyQualifierInfo.getValueAt(selectedRow, 0); policyQualifierInfo.remove(policyQualInfo); reloadPolicyQualifierInfoTable(); selectFirstPolicyQualifierInfoInTable(); updateButtonControls(); } }
private void selectPolicyQualifierInfoInTable(PolicyQualifierInfo policyQualInfo) { for (int i = 0; i < jtPolicyQualifierInfo.getRowCount(); i++) { if (policyQualInfo.equals(jtPolicyQualifierInfo.getValueAt(i, 0))) { jtPolicyQualifierInfo.changeSelection(i, 0, false, false); return; } } }
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); } } }
/** * Get the class at of the cells at the given column position. * * @param col * The column position * @return The column cells' class */ @Override public Class<?> getColumnClass(int col) { return PolicyQualifierInfo.class; }
/** * Constructs a new DPolicyQualifierInfoChooser dialog. * * @param parent * The parent frame * @param title * The dialog title * @param policyQualifierInfo * Policy qualifier info * @throws IOException * If policy qualifier info could not be decoded */ public DPolicyQualifierInfoChooser(JFrame parent, String title, PolicyQualifierInfo policyQualifierInfo) throws IOException { super(parent, title, ModalityType.DOCUMENT_MODAL); initComponents(policyQualifierInfo); }
/** * Constructs a new DPolicyQualifierInfoChooser dialog. * * @param parent * The parent dialog * @param title * The dialog title * @param policyQualifierInfo * Policy qualifier info * @throws IOException * If policy qualifier info could not be decoded */ public DPolicyQualifierInfoChooser(JDialog parent, String title, PolicyQualifierInfo policyQualifierInfo) throws IOException { super(parent, title, Dialog.ModalityType.DOCUMENT_MODAL); initComponents(policyQualifierInfo); }
/** * Get selected policy qualifier info. * * @return General subtree, or null if none */ public PolicyQualifierInfo getPolicyQualifierInfo() { return policyQualifierInfo; }
/** * Get policy qualifier info. * * @return Policy qualifier info */ public List<PolicyQualifierInfo> getPolicyQualifierInfo() { return policyQualifierInfo; }
/** * Set policy qualifier info. * * @param policyQualifierInfo * Policy qualifier info */ public void setPolicyQualifierInfo(List<PolicyQualifierInfo> policyQualifierInfo) { this.policyQualifierInfo = policyQualifierInfo; populate(); }