本文整理汇总了Java中org.bouncycastle.asn1.x509.Certificate.getEncoded方法的典型用法代码示例。如果您正苦于以下问题:Java Certificate.getEncoded方法的具体用法?Java Certificate.getEncoded怎么用?Java Certificate.getEncoded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x509.Certificate
的用法示例。
在下文中一共展示了Certificate.getEncoded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute0
import org.bouncycastle.asn1.x509.Certificate; //导入方法依赖的package包/类
@Override
protected Object execute0() throws Exception {
Certificate cert = Certificate.getInstance(IoUtil.read(inFile));
if (serial != null && serial) {
return getNumber(cert.getSerialNumber().getPositiveValue());
} else if (subject != null && subject) {
return cert.getSubject().toString();
} else if (issuer != null && issuer) {
return cert.getIssuer().toString();
} else if (notBefore != null && notBefore) {
return toUtcTimeyyyyMMddhhmmssZ(cert.getStartDate().getDate());
} else if (notAfter != null && notAfter) {
return toUtcTimeyyyyMMddhhmmssZ(cert.getEndDate().getDate());
} else if (fingerprint != null && fingerprint) {
byte[] encoded = cert.getEncoded();
return HashAlgoType.getHashAlgoType(hashAlgo).hexHash(encoded);
}
return null;
}
示例2: buildCRT
import org.bouncycastle.asn1.x509.Certificate; //导入方法依赖的package包/类
private static byte[] buildCRT(TBSCertificate tbs, AlgorithmIdentifier aid, byte[] sig) {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(tbs);
v.add(aid);
v.add(new DERBitString(sig));
byte [] crt = null;
try {
Certificate c = Certificate.getInstance(new DERSequence(v));
crt = c.getEncoded();
Base64.encode(crt, System.out);
System.out.println("");
} catch (Exception ex) {
ex.printStackTrace(System.out);
Assert.fail();
}
return crt;
}
示例3: PKCS12SafeBagBuilder
import org.bouncycastle.asn1.x509.Certificate; //导入方法依赖的package包/类
public PKCS12SafeBagBuilder(Certificate certificate)
throws IOException
{
this.bagType = PKCSObjectIdentifiers.certBag;
this.bagValue = new CertBag(PKCSObjectIdentifiers.x509Certificate, new DEROctetString(certificate.getEncoded()));
}
示例4: execute0
import org.bouncycastle.asn1.x509.Certificate; //导入方法依赖的package包/类
@Override
protected Object execute0() throws Exception {
X509CRL crl = X509Util.parseCrl(crlFile);
String oidExtnCerts = ObjectIdentifiers.id_xipki_ext_crlCertset.getId();
byte[] extnValue = crl.getExtensionValue(oidExtnCerts);
if (extnValue == null) {
throw new IllegalCmdParamException("no certificate is contained in " + crlFile);
}
extnValue = removingTagAndLenFromExtensionValue(extnValue);
ASN1Set asn1Set = DERSet.getInstance(extnValue);
final int n = asn1Set.size();
if (n == 0) {
throw new CmdFailure("no certificate is contained in " + crlFile);
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(out);
for (int i = 0; i < n; i++) {
ASN1Encodable asn1 = asn1Set.getObjectAt(i);
Certificate cert;
try {
ASN1Sequence seq = ASN1Sequence.getInstance(asn1);
cert = Certificate.getInstance(seq.getObjectAt(0));
} catch (IllegalArgumentException ex) {
// backwards compatibility
cert = Certificate.getInstance(asn1);
}
byte[] certBytes = cert.getEncoded();
String sha1FpCert = HashAlgoType.SHA1.hexHash(certBytes);
ZipEntry certZipEntry = new ZipEntry(sha1FpCert + ".der");
zip.putNextEntry(certZipEntry);
try {
zip.write(certBytes);
} finally {
zip.closeEntry();
}
}
zip.flush();
zip.close();
saveVerbose("extracted " + n + " certificates to", new File(outFile), out.toByteArray());
return null;
}