byte[] authorityExtensionValue = ext.getExtensionValue(Extension.authorityInfoAccess.getId()); if (authorityExtensionValue == null)
import org.bouncycastle.asn1.x509.KeyUsage; KeyUsage keyUsage = new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign); X509Extension extension = new X509Extension(true, new DEROctetString(keyUsage));
Set<String> critExts = extensions.getCriticalExtensionOIDs(); Set<String> nonCritExts = extensions.getNonCriticalExtensionOIDs(); byte[] value = extensions.getExtensionValue(extOid); byte[] value = extensions.getExtensionValue(extOid);
private X509Certificate generateVersion3(X500Name subject, X500Name issuer, Date validityStart, Date validityEnd, PublicKey publicKey, PrivateKey privateKey, SignatureType signatureType, BigInteger serialNumber, X509Extension extensions, Provider provider) throws CryptoException, CertIOException { Date notBefore = validityStart == null ? new Date() : validityStart; Date notAfter = validityEnd == null ? new Date(notBefore.getTime() + TimeUnit.DAYS.toMillis(365)) : validityEnd; JcaX509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(issuer, serialNumber, notBefore, notAfter, subject, publicKey); if (extensions != null) { for (String oid : extensions.getCriticalExtensionOIDs()) { certBuilder.addExtension(new ASN1ObjectIdentifier(oid), true, getExtensionValue(extensions, oid)); } for (String oid : extensions.getNonCriticalExtensionOIDs()) { certBuilder.addExtension(new ASN1ObjectIdentifier(oid), false, getExtensionValue(extensions, oid)); } } try { ContentSigner certSigner = null; if (provider == null) { certSigner = new JcaContentSignerBuilder(signatureType.jce()).setProvider("BC").build(privateKey); } else { certSigner = new JcaContentSignerBuilder(signatureType.jce()).setProvider(provider).build(privateKey); } return new JcaX509CertificateConverter().setProvider("BC").getCertificate(certBuilder.build(certSigner)); } catch (CertificateException | IllegalStateException | OperatorCreationException ex) { throw new CryptoException(res.getString("CertificateGenFailed.exception.message"), ex); } }
protected static ASN1Object getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
private void populateExtensionTypes() { // Population is the supported set minus those already added ArrayList<X509ExtensionType> availableExtensions = new ArrayList<>(); for (X509ExtensionType extentionType : SUPPORTED_EXTENSIONS) { if (extensions.getExtensionValue(extentionType.oid()) == null) { availableExtensions.add(extentionType); } } jltExtensionTypes.setListData(availableExtensions.toArray(new X509ExtensionType[availableExtensions.size()])); if (!availableExtensions.isEmpty()) { jltExtensionTypes.setSelectedIndex(0); } }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
/** * Extract the value of the given extension, if it exists. * * @param ext The extension object. * @param oid The object identifier to obtain. * @throws AnnotatedException if the extension cannot be read. */ protected static ASN1Primitive getExtensionValue( java.security.cert.X509Extension ext, String oid) throws AnnotatedException { byte[] bytes = ext.getExtensionValue(oid); if (bytes == null) { return null; } return getObject(oid, bytes); }
private ASN1Encodable getExtensionValue(X509Extension extensions, String oid) throws CryptoException { byte[] octets = ASN1OctetString.getInstance(extensions.getExtensionValue(oid)).getOctets(); try (ASN1InputStream ais = new ASN1InputStream(octets)) { return ais.readObject(); } catch (IOException ex) { throw new CryptoException(res.getString("CertificateGenFailed.exception.message"), ex); } } }
private void updateExtensionValue() { int selectedRow = jtExtensions.getSelectedRow(); if (selectedRow == -1) { jepExtensionValue.setText(""); jbAsn1.setEnabled(false); } else { String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId(); byte[] value = extensions.getExtensionValue(oid); boolean criticality = (Boolean) jtExtensions.getValueAt(selectedRow, 0); X509Ext ext = new X509Ext(oid, value, criticality); try { jepExtensionValue.setText("<html><body>" + ext.getStringValue() .replace(X509Ext.INDENT.getIndentChar().toString(), " ") .replace(X509Ext.NEWLINE, "<br/>") + "</body></html>"); } catch (Exception e) { jepExtensionValue.setText(""); DError.displayError(this, e); } jepExtensionValue.setCaretPosition(0); jbAsn1.setEnabled(true); } }
byte[] extPolicyBytes = cert.getExtensionValue(CERTIFICATE_POLICY_OID); if (extPolicyBytes == null) { return null;
private void asn1DumpPressed() { int selectedRow = jtExtensions.getSelectedRow(); if (selectedRow == -1) { return; } String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId(); byte[] value = extensions.getExtensionValue(oid); boolean criticality = (Boolean) jtExtensions.getValueAt(selectedRow, 0); X509Ext extension = new X509Ext(oid, value, criticality); try { DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, extension); dViewAsn1Dump.setLocationRelativeTo(this); dViewAsn1Dump.setVisible(true); } catch (Asn1Exception | IOException e) { DError.displayError(this, e); } }