本文整理匯總了Java中java.security.cert.X509Certificate.getTBSCertificate方法的典型用法代碼示例。如果您正苦於以下問題:Java X509Certificate.getTBSCertificate方法的具體用法?Java X509Certificate.getTBSCertificate怎麽用?Java X509Certificate.getTBSCertificate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.cert.X509Certificate
的用法示例。
在下文中一共展示了X509Certificate.getTBSCertificate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getIssuerX509Principal
import java.security.cert.X509Certificate; //導入方法依賴的package包/類
/**
* return the issuer of the given cert as an X509PrincipalObject.
*/
public static X509Principal getIssuerX509Principal(
X509Certificate cert)
throws CertificateEncodingException
{
try
{
ByteArrayInputStream bIn = new ByteArrayInputStream(
cert.getTBSCertificate());
ASN1InputStream aIn = new ASN1InputStream(bIn);
TBSCertificateStructure tbsCert = new TBSCertificateStructure(
(ASN1Sequence)aIn.readObject());
return new X509Principal(tbsCert.getIssuer());
}
catch (IOException e)
{
throw new CertificateEncodingException(e.toString());
}
}
示例2: getSubjectX509Principal
import java.security.cert.X509Certificate; //導入方法依賴的package包/類
/**
* return the subject of the given cert as an X509PrincipalObject.
*/
public static X509Principal getSubjectX509Principal(
X509Certificate cert)
throws CertificateEncodingException
{
try
{
ByteArrayInputStream bIn = new ByteArrayInputStream(
cert.getTBSCertificate());
ASN1InputStream aIn = new ASN1InputStream(bIn);
TBSCertificateStructure tbsCert = new TBSCertificateStructure(
(ASN1Sequence)aIn.readObject());
return new X509Principal(tbsCert.getSubject());
}
catch (IOException e)
{
throw new CertificateEncodingException(e.toString());
}
}
示例3: populateCertIssuerNames
import java.security.cert.X509Certificate; //導入方法依賴的package包/類
/**
* Populate array of Issuer DNs from certificates and convert
* each Principal to type X500Name if necessary.
*/
private void populateCertIssuerNames() {
if (certificates == null)
return;
certIssuerNames = new Principal[certificates.length];
for (int i = 0; i < certificates.length; i++) {
X509Certificate cert = certificates[i];
Principal certIssuerName = cert.getIssuerDN();
if (!(certIssuerName instanceof X500Name)) {
// must extract the original encoded form of DN for
// subsequent name comparison checks (converting to a
// String and back to an encoded DN could cause the
// types of String attribute values to be changed)
try {
X509CertInfo tbsCert =
new X509CertInfo(cert.getTBSCertificate());
certIssuerName = (Principal)
tbsCert.get(X509CertInfo.ISSUER + "." +
X509CertInfo.DN_NAME);
} catch (Exception e) {
// error generating X500Name object from the cert's
// issuer DN, leave name as is.
}
}
certIssuerNames[i] = certIssuerName;
}
}