本文整理汇总了Java中org.bouncycastle.asn1.x509.Extensions类的典型用法代码示例。如果您正苦于以下问题:Java Extensions类的具体用法?Java Extensions怎么用?Java Extensions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Extensions类属于org.bouncycastle.asn1.x509包,在下文中一共展示了Extensions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateOCSPRequest
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
/**
* Generates an OCSP request using BouncyCastle.
* @param issuerCert certificate of the issues
* @param serialNumber serial number
* @return an OCSP request
* @throws OCSPException
* @throws IOException
*/
private static OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws OCSPException, IOException, OperatorException, CertificateEncodingException {
//Add provider BC
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
DigestCalculator digestCalculator = digestCalculatorProvider.get(CertificateID.HASH_SHA1);
// Generate the id for the certificate we are looking for
CertificateID id = new CertificateID(digestCalculator, new JcaX509CertificateHolder(issuerCert), serialNumber);
// basic request generation with nonce
OCSPReqBuilder gen = new OCSPReqBuilder();
gen.addRequest(id);
// create details for nonce extension
Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.createDocumentId()).getEncoded()));
gen.setRequestExtensions(new Extensions(new Extension[]{ext}));
return gen.build();
}
示例2: getExtensionValue
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
Extensions extensions = cert.getAcinfo().getExtensions();
if (extensions != null)
{
Extension ext = extensions.getExtension(new ASN1ObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getExtnValue().getEncoded(ASN1Encoding.DER);
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}
示例3: getExtensionOIDs
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(
boolean critical)
{
Extensions extensions = cert.getAcinfo().getExtensions();
if (extensions != null)
{
Set set = new HashSet();
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
Extension ext = extensions.getExtension(oid);
if (ext.isCritical() == critical)
{
set.add(oid.getId());
}
}
return set;
}
return null;
}
示例4: getExtensionValue
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
Extensions exts = c.getTBSCertificate().getExtensions();
if (exts != null)
{
Extension ext = exts.getExtension(new ASN1ObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getExtnValue().getEncoded();
}
catch (Exception e)
{
throw new IllegalStateException("error parsing " + e.toString());
}
}
}
return null;
}
示例5: getExtensionValue
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
Extensions exts = c.getTBSCertList().getExtensions();
if (exts != null)
{
Extension ext = exts.getExtension(new ASN1ObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getExtnValue().getEncoded();
}
catch (Exception e)
{
throw new IllegalStateException("error parsing " + e.toString());
}
}
}
return null;
}
示例6: getExtensionOIDs
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
Extensions extensions = c.getExtensions();
if (extensions != null)
{
Set set = new HashSet();
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
return set;
}
return null;
}
示例7: validateKeyUsage
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static void validateKeyUsage(org.bouncycastle.asn1.x509.Certificate c, int keyUsageBits)
throws IOException
{
Extensions exts = c.getTBSCertificate().getExtensions();
if (exts != null)
{
KeyUsage ku = KeyUsage.fromExtensions(exts);
if (ku != null)
{
int bits = ku.getBytes()[0] & 0xff;
if ((bits & keyUsageBits) != keyUsageBits)
{
throw new TlsFatalAlert(AlertDescription.certificate_unknown);
}
}
}
}
示例8: TSTInfo
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public TSTInfo(ASN1ObjectIdentifier tsaPolicyId, MessageImprint messageImprint,
ASN1Integer serialNumber, ASN1GeneralizedTime genTime,
Accuracy accuracy, ASN1Boolean ordering, ASN1Integer nonce,
GeneralName tsa, Extensions extensions)
{
version = new ASN1Integer(1);
this.tsaPolicyId = tsaPolicyId;
this.messageImprint = messageImprint;
this.serialNumber = serialNumber;
this.genTime = genTime;
this.accuracy = accuracy;
this.ordering = ordering;
this.nonce = nonce;
this.tsa = tsa;
this.extensions = extensions;
}
示例9: TimeStampReq
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public TimeStampReq(
MessageImprint messageImprint,
ASN1ObjectIdentifier tsaPolicy,
ASN1Integer nonce,
ASN1Boolean certReq,
Extensions extensions)
{
// default
version = new ASN1Integer(1);
this.messageImprint = messageImprint;
this.tsaPolicy = tsaPolicy;
this.nonce = nonce;
this.certReq = certReq;
this.extensions = extensions;
}
示例10: getExtensionValue
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
Extensions exts = req.getExtensions();
if (exts != null)
{
Extension ext = exts.getExtension(new ASN1ObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getExtnValue().getEncoded();
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}
示例11: getExtensionsFromCSR
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
/**
* Extract extensions from CSR object
*/
public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) {
Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
for (Attribute attribute : attributess) {
ASN1Set attValue = attribute.getAttrValues();
if (attValue != null) {
ASN1Encodable extension = attValue.getObjectAt(0);
if (extension instanceof Extensions) {
return (Extensions) extension;
} else if (extension instanceof DERSequence) {
return Extensions.getInstance(extension);
}
}
}
return null;
}
示例12: extractX509CSRIPAddresses
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
public static List<String> extractX509CSRIPAddresses(PKCS10CertificationRequest certReq) {
List<String> ipAddresses = new ArrayList<>();
Attribute[] attributes = certReq.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
for (Attribute attribute : attributes) {
for (ASN1Encodable value : attribute.getAttributeValues()) {
Extensions extensions = Extensions.getInstance(value);
GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName);
for (GeneralName name : gns.getNames()) {
if (name.getTagNo() == GeneralName.iPAddress) {
try {
InetAddress addr = InetAddress.getByAddress(((DEROctetString) name.getName()).getOctets());
ipAddresses.add(addr.getHostAddress());
} catch (UnknownHostException e) {
}
}
}
}
}
return ipAddresses;
}
示例13: getCriticalExtensionOIDs
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static Set getCriticalExtensionOIDs(Extensions extensions)
{
if (extensions == null)
{
return EMPTY_SET;
}
return Collections.unmodifiableSet(new HashSet(Arrays.asList(extensions.getCriticalExtensionOIDs())));
}
示例14: getNonCriticalExtensionOIDs
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static Set getNonCriticalExtensionOIDs(Extensions extensions)
{
if (extensions == null)
{
return EMPTY_SET;
}
// TODO: should probably produce a set that imposes correct ordering
return Collections.unmodifiableSet(new HashSet(Arrays.asList(extensions.getNonCriticalExtensionOIDs())));
}
示例15: getExtensionOIDs
import org.bouncycastle.asn1.x509.Extensions; //导入依赖的package包/类
static List getExtensionOIDs(Extensions extensions)
{
if (extensions == null)
{
return EMPTY_LIST;
}
return Collections.unmodifiableList(Arrays.asList(extensions.getExtensionOIDs()));
}