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


Java AuthorityKeyIdentifier.getKeyIdentifier方法代码示例

本文整理汇总了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();
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:11,代码来源:TSPTimeStampService.java

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

示例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());
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:15,代码来源:X509Util.java

示例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();
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:10,代码来源:KeyIdentifierImpl.java

示例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();
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:19,代码来源:CertTools.java

示例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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:54,代码来源:PKIXCertPathReviewer.java

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

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

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


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