当前位置: 首页>>代码示例>>Java>>正文


Java SubjectKeyIdentifier.getInstance方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.x509.SubjectKeyIdentifier.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java SubjectKeyIdentifier.getInstance方法的具体用法?Java SubjectKeyIdentifier.getInstance怎么用?Java SubjectKeyIdentifier.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.x509.SubjectKeyIdentifier的用法示例。


在下文中一共展示了SubjectKeyIdentifier.getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSki

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
/**
 * This method returns SKI bytes from certificate.
 *
 * @param certificateToken
 *            {@code CertificateToken}
 * @param computeIfMissing
 *            if the extension is missing and computeIfMissing = true, it will compute the SKI value from the Public
 *            Key
 * @return ski bytes from the given certificate
 * @throws DSSException
 */
public static byte[] getSki(final CertificateToken certificateToken, boolean computeIfMissing) throws DSSException {
	try {
		byte[] sKI = certificateToken.getCertificate().getExtensionValue(Extension.subjectKeyIdentifier.getId());
		if (Utils.isArrayNotEmpty(sKI)) {
			ASN1Primitive extension = X509ExtensionUtil.fromExtensionValue(sKI);
			SubjectKeyIdentifier skiBC = SubjectKeyIdentifier.getInstance(extension);
			return skiBC.getKeyIdentifier();
		} else if (computeIfMissing) {
			// If extension not present, we compute it from the certificate public key
			DLSequence seq = (DLSequence) DERSequence.fromByteArray(certificateToken.getPublicKey().getEncoded());
			DERBitString item = (DERBitString) seq.getObjectAt(1);
			return DSSUtils.digest(DigestAlgorithm.SHA1, item.getOctets());
		}
		return null;
	} catch (Exception e) {
		throw new DSSException(e);
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:30,代码来源:DSSASN1Utils.java

示例2: getSubjectKeyIndentifierStringValue

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
private String getSubjectKeyIndentifierStringValue(byte[] value) throws IOException {
	// @formatter:off

	/*
	 * SubjectKeyIdentifier ::= KeyIdentifier
	 *
	 * KeyIdentifier ::= OCTET STRING
	 */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	SubjectKeyIdentifier subjectKeyIdentifier = SubjectKeyIdentifier.getInstance(value);

	// Get key identifier from octet string
	byte[] keyIdentifierBytes = subjectKeyIdentifier.getKeyIdentifier();

	sb.append(MessageFormat.format(res.getString("SubjectKeyIdentifier"),
			HexUtil.getHexString(keyIdentifierBytes)));
	sb.append(NEWLINE);

	return sb.toString();
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:25,代码来源:X509Ext.java

示例3: getSubjectKeyIdentifier

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
public SubjectKeyIdentifier getSubjectKeyIdentifier()
{
    if (id instanceof ASN1TaggedObject && ((ASN1TaggedObject)id).getTagNo() == 0)
    {
        return SubjectKeyIdentifier.getInstance((ASN1TaggedObject)id, false);
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:OriginatorIdentifierOrKey.java

示例4: getInstance

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
/**
 * Return an OriginatorIdentifierOrKey object from the given object.
 * <p>
 * Accepted inputs:
 * <ul>
 * <li> null &rarr; null
 * <li> {@link OriginatorIdentifierOrKey} object
 * <li> {@link IssuerAndSerialNumber} object
 * <li> {@link org.bouncycastle.asn1.ASN1TaggedObject#getInstance(java.lang.Object) ASN1TaggedObject} input formats with IssuerAndSerialNumber structure inside
 * </ul>
 *
 * @param o the object we want converted.
 * @exception IllegalArgumentException if the object cannot be converted.
 */
public static OriginatorIdentifierOrKey getInstance(
    Object o)
{
    if (o == null || o instanceof OriginatorIdentifierOrKey)
    {
        return (OriginatorIdentifierOrKey)o;
    }

    if (o instanceof IssuerAndSerialNumber || o instanceof ASN1Sequence)
    {
        return new OriginatorIdentifierOrKey(IssuerAndSerialNumber.getInstance(o));
    }

    if (o instanceof ASN1TaggedObject)
    {
        ASN1TaggedObject tagged = (ASN1TaggedObject)o;

        if (tagged.getTagNo() == 0)
        {
            return new OriginatorIdentifierOrKey(SubjectKeyIdentifier.getInstance(tagged, false));
        }
        else if (tagged.getTagNo() == 1)
        {
            return new OriginatorIdentifierOrKey(OriginatorPublicKey.getInstance(tagged, false));
        }
    }

    throw new IllegalArgumentException("Invalid OriginatorIdentifierOrKey: " + o.getClass().getName());
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:44,代码来源:OriginatorIdentifierOrKey.java

示例5: getSubjectKeyId

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
private byte[] getSubjectKeyId(X509Certificate cert) throws IOException {
	byte[] extvalue = cert.getExtensionValue(X509Extensions.SubjectKeyIdentifier.getId());
	if (extvalue == null) {
		return null;
	}
	ASN1OctetString str = ASN1OctetString
			.getInstance(new ASN1InputStream(new ByteArrayInputStream(extvalue)).readObject());
	SubjectKeyIdentifier keyId = SubjectKeyIdentifier
			.getInstance(new ASN1InputStream(new ByteArrayInputStream(str.getOctets())).readObject());
	return keyId.getKeyIdentifier();
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:12,代码来源:TSPTimeStampService.java

示例6: checkExtensionSubjectKeyIdentifier

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
private void checkExtensionSubjectKeyIdentifier(StringBuilder failureMsg,
        byte[] extensionValue, SubjectPublicKeyInfo subjectPublicKeyInfo) {
    // subjectKeyIdentifier
    SubjectKeyIdentifier asn1 = SubjectKeyIdentifier.getInstance(extensionValue);
    byte[] ski = asn1.getKeyIdentifier();
    byte[] pkData = subjectPublicKeyInfo.getPublicKeyData().getBytes();
    byte[] expectedSki = HashAlgoType.SHA1.hash(pkData);
    if (!Arrays.equals(expectedSki, ski)) {
        addViolation(failureMsg, "SKI", hex(ski), hex(expectedSki));
    }
}
 
开发者ID:xipki,项目名称:xipki,代码行数:12,代码来源:ExtensionsChecker.java

示例7: getSubjectKeyId

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
/**
 * Get the subject key identifier from a certificate extensions
 *
 * @param cert certificate containing the extension
 * @return byte[] containing the subject key identifier
 * @throws IOException if extension can not be parsed
 */
public static byte[] getSubjectKeyId(X509Certificate cert) throws IOException {
    byte[] extvalue = cert.getExtensionValue("2.5.29.14");
    if (extvalue == null) {
        return null;
    }
    ASN1OctetString str = ASN1OctetString.getInstance(new ASN1InputStream(new ByteArrayInputStream(
        extvalue)).readObject());
    SubjectKeyIdentifier keyId = SubjectKeyIdentifier.getInstance(new ASN1InputStream(
        new ByteArrayInputStream(str.getOctets())).readObject());
    return keyId.getKeyIdentifier();
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:19,代码来源:CertTools.java

示例8: getSubjectKeyIdentifierFrom

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
private SubjectKeyIdentifier getSubjectKeyIdentifierFrom(X509Certificate certificate) throws Exception {
  byte[] extensionValue = certificate.getExtensionValue(Extension.subjectKeyIdentifier.getId());
  return extensionValue == null ?
      new SubjectKeyIdentifier(null) :
      SubjectKeyIdentifier.getInstance(parseExtensionValue(extensionValue));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:7,代码来源:SignedCertificateGenerator.java

示例9: prepopulateWithValue

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
private void prepopulateWithValue(byte[] value) throws IOException {
	SubjectKeyIdentifier subjectKeyIdentifier = SubjectKeyIdentifier.getInstance(value);

	jkiKeyIdentifier.setKeyIdentifier(subjectKeyIdentifier.getKeyIdentifier());
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:6,代码来源:DSubjectKeyIdentifier.java

示例10: getSubjectKeyIdentifierStringValue

import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
/**
 * Get Subject Key Identifier (2.5.29.14) extension value as a string.
 * 
 * <pre>
 * SubjectKeyIdentifier ::= KeyIdentifier
 * KeyIdentifier ::= OCTET STRING
 * </pre>
 * 
 * @param bValue The octet string value
 * @return Extension value as a string
 * @throws IOException If an I/O problem occurs
 */
private String getSubjectKeyIdentifierStringValue(byte[] bValue)
    throws IOException
{
	SubjectKeyIdentifier ski = SubjectKeyIdentifier.getInstance(bValue);
	byte[] bKeyIdent = ski.getKeyIdentifier();

	// Output as a hex string
	return convertToHexString(bKeyIdent);
}
 
开发者ID:gavioto,项目名称:portecle,代码行数:22,代码来源:X509Ext.java


注:本文中的org.bouncycastle.asn1.x509.SubjectKeyIdentifier.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。