本文整理汇总了Java中java.security.cert.X509Certificate.getSigAlgName方法的典型用法代码示例。如果您正苦于以下问题:Java X509Certificate.getSigAlgName方法的具体用法?Java X509Certificate.getSigAlgName怎么用?Java X509Certificate.getSigAlgName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.cert.X509Certificate
的用法示例。
在下文中一共展示了X509Certificate.getSigAlgName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCertificateInfoList
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
@Override
public List<CertificateBasicInfoModel> getCertificateInfoList() throws Exception {
reloadTrustManager();
ArrayList<CertificateBasicInfoModel> list = new ArrayList<>();
Enumeration<String> aliases = this.keyStore.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
if ("X.509".equals(this.keyStore.getCertificate(alias).getType())) {
X509Certificate certificate = (X509Certificate) this.keyStore.getCertificate(alias);
try {
CertificateBasicInfoModel infoModel = new CertificateBasicInfoModel(
alias, getSha1Fingerprint(certificate), certificate.getIssuerDN().getName(),
certificate.getNotBefore(), certificate.getNotAfter(), certificate.getSigAlgName(),
certificateToString(certificate));
list.add(infoModel);
} catch (NoSuchAlgorithmException | CertificateEncodingException e) {
LOG.error("Failed to add certificate basic info model", e);
}
} else {
list.add(new CertificateBasicInfoModel(alias));
}
}
return list;
}
示例2: checkConstraints
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
private void checkConstraints(Set<CryptoPrimitive> primitives,
CertConstraintParameters cp) throws CertPathValidatorException {
X509Certificate cert = cp.getCertificate();
String algorithm = cert.getSigAlgName();
// Check signature algorithm is not disabled
if (!permits(primitives, algorithm, null)) {
throw new CertPathValidatorException(
"Algorithm constraints check failed on disabled "+
"signature algorithm: " + algorithm,
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
// Check key algorithm is not disabled
if (!permits(primitives, cert.getPublicKey().getAlgorithm(), null)) {
throw new CertPathValidatorException(
"Algorithm constraints check failed on disabled "+
"public key algorithm: " + algorithm,
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
// Check the certificate and key constraints
algorithmConstraints.permits(cp);
}
示例3: run
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
private static void run(String keyAlg, int keySize,
String expectedSigAlg, String sigAlg) throws Exception {
String alias = keyAlg + keySize + System.currentTimeMillis();
String cmd = "-keystore ks -storepass changeit" +
" -keypass changeit -alias " + alias +
" -keyalg " + keyAlg + " -keysize " + keySize +
" -genkeypair -dname CN=" + alias + " -debug";
if (sigAlg != null) {
cmd += " -sigalg " + sigAlg;
}
Main.main(cmd.split(" "));
KeyStore ks = KeyStore.getInstance(
new File("ks"), "changeit".toCharArray());
X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
String actualSigAlg = cert.getSigAlgName();
if (!actualSigAlg.equals(expectedSigAlg)) {
throw new Exception("Failure at " + alias + ": expected "
+ expectedSigAlg + ", actually " + actualSigAlg);
}
}
示例4: printX509Cert
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
/**
* Prints a certificate in a human readable format.
*/
private void printX509Cert(X509Certificate cert, PrintStream out)
throws Exception
{
MessageFormat form = new MessageFormat
(rb.getString(".PATTERN.printX509Cert.with.weak"));
PublicKey pkey = cert.getPublicKey();
String sigName = cert.getSigAlgName();
// No need to warn about sigalg of a trust anchor
if (!isTrustedCert(cert)) {
sigName = withWeak(sigName);
}
Object[] source = {cert.getSubjectDN().toString(),
cert.getIssuerDN().toString(),
cert.getSerialNumber().toString(16),
cert.getNotBefore().toString(),
cert.getNotAfter().toString(),
getCertFingerPrint("SHA-1", cert),
getCertFingerPrint("SHA-256", cert),
sigName,
withWeak(pkey),
cert.getVersion()
};
out.println(form.format(source));
if (cert instanceof X509CertImpl) {
X509CertImpl impl = (X509CertImpl)cert;
X509CertInfo certInfo = (X509CertInfo)impl.get(X509CertImpl.NAME
+ "." +
X509CertImpl.INFO);
CertificateExtensions exts = (CertificateExtensions)
certInfo.get(X509CertInfo.EXTENSIONS);
if (exts != null) {
printExtensions(rb.getString("Extensions."), exts, out);
}
}
}
示例5: checkWeak
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
private void checkWeak(String label, Certificate cert)
throws KeyStoreException {
if (cert instanceof X509Certificate) {
X509Certificate xc = (X509Certificate)cert;
// No need to check the sigalg of a trust anchor
String sigAlg = isTrustedCert(cert) ? null : xc.getSigAlgName();
checkWeak(label, sigAlg, xc.getPublicKey());
}
}
示例6: getSignatureAlgorithm
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
public String getSignatureAlgorithm() {
X509Certificate cert = getCertificateList().get(0);
return cert.getSigAlgName();
}
示例7: printX509Cert
import java.security.cert.X509Certificate; //导入方法依赖的package包/类
/**
* Prints a certificate in a human readable format.
*/
private void printX509Cert(X509Certificate cert, PrintStream out)
throws Exception
{
/*
out.println("Owner: "
+ cert.getSubjectDN().toString()
+ "\n"
+ "Issuer: "
+ cert.getIssuerDN().toString()
+ "\n"
+ "Serial number: " + cert.getSerialNumber().toString(16)
+ "\n"
+ "Valid from: " + cert.getNotBefore().toString()
+ " until: " + cert.getNotAfter().toString()
+ "\n"
+ "Certificate fingerprints:\n"
+ "\t MD5: " + getCertFingerPrint("MD5", cert)
+ "\n"
+ "\t SHA1: " + getCertFingerPrint("SHA1", cert));
*/
MessageFormat form = new MessageFormat
(rb.getString(".PATTERN.printX509Cert"));
Object[] source = {cert.getSubjectDN().toString(),
cert.getIssuerDN().toString(),
cert.getSerialNumber().toString(16),
cert.getNotBefore().toString(),
cert.getNotAfter().toString(),
getCertFingerPrint("MD5", cert),
getCertFingerPrint("SHA1", cert),
getCertFingerPrint("SHA-256", cert),
cert.getSigAlgName(),
cert.getVersion()
};
out.println(form.format(source));
if (cert instanceof X509CertImpl) {
X509CertImpl impl = (X509CertImpl)cert;
X509CertInfo certInfo = (X509CertInfo)impl.get(X509CertImpl.NAME
+ "." +
X509CertImpl.INFO);
CertificateExtensions exts = (CertificateExtensions)
certInfo.get(X509CertInfo.EXTENSIONS);
if (exts != null) {
printExtensions(rb.getString("Extensions."), exts, out);
}
}
}