org.bouncycastle.asn1.x509.PolicyQualifierInfo Java Examples
The following examples show how to use
org.bouncycastle.asn1.x509.PolicyQualifierInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PolicyInformationUtil.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
/** * 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(); }
Example #2
Source File: PolicyQualifierInfoTableModel.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
/** * 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(); }
Example #3
Source File: PolicyQualifierInfoTableCellRend.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #4
Source File: DPolicyQualifierInfoChooser.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
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); } } }
Example #5
Source File: DPolicyInformationChooser.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
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); } } }
Example #6
Source File: PolicyInformationUtil.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
/** * 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(); }
Example #7
Source File: PolicyQualifierInfoTableModel.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
@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 } }
Example #8
Source File: DSSASN1Utils.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
public static List<CertificatePolicy> getCertificatePolicies(final CertificateToken certToken) { List<CertificatePolicy> certificatePolicies = new ArrayList<>(); final byte[] certificatePoliciesBinaries = certToken.getCertificate().getExtensionValue(Extension.certificatePolicies.getId()); if (Utils.isArrayNotEmpty(certificatePoliciesBinaries)) { try { ASN1Sequence seq = getAsn1SequenceFromDerOctetString(certificatePoliciesBinaries); for (int ii = 0; ii < seq.size(); ii++) { CertificatePolicy cp = new CertificatePolicy(); final PolicyInformation policyInfo = PolicyInformation.getInstance(seq.getObjectAt(ii)); cp.setOid(policyInfo.getPolicyIdentifier().getId()); ASN1Sequence policyQualifiersSeq = policyInfo.getPolicyQualifiers(); if (policyQualifiersSeq != null) { for (int jj = 0; jj < policyQualifiersSeq.size(); jj++) { PolicyQualifierInfo pqi = PolicyQualifierInfo.getInstance(policyQualifiersSeq.getObjectAt(jj)); if (PolicyQualifierId.id_qt_cps.equals(pqi.getPolicyQualifierId())) { cp.setCpsUrl(getString(pqi.getQualifier())); } } } certificatePolicies.add(cp); } } catch (Exception e) { LOG.warn("Unable to parse the certificatePolicies extension '{}' : {}", Utils.toBase64(certificatePoliciesBinaries), e.getMessage(), e); } } return certificatePolicies; }
Example #9
Source File: JPolicyQualifierInfo.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
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; } } }
Example #10
Source File: JPolicyQualifierInfo.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
private void removeSelectedPolicyQualifierInfo() { int selectedRow = jtPolicyQualifierInfo.getSelectedRow(); if (selectedRow != -1) { PolicyQualifierInfo policyQualInfo = (PolicyQualifierInfo) jtPolicyQualifierInfo.getValueAt(selectedRow, 0); policyQualifierInfo.remove(policyQualInfo); reloadPolicyQualifierInfoTable(); selectFirstPolicyQualifierInfoInTable(); updateButtonControls(); } }
Example #11
Source File: JPolicyQualifierInfo.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
private void addPressed() { Container container = getTopLevelAncestor(); try { DPolicyQualifierInfoChooser dPolicyQualifierInfoChooser = null; if (container instanceof JDialog) { dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JDialog) container, title, null); } else { 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); } }
Example #12
Source File: ExtensionsChecker.java From xipki with Apache License 2.0 | 4 votes |
private void checkExtnCertificatePolicies(StringBuilder failureMsg, byte[] extensionValue, Extensions requestedExtns, ExtensionControl extControl) { CertificatePolicies conf = certificatePolicies; if (conf == null) { checkConstantExtnValue(Extension.certificatePolicies, failureMsg, extensionValue, requestedExtns, extControl); return; } Map<String, CertificatePolicyInformationType> expPoliciesMap = new HashMap<>(); for (CertificatePolicyInformationType cp : conf.getCertificatePolicyInformations()) { expPoliciesMap.put(cp.getPolicyIdentifier().getOid(), cp); } Set<String> expPolicyIds = new HashSet<>(expPoliciesMap.keySet()); org.bouncycastle.asn1.x509.CertificatePolicies asn1 = org.bouncycastle.asn1.x509.CertificatePolicies.getInstance(extensionValue); PolicyInformation[] isPolicyInformations = asn1.getPolicyInformation(); for (PolicyInformation isPolicyInformation : isPolicyInformations) { ASN1ObjectIdentifier isPolicyId = isPolicyInformation.getPolicyIdentifier(); expPolicyIds.remove(isPolicyId.getId()); CertificatePolicyInformationType expCp = expPoliciesMap.get(isPolicyId.getId()); if (expCp == null) { failureMsg.append("certificate policy '").append(isPolicyId).append("' is not expected; "); continue; } List<PolicyQualifier> expCpPq = expCp.getPolicyQualifiers(); if (CollectionUtil.isEmpty(expCpPq)) { continue; } ASN1Sequence isPolicyQualifiers = isPolicyInformation.getPolicyQualifiers(); List<String> isCpsUris = new LinkedList<>(); List<String> isUserNotices = new LinkedList<>(); int size = isPolicyQualifiers.size(); for (int i = 0; i < size; i++) { PolicyQualifierInfo isPolicyQualifierInfo = PolicyQualifierInfo.getInstance(isPolicyQualifiers.getObjectAt(i)); ASN1ObjectIdentifier isPolicyQualifierId = isPolicyQualifierInfo.getPolicyQualifierId(); ASN1Encodable isQualifier = isPolicyQualifierInfo.getQualifier(); if (PolicyQualifierId.id_qt_cps.equals(isPolicyQualifierId)) { String isCpsUri = DERIA5String.getInstance(isQualifier).getString(); isCpsUris.add(isCpsUri); } else if (PolicyQualifierId.id_qt_unotice.equals(isPolicyQualifierId)) { UserNotice isUserNotice = UserNotice.getInstance(isQualifier); if (isUserNotice.getExplicitText() != null) { isUserNotices.add(isUserNotice.getExplicitText().getString()); } } } for (PolicyQualifier qualifierInfo : expCpPq) { String value = qualifierInfo.getValue(); switch (qualifierInfo.getType()) { case cpsUri: if (!isCpsUris.contains(value)) { failureMsg.append("CPSUri '").append(value).append("' is absent but is required; "); } continue; case userNotice: if (!isUserNotices.contains(value)) { failureMsg.append("userNotice '").append(value) .append("' is absent but is required; "); } continue; default: throw new IllegalStateException("should not reach here"); } } } for (String policyId : expPolicyIds) { failureMsg.append("certificate policy '").append(policyId) .append("' is absent but is required; "); } }
Example #13
Source File: JPolicyQualifierInfo.java From keystore-explorer with GNU General Public License v3.0 | 4 votes |
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); } else { 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); } } }
Example #14
Source File: JPolicyQualifierInfo.java From keystore-explorer with GNU General Public License v3.0 | 2 votes |
/** * Set policy qualifier info. * * @param policyQualifierInfo * Policy qualifier info */ public void setPolicyQualifierInfo(List<PolicyQualifierInfo> policyQualifierInfo) { this.policyQualifierInfo = policyQualifierInfo; populate(); }
Example #15
Source File: JPolicyQualifierInfo.java From keystore-explorer with GNU General Public License v3.0 | 2 votes |
/** * Get policy qualifier info. * * @return Policy qualifier info */ public List<PolicyQualifierInfo> getPolicyQualifierInfo() { return policyQualifierInfo; }
Example #16
Source File: DPolicyQualifierInfoChooser.java From keystore-explorer with GNU General Public License v3.0 | 2 votes |
/** * Get selected policy qualifier info. * * @return General subtree, or null if none */ public PolicyQualifierInfo getPolicyQualifierInfo() { return policyQualifierInfo; }
Example #17
Source File: DPolicyQualifierInfoChooser.java From keystore-explorer with GNU General Public License v3.0 | 2 votes |
/** * 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); }
Example #18
Source File: DPolicyQualifierInfoChooser.java From keystore-explorer with GNU General Public License v3.0 | 2 votes |
/** * 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); }
Example #19
Source File: PolicyQualifierInfoTableModel.java From keystore-explorer with GNU General Public License v3.0 | 2 votes |
/** * 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; }