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


Java AuthorityKeyIdentifier.getAuthorityCertSerialNumber方法代码示例

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


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

示例1: 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);
	}
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:21,代码来源:DAuthorityKeyIdentifier.java

示例2: 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();
}
 
开发者ID:gavioto,项目名称:portecle,代码行数:60,代码来源:X509Ext.java

示例3: 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();
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:54,代码来源:X509Ext.java

示例4: 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'; ");
        }
    }
}
 
开发者ID:xipki,项目名称:xipki,代码行数:65,代码来源:ExtensionsChecker.java


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