本文整理汇总了Java中org.bouncycastle.asn1.x509.X509Extensions类的典型用法代码示例。如果您正苦于以下问题:Java X509Extensions类的具体用法?Java X509Extensions怎么用?Java X509Extensions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
X509Extensions类属于org.bouncycastle.asn1.x509包,在下文中一共展示了X509Extensions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GenOcspReq
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public static OCSPReq GenOcspReq(X509Certificate nextCert,
X509Certificate nextIssuer) throws OCSPException {
OCSPReqGenerator ocspRequestGenerator = new OCSPReqGenerator();
CertificateID certId = new CertificateID(CertificateID.HASH_SHA1,
nextIssuer, nextCert.getSerialNumber());
ocspRequestGenerator.addRequest(certId);
BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());
Vector<DERObjectIdentifier> oids = new Vector<DERObjectIdentifier>();
Vector<X509Extension> values = new Vector<X509Extension>();
oids.add(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
values.add(new X509Extension(false, new DEROctetString(nonce
.toByteArray())));
ocspRequestGenerator.setRequestExtensions(new X509Extensions(oids,
values));
return ocspRequestGenerator.generate();
}
示例2: makeCertificate
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public static X509Certificate makeCertificate(KeyPair _subKP,
String _subDN, KeyPair _issKP, String _issDN, String algorithm, boolean _ca)
throws Exception
{
PublicKey _subPub = _subKP.getPublic();
PrivateKey _issPriv = _issKP.getPrivate();
PublicKey _issPub = _issKP.getPublic();
X509V3CertificateGenerator _v3CertGen = new X509V3CertificateGenerator();
_v3CertGen.reset();
_v3CertGen.setSerialNumber(allocateSerialNumber());
_v3CertGen.setIssuerDN(new X509Name(_issDN));
_v3CertGen.setNotBefore(new Date(System.currentTimeMillis()));
_v3CertGen.setNotAfter(new Date(System.currentTimeMillis()
+ (1000L * 60 * 60 * 24 * 100)));
_v3CertGen.setSubjectDN(new X509Name(_subDN));
_v3CertGen.setPublicKey(_subPub);
_v3CertGen.setSignatureAlgorithm(algorithm);
_v3CertGen.addExtension(X509Extensions.SubjectKeyIdentifier, false,
createSubjectKeyId(_subPub));
_v3CertGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false,
createAuthorityKeyId(_issPub));
_v3CertGen.addExtension(X509Extensions.BasicConstraints, false,
new BasicConstraints(_ca));
X509Certificate _cert = _v3CertGen.generate(_issPriv);
_cert.checkValidity(new Date());
_cert.verify(_issPub);
return _cert;
}
示例3: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
Set set = new HashSet();
X509Extensions extensions = this.getResponseExtensions();
if (extensions != null)
{
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
}
return set;
}
示例4: getExtensionValue
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
X509Extensions exts = this.getResponseExtensions();
if (exts != null)
{
X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getValue().getEncoded(ASN1Encoding.DER);
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}
示例5: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
Set set = new HashSet();
X509Extensions extensions = this.getRequestExtensions();
if (extensions != null)
{
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
}
return set;
}
示例6: getExtensionValue
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
X509Extensions exts = this.getRequestExtensions();
if (exts != null)
{
X509Extension ext = exts.getExtension(new ASN1ObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getValue().getEncoded(ASN1Encoding.DER);
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}
示例7: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
Set set = new HashSet();
X509Extensions extensions = this.getSingleRequestExtensions();
if (extensions != null)
{
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
}
return set;
}
示例8: getExtensionValue
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
X509Extensions exts = this.getSingleRequestExtensions();
if (exts != null)
{
X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getValue().getEncoded(ASN1Encoding.DER);
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}
示例9: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
Set set = new HashSet();
X509Extensions extensions = this.getSingleExtensions();
if (extensions != null)
{
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
}
return set;
}
示例10: getExtensionValue
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
X509Extensions exts = this.getSingleExtensions();
if (exts != null)
{
X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));
if (ext != null)
{
try
{
return ext.getValue().getEncoded(ASN1Encoding.DER);
}
catch (Exception e)
{
throw new RuntimeException("error encoding " + e.toString());
}
}
}
return null;
}
示例11: generateSignedCertificate
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private X509Certificate generateSignedCertificate(
PKCS10CertificationRequest csr) throws NoSuchAlgorithmException,
NoSuchProviderException, InvalidKeyException,
CertificateParsingException, CertificateEncodingException,
SignatureException {
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
certGen.setSerialNumber(BigInteger.valueOf(System.currentTimeMillis()));
certGen.setIssuerDN(rootCert.getSubjectX500Principal());
Calendar c = Calendar.getInstance();
certGen.setNotBefore(c.getTime());
c.add(Calendar.YEAR, 1);
certGen.setNotAfter(c.getTime());
certGen.setSubjectDN(csr.getCertificationRequestInfo().getSubject());
certGen.setPublicKey(csr.getPublicKey("BC"));
certGen.setSignatureAlgorithm(ALGORITHM_SHA256_RSA);
certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false,
new AuthorityKeyIdentifierStructure(rootCert.getPublicKey()));
certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false,
new SubjectKeyIdentifierStructure(csr.getPublicKey("BC")));
certGen.addExtension(X509Extensions.BasicConstraints, true,
new BasicConstraints(false));
certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(
KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
X509Certificate issuedCert = certGen.generate(rootPrivateKeyEntry
.getPrivateKey());
return issuedCert;
}
示例12: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(
boolean critical)
{
X509Extensions extensions = cert.getAcinfo().getExtensions();
if (extensions != null)
{
Set set = new HashSet();
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (ext.isCritical() == critical)
{
set.add(oid.getId());
}
}
return set;
}
return null;
}
示例13: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
if (this.getVersion() == 2)
{
HashSet set = new HashSet();
X509Extensions extensions = c.getTBSCertList().getExtensions();
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
return set;
}
return null;
}
示例14: getExtensionOIDs
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
private Set getExtensionOIDs(boolean critical)
{
X509Extensions extensions = c.getExtensions();
if ( extensions != null )
{
HashSet set = new HashSet();
Enumeration e = extensions.oids();
while (e.hasMoreElements())
{
DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement();
X509Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical())
{
set.add(oid.getId());
}
}
return set;
}
return null;
}
示例15: getExtensionValue
import org.bouncycastle.asn1.x509.X509Extensions; //导入依赖的package包/类
public byte[] getExtensionValue(String oid)
{
X509Extensions exts = c.getExtensions();
if (exts != null)
{
X509Extension ext = exts.getExtension(new DERObjectIdentifier(oid));
if (ext != null)
{
return ext.getValue().getOctets();
}
}
return null;
}