本文整理汇总了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);
}
}
示例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();
}
示例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;
}
示例4: getInstance
import org.bouncycastle.asn1.x509.SubjectKeyIdentifier; //导入方法依赖的package包/类
/**
* Return an OriginatorIdentifierOrKey object from the given object.
* <p>
* Accepted inputs:
* <ul>
* <li> null → 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());
}
示例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();
}
示例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));
}
}
示例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();
}
示例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));
}
示例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());
}
示例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);
}