public PolicyInformation[] getPolicies() { if (policies == null) { return null; } PolicyInformation[] ps = new PolicyInformation[policies.size()]; for (int i = 0; i != policies.size(); i++) { ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i)); } return ps; }
public SigningCertificateV2( ESSCertIDv2[] certs, PolicyInformation[] policies) { ASN1EncodableVector v = new ASN1EncodableVector(); for (int i=0; i < certs.length; i++) { v.add(certs[i]); } this.certs = new DERSequence(v); if (policies != null) { v = new ASN1EncodableVector(); for (int i=0; i < policies.length; i++) { v.add(policies[i]); } this.policies = new DERSequence(v); } }
private void okPressed() { List<PolicyInformation> policyInformation = jpiCertificatePolicies.getPolicyInformation(); if (policyInformation.size() == 0) { JOptionPane.showMessageDialog(this, res.getString("DCertificatePolicies.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } CertificatePolicies certificatePolicies = new CertificatePolicies(policyInformation.toArray( new PolicyInformation[policyInformation.size()])); try { value = certificatePolicies.getEncoded(ASN1Encoding.DER); } catch (IOException ex) { DError dError = new DError(this, ex); dError.setLocationRelativeTo(this); dError.setVisible(true); return; } closeDialog(); }
/** * 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) { 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); } } }
/** * Load the PolicyInformationTableModel with policy information. * * @param policyInformation * The policy information */ public void load(List<PolicyInformation> policyInformation) { PolicyInformation[] policyInformationArray = policyInformation.toArray(new PolicyInformation[policyInformation .size()]); Arrays.sort(policyInformationArray, new PolicyInformationComparator()); data = new Object[policyInformation.size()][1]; int i = 0; for (PolicyInformation policyInfo : policyInformationArray) { data[i][0] = policyInfo; i++; } fireTableDataChanged(); }
public static org.bouncycastle.asn1.x509.CertificatePolicies createCertificatePolicies( List<CertificatePolicyInformation> policyInfos) throws CertprofileException { ParamUtil.requireNonEmpty("policyInfos", policyInfos); int size = policyInfos.size(); PolicyInformation[] infos = new PolicyInformation[size]; int idx = 0; for (CertificatePolicyInformation policyInfo : policyInfos) { String policyId = policyInfo.certPolicyId(); List<CertificatePolicyQualifier> qualifiers = policyInfo.qualifiers(); ASN1Sequence policyQualifiers = null; if (CollectionUtil.isNonEmpty(qualifiers)) { policyQualifiers = createPolicyQualifiers(qualifiers); } ASN1ObjectIdentifier policyOid = new ASN1ObjectIdentifier(policyId); infos[idx++] = (policyQualifiers == null) ? new PolicyInformation(policyOid) : new PolicyInformation(policyOid, policyQualifiers); } return new org.bouncycastle.asn1.x509.CertificatePolicies(infos); }
/** * Get a certificate policy ID from a certificate policies extension * * @param cert certificate containing the extension * @param pos position of the policy id, if several exist, the first is as pos 0 * @return String with the certificate policy OID * @throws IOException if extension can not be parsed */ public static String getCertificatePolicyId(X509Certificate cert, int pos) throws IOException { byte[] extvalue = cert.getExtensionValue(X509Extensions.CertificatePolicies.getId()); if (extvalue == null) { return null; } DEROctetString oct = (DEROctetString) (new ASN1InputStream(new ByteArrayInputStream(extvalue)) .readObject()); ASN1Sequence seq = (ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(oct.getOctets())) .readObject(); // Check the size so we don't ArrayIndexOutOfBounds if (seq.size() < (pos + 1)) { return null; } PolicyInformation pol = new PolicyInformation((ASN1Sequence) seq.getObjectAt(pos)); String id = pol.getPolicyIdentifier().getId(); return id; }
public void setRequestPolicy(PolicyInformation requestPolicy) { if (initialInfo != null) { throw new IllegalStateException("cannot change request policy in existing DVCSRequestInformation"); } this.requestPolicy = requestPolicy; }
public PathProcInput(PolicyInformation[] acceptablePolicySet, boolean inhibitPolicyMapping, boolean explicitPolicyReqd, boolean inhibitAnyPolicy) { this.acceptablePolicySet = acceptablePolicySet; this.inhibitPolicyMapping = inhibitPolicyMapping; this.explicitPolicyReqd = explicitPolicyReqd; this.inhibitAnyPolicy = inhibitAnyPolicy; }
private static PolicyInformation[] fromSequence(ASN1Sequence seq) { PolicyInformation[] tmp = new PolicyInformation[seq.size()]; for (int i = 0; i != tmp.length; i++) { tmp[i] = PolicyInformation.getInstance(seq.getObjectAt(i)); } return tmp; }
public PolicyInformation[] getPolicies() { if (policies == null) { return null; } PolicyInformation[] policyInformations = new PolicyInformation[policies.size()]; for (int i = 0; i != policies.size(); i++) { policyInformations[i] = PolicyInformation.getInstance(policies.getObjectAt(i)); } return policyInformations; }
/** * Get policy, under which the validation is requested. * * @return policy identifier or null, if any policy is acceptable. */ public PolicyInformation getRequestPolicy() { if (data.getRequestPolicy() != null) { return data.getRequestPolicy(); } return null; }
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); } }
public CertificatePoliciesImpl(X509Certificate cert) throws IOException { certificatePolicyIds = new ArrayList<>(); byte[] extVal = cert.getExtensionValue(Extension.certificatePolicies.getId()); if (extVal == null) return; org.bouncycastle.asn1.x509.CertificatePolicies cf = org.bouncycastle.asn1.x509.CertificatePolicies .getInstance(X509ExtensionUtil.fromExtensionValue(extVal)); PolicyInformation[] information = cf.getPolicyInformation(); for (PolicyInformation p : information) { ASN1ObjectIdentifier aIdentifier = p.getPolicyIdentifier(); certificatePolicyIds.add(aIdentifier.getId()); } }