本文整理汇总了Java中org.bouncycastle.asn1.x509.AuthorityKeyIdentifier.getKeyIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java AuthorityKeyIdentifier.getKeyIdentifier方法的具体用法?Java AuthorityKeyIdentifier.getKeyIdentifier怎么用?Java AuthorityKeyIdentifier.getKeyIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x509.AuthorityKeyIdentifier
的用法示例。
在下文中一共展示了AuthorityKeyIdentifier.getKeyIdentifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthorityKeyId
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
private byte[] getAuthorityKeyId(X509Certificate cert) throws IOException {
byte[] extvalue = cert.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
if (extvalue == null) {
return null;
}
DEROctetString oct = (DEROctetString) (new ASN1InputStream(new ByteArrayInputStream(extvalue)).readObject());
AuthorityKeyIdentifier keyId = new AuthorityKeyIdentifier(
(ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(oct.getOctets())).readObject());
return keyId.getKeyIdentifier();
}
示例2: prepopulateWithValue
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
private void prepopulateWithValue(byte[] value) throws IOException {
AuthorityKeyIdentifier authorityKeyIdentifier = AuthorityKeyIdentifier.getInstance(value);
if (authorityKeyIdentifier.getKeyIdentifier() != null) {
jkiKeyIdentifier.setKeyIdentifier(authorityKeyIdentifier.getKeyIdentifier());
}
GeneralNames authorityCertIssuer = authorityKeyIdentifier.getAuthorityCertIssuer();
if (authorityCertIssuer != null) {
jgnAuthorityCertIssuer.setGeneralNames(authorityCertIssuer);
}
BigInteger authorityCertSerialNumber = authorityKeyIdentifier.getAuthorityCertSerialNumber();
if (authorityCertSerialNumber != null) {
jtfAuthorityCertSerialNumber.setText("" + authorityCertSerialNumber.longValue());
jtfAuthorityCertSerialNumber.setCaretPosition(0);
}
}
示例3: extractAki
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
public static byte[] extractAki(X509Certificate cert) throws CertificateEncodingException {
byte[] extValue = getCoreExtValue(cert, Extension.authorityKeyIdentifier);
if (extValue == null) {
return null;
}
try {
AuthorityKeyIdentifier aki = AuthorityKeyIdentifier.getInstance(extValue);
return aki.getKeyIdentifier();
} catch (IllegalArgumentException ex) {
throw new CertificateEncodingException("invalid extension AuthorityKeyIdentifier: "
+ ex.getMessage());
}
}
示例4: KeyIdentifierImpl
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
public KeyIdentifierImpl(X509Certificate cert) throws CertificateException, IOException {
byte[] extVal = cert.getExtensionValue(Extension.authorityKeyIdentifier.getId());
if (extVal == null) {
lock = true;
return;
}
AuthorityKeyIdentifier aki = AuthorityKeyIdentifier.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
keyIdentifier = aki.getKeyIdentifier();
}
示例5: getAuthorityKeyId
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
/**
* Get the authority key identifier from a certificate extensions
*
* @param cert certificate containing the extension
* @return byte[] containing the authority key identifier
* @throws IOException if extension can not be parsed
*/
public static byte[] getAuthorityKeyId(X509Certificate cert) throws IOException {
byte[] extvalue = cert.getExtensionValue("2.5.29.35");
if (extvalue == null) {
return null;
}
DEROctetString oct = (DEROctetString) (new ASN1InputStream(new ByteArrayInputStream(extvalue))
.readObject());
AuthorityKeyIdentifier keyId = new AuthorityKeyIdentifier((ASN1Sequence) new ASN1InputStream(
new ByteArrayInputStream(oct.getOctets())).readObject());
return keyId.getKeyIdentifier();
}
示例6: getTrustAnchors
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
protected Collection getTrustAnchors(X509Certificate cert, Set trustanchors) throws CertPathReviewerException
{
Collection trustColl = new ArrayList();
Iterator it = trustanchors.iterator();
X509CertSelector certSelectX509 = new X509CertSelector();
try
{
certSelectX509.setSubject(getEncodedIssuerPrincipal(cert).getEncoded());
byte[] ext = cert.getExtensionValue(X509Extensions.AuthorityKeyIdentifier.getId());
if (ext != null)
{
ASN1OctetString oct = (ASN1OctetString)ASN1Primitive.fromByteArray(ext);
AuthorityKeyIdentifier authID = AuthorityKeyIdentifier.getInstance(ASN1Primitive.fromByteArray(oct.getOctets()));
certSelectX509.setSerialNumber(authID.getAuthorityCertSerialNumber());
byte[] keyID = authID.getKeyIdentifier();
if (keyID != null)
{
certSelectX509.setSubjectKeyIdentifier(new DEROctetString(keyID).getEncoded());
}
}
}
catch (IOException ex)
{
ErrorBundle msg = new ErrorBundle(RESOURCE_NAME,"CertPathReviewer.trustAnchorIssuerError");
throw new CertPathReviewerException(msg);
}
while (it.hasNext())
{
TrustAnchor trust = (TrustAnchor) it.next();
if (trust.getTrustedCert() != null)
{
if (certSelectX509.match(trust.getTrustedCert()))
{
trustColl.add(trust);
}
}
else if (trust.getCAName() != null && trust.getCAPublicKey() != null)
{
X500Principal certIssuer = getEncodedIssuerPrincipal(cert);
X500Principal caName = new X500Principal(trust.getCAName());
if (certIssuer.equals(caName))
{
trustColl.add(trust);
}
}
}
return trustColl;
}
示例7: getAuthorityKeyIdentifierStringValue
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
/**
* Get Authority Key Identifier (2.5.29.35) extension value as a string.
*
* <pre>
* AuthorityKeyIdentifier ::= SEQUENCE {
* keyIdentifier [0] KeyIdentifier OPTIONAL,
* authorityCertIssuer [1] Names OPTIONAL,
* authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL }
* KeyIdentifier ::= OCTET STRING
* GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
* CertificateSerialNumber ::= INTEGER
* </pre>
*
* @param bValue The octet string value
* @return Extension value as a string
* @throws IOException If an I/O problem occurs
*/
private String getAuthorityKeyIdentifierStringValue(byte[] bValue)
throws IOException
{
AuthorityKeyIdentifier aki = AuthorityKeyIdentifier.getInstance(bValue);
StringBuilder strBuff = new StringBuilder();
byte[] keyIdentifier = aki.getKeyIdentifier();
if (keyIdentifier != null)
{
strBuff.append(RB.getString("KeyIdentifier"));
strBuff.append(": ");
strBuff.append(convertToHexString(keyIdentifier));
strBuff.append("<br>");
}
GeneralNames authorityCertIssuer;
if ((authorityCertIssuer = aki.getAuthorityCertIssuer()) != null)
{
if (strBuff.length() != 0)
{
strBuff.append("<br>");
}
strBuff.append("<ul><li>");
strBuff.append(RB.getString("CertificateIssuer"));
strBuff.append(": ");
strBuff.append(getGeneralNamesString(authorityCertIssuer, LinkClass.BROWSER));
strBuff.append("</li></ul>");
}
BigInteger serialNo;
if ((serialNo = aki.getAuthorityCertSerialNumber()) != null)
{
if (strBuff.length() != 0)
{
strBuff.append("<br>");
}
strBuff.append(MessageFormat.format(RB.getString("CertificateSerialNumber"), serialNo));
}
return strBuff.toString();
}
示例8: getAuthorityKeyIdentifierStringValue
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
private String getAuthorityKeyIdentifierStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* AuthorityKeyIdentifier ::= ASN1Sequence { keyIdentifier [0]
* KeyIdentifier OPTIONAL, authorityCertIssuer [1] GeneralNames
* OPTIONAL, authorityCertSerialNumber [2] CertificateSerialNumber
* OPTIONAL }
*
* KeyIdentifier ::= OCTET STRING
*
* GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
*
* CertificateSerialNumber ::= ASN1Integer
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
AuthorityKeyIdentifier authorityKeyIdentifier = AuthorityKeyIdentifier.getInstance(value);
byte[] keyIdentifier = authorityKeyIdentifier.getKeyIdentifier();
GeneralNames authorityCertIssuer = authorityKeyIdentifier.getAuthorityCertIssuer();
BigInteger certificateSerialNumber = authorityKeyIdentifier.getAuthorityCertSerialNumber();
if (keyIdentifier != null) { // Optional
// Output as a hex string
sb.append(MessageFormat.format(res.getString("AuthorityKeyIdentifier"),
HexUtil.getHexString(keyIdentifier)));
sb.append(NEWLINE);
}
if (authorityCertIssuer != null) { // Optional
sb.append(res.getString("CertificateIssuer"));
sb.append(NEWLINE);
for (GeneralName generalName : authorityCertIssuer.getNames()) {
sb.append(INDENT);
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
}
if (certificateSerialNumber != null) { // Optional
// Output as an integer
sb.append(MessageFormat.format(res.getString("CertificateSerialNumber"),
HexUtil.getHexString(certificateSerialNumber)));
sb.append(NEWLINE);
}
return sb.toString();
}
示例9: checkExtensionIssuerKeyIdentifier
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier; //导入方法依赖的package包/类
private void checkExtensionIssuerKeyIdentifier(StringBuilder failureMsg,
byte[] extensionValue, X509IssuerInfo issuerInfo) {
AuthorityKeyIdentifier asn1 = AuthorityKeyIdentifier.getInstance(extensionValue);
byte[] keyIdentifier = asn1.getKeyIdentifier();
if (keyIdentifier == null) {
failureMsg.append("keyIdentifier is 'absent' but expected 'present'; ");
} else if (!Arrays.equals(issuerInfo.subjectKeyIdentifier(), keyIdentifier)) {
addViolation(failureMsg, "keyIdentifier", hex(keyIdentifier),
hex(issuerInfo.subjectKeyIdentifier()));
}
BigInteger serialNumber = asn1.getAuthorityCertSerialNumber();
GeneralNames names = asn1.getAuthorityCertIssuer();
if (certProfile.isIncludeIssuerAndSerialInAki()) {
if (serialNumber == null) {
failureMsg.append("authorityCertSerialNumber is 'absent' but expected 'present'; ");
} else {
if (!issuerInfo.cert().getSerialNumber().equals(serialNumber)) {
addViolation(failureMsg, "authorityCertSerialNumber",
LogUtil.formatCsn(serialNumber),
LogUtil.formatCsn(issuerInfo.cert().getSerialNumber()));
}
}
if (names == null) {
failureMsg.append("authorityCertIssuer is 'absent' but expected 'present'; ");
} else {
GeneralName[] genNames = names.getNames();
X500Name x500GenName = null;
for (GeneralName genName : genNames) {
if (genName.getTagNo() != GeneralName.directoryName) {
continue;
}
if (x500GenName != null) {
failureMsg.append("authorityCertIssuer contains at least two ");
failureMsg.append("directoryName but expected one; ");
break;
} else {
x500GenName = (X500Name) genName.getName();
}
}
if (x500GenName == null) {
failureMsg.append(
"authorityCertIssuer does not contain directoryName but expected one; ");
} else {
X500Name caSubject = issuerInfo.bcCert().getTBSCertificate().getSubject();
if (!caSubject.equals(x500GenName)) {
addViolation(failureMsg, "authorityCertIssuer", x500GenName, caSubject);
}
}
}
} else {
if (serialNumber != null) {
failureMsg.append("authorityCertSerialNumber is 'absent' but expected 'present'; ");
}
if (names != null) {
failureMsg.append("authorityCertIssuer is 'absent' but expected 'present'; ");
}
}
}