本文整理了Java中java.security.cert.X509Certificate.getKeyUsage()
方法的一些代码示例,展示了X509Certificate.getKeyUsage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X509Certificate.getKeyUsage()
方法的具体详情如下:
包路径:java.security.cert.X509Certificate
类名称:X509Certificate
方法名:getKeyUsage
[英]Returns the KeyUsage extension as a boolean array.
The ASN.1 definition of KeyUsage:
KeyUsage ::= BIT STRING {
digitalSignature (0),
nonRepudiation (1),
keyEncipherment (2),
dataEncipherment (3),
keyAgreement (4),
keyCertSign (5),
cRLSign (6),
encipherOnly (7),
decipherOnly (8) }
[中]以布尔数组的形式返回KeyUsage扩展名。
ASN。1键用法的定义:
KeyUsage ::= BIT STRING {
digitalSignature (0),
nonRepudiation (1),
keyEncipherment (2),
dataEncipherment (3),
keyAgreement (4),
keyCertSign (5),
cRLSign (6),
encipherOnly (7),
decipherOnly (8) }
代码示例来源:origin: Meituan-Dianping/walle
@Override
public boolean[] getKeyUsage() {
return mDelegate.getKeyUsage();
}
代码示例来源:origin: redisson/redisson
@Override
public boolean[] getKeyUsage() {
return unwrap().getKeyUsage();
}
代码示例来源:origin: wildfly/wildfly
@Override
public boolean[] getKeyUsage() {
return unwrap().getKeyUsage();
}
代码示例来源:origin: looly/hutool
/**
* 设置{@link Certificate} 为PublicKey<br>
* 如果Certificate是X509Certificate,我们需要检查是否有密钥扩展
*
* @param certificate {@link Certificate}
* @return this
*/
public Sign setCertificate(Certificate certificate) {
// If the certificate is of type X509Certificate,
// we should check whether it has a Key Usage
// extension marked as critical.
if (certificate instanceof java.security.cert.X509Certificate) {
// Check whether the cert has a key usage extension
// marked as a critical extension.
// The OID for KeyUsage extension is 2.5.29.15.
final X509Certificate cert = (X509Certificate) certificate;
final Set<String> critSet = cert.getCriticalExtensionOIDs();
if (CollUtil.isNotEmpty(critSet) && critSet.contains("2.5.29.15")) {
final boolean[] keyUsageInfo = cert.getKeyUsage();
// keyUsageInfo[0] is for digitalSignature.
if ((keyUsageInfo != null) && (keyUsageInfo[0] == false)) {
throw new CryptoException("Wrong key usage");
}
}
}
this.publicKey = certificate.getPublicKey();
return this;
}
}
代码示例来源:origin: looly/hutool
/**
* 设置{@link Certificate} 为PublicKey<br>
* 如果Certificate是X509Certificate,我们需要检查是否有密钥扩展
*
* @param certificate {@link Certificate}
* @return this
*/
public Sign setCertificate(Certificate certificate) {
// If the certificate is of type X509Certificate,
// we should check whether it has a Key Usage
// extension marked as critical.
if (certificate instanceof java.security.cert.X509Certificate) {
// Check whether the cert has a key usage extension
// marked as a critical extension.
// The OID for KeyUsage extension is 2.5.29.15.
final X509Certificate cert = (X509Certificate) certificate;
final Set<String> critSet = cert.getCriticalExtensionOIDs();
if (CollUtil.isNotEmpty(critSet) && critSet.contains("2.5.29.15")) {
final boolean[] keyUsageInfo = cert.getKeyUsage();
// keyUsageInfo[0] is for digitalSignature.
if ((keyUsageInfo != null) && (keyUsageInfo[0] == false)) {
throw new CryptoException("Wrong key usage");
}
}
}
this.publicKey = certificate.getPublicKey();
return this;
}
}
代码示例来源:origin: robovm/robovm
.getKeyUsage();
代码示例来源:origin: robovm/robovm
boolean[] keyUsage = ((X509Certificate) certificate).getKeyUsage();
代码示例来源:origin: robovm/robovm
boolean[] ku = cert.getKeyUsage();
if (ku != null) {
int i = 0;
代码示例来源:origin: org.eclipse.jetty/jetty-util
public static boolean isCertSign(X509Certificate x509)
{
boolean[] key_usage = x509.getKeyUsage();
if ((key_usage == null) || (key_usage.length <= KEY_USAGE__KEY_CERT_SIGN))
{
return false;
}
return key_usage[KEY_USAGE__KEY_CERT_SIGN];
}
代码示例来源:origin: io.netty/netty-handler
@Override
public boolean[] getKeyUsage() {
return unwrap().getKeyUsage();
}
代码示例来源:origin: apache/pdfbox
boolean[] keyUsage = x509Certificate.getKeyUsage();
if (keyUsage != null && !keyUsage[0] && !keyUsage[1])
代码示例来源:origin: stackoverflow.com
X509Certificate cert = ...;
boolean[] keyUsage = cert.getKeyUsage();
if ( keyUsage[5] ) {
// CA certificate
}
else {
// User certificate
}
代码示例来源:origin: org.demoiselle.signer/signature-core
/**
*
* @param cert
* X509Certificate
*/
public ICPBRKeyUsage(X509Certificate cert) {
this.keyUsage = cert.getKeyUsage();
}
代码示例来源:origin: arhs/sd-dss
/**
* @return true if the wrapped certificate has cRLSign key usage bit set
*/
public boolean hasCRLSignKeyUsage() {
final boolean[] keyUsage = x509Certificate.getKeyUsage();
final boolean crlSignKeyUsage = keyUsage != null || (keyUsage != null && keyUsage[6]);
return crlSignKeyUsage;
}
代码示例来源:origin: apache/activemq-artemis
@Override
public boolean[] getKeyUsage() {
return unwrap().getKeyUsage();
}
代码示例来源:origin: es.gob.afirma/afirma-keystores-filters
private static boolean isPseudonymFor(final X509Certificate pseudonymCert, final X509Certificate otherCert) {
if (pseudonymCert == null || otherCert == null) {
return false;
}
if (
pseudonymCert.getIssuerX500Principal().equals(otherCert.getIssuerX500Principal()) &&
compareArrays(pseudonymCert.getKeyUsage(), otherCert.getKeyUsage())
) {
return true;
}
return false;
}
代码示例来源:origin: es.gob.afirma/afirma-keystores-filters
/** Comprueba si el certificado tiene tiene un <em>KeyUsage</em> de firma (nonRepudiation).
* @param cert Certificado.
* @return {@code true} si el certificado es de firma. */
private static boolean isSignatureCert(final X509Certificate cert) {
if (cert.getKeyUsage() == null) {
return false;
}
final KeyUsagesPattern pattern = new KeyUsagesPattern(cert.getIssuerDN());
return checkKeyUsages(cert.getKeyUsage(), pattern.getSignaturePattern());
}
代码示例来源:origin: org.xipki.scep/scep-common
public static boolean hasKeyusage(X509Certificate cert, KeyUsage usage) {
boolean[] keyusage = cert.getKeyUsage();
if (keyusage != null && keyusage.length > usage.getBit()) {
return keyusage[usage.getBit()];
}
return false;
}
代码示例来源:origin: org.xipki/security
public static boolean hasKeyusage(X509Certificate cert, KeyUsage usage) {
Args.notNull(cert, "cert");
boolean[] keyusage = cert.getKeyUsage();
if (keyusage != null && keyusage.length > usage.getBit()) {
return keyusage[usage.getBit()];
}
return false;
}
代码示例来源:origin: org.xipki.tk/security
public static boolean hasKeyusage(final X509Certificate cert, final KeyUsage usage) {
ParamUtil.requireNonNull("cert", cert);
boolean[] keyusage = cert.getKeyUsage();
if (keyusage != null && keyusage.length > usage.bit()) {
return keyusage[usage.bit()];
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!