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


Java ExtendedKeyUsage.getInstance方法代码示例

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


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

示例1: getExtendedKeyUsageStringValue

import org.bouncycastle.asn1.x509.ExtendedKeyUsage; //导入方法依赖的package包/类
/**
 * Get Extended Key Usage (2.5.29.37) extension value as a string.
 * 
 * <pre>
 * ExtendedKeyUsage ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
 * KeyPurposeId ::= OBJECT IDENTIFIER
 * </pre>
 * 
 * @param bValue The octet string value
 * @return Extension value as a string
 * @throws IOException If an I/O problem occurs
 */
private String getExtendedKeyUsageStringValue(byte[] bValue)
    throws IOException
{
	StringBuilder strBuff = new StringBuilder();

	ExtendedKeyUsage eku = ExtendedKeyUsage.getInstance(bValue);
	KeyPurposeId[] usages = eku.getUsages();

	for (KeyPurposeId usage : usages)
	{
		if (strBuff.length() != 0)
		{
			strBuff.append("<br><br>");
		}
		String sOid = usage.getId();
		String sEku = getRes(sOid, "UnrecognisedExtKeyUsageString");
		strBuff.append(MessageFormat.format(sEku, sOid));
	}

	return strBuff.toString();
}
 
开发者ID:gavioto,项目名称:portecle,代码行数:34,代码来源:X509Ext.java

示例2: addRequestedExtKeyusage

import org.bouncycastle.asn1.x509.ExtendedKeyUsage; //导入方法依赖的package包/类
private static void addRequestedExtKeyusage(List<ASN1ObjectIdentifier> usages,
        Extensions requestedExtensions, Set<ExtKeyUsageControl> usageOccs) {
    Extension extension = requestedExtensions.getExtension(Extension.extendedKeyUsage);
    if (extension == null) {
        return;
    }

    ExtendedKeyUsage reqKeyUsage =
            ExtendedKeyUsage.getInstance(extension.getParsedValue());
    for (ExtKeyUsageControl k : usageOccs) {
        if (k.isRequired()) {
            continue;
        }

        if (reqKeyUsage.hasKeyPurposeId(KeyPurposeId.getInstance(k.extKeyUsage()))) {
            usages.add(k.extKeyUsage());
        }
    }
}
 
开发者ID:xipki,项目名称:xipki,代码行数:20,代码来源:IdentifiedX509Certprofile.java

示例3: validateCertificate

import org.bouncycastle.asn1.x509.ExtendedKeyUsage; //导入方法依赖的package包/类
/**
 * Validate the passed in certificate as being of the correct type to be used
 * for time stamping. To be valid it must have an ExtendedKeyUsage extension
 * which has a key purpose identifier of id-kp-timeStamping.
 *
 * @param cert the certificate of interest.
 * @throws TSPValidationException if the certicate fails on one of the check points.
 */
public static void validateCertificate(
    X509CertificateHolder cert)
    throws TSPValidationException
{
    if (cert.toASN1Structure().getVersionNumber() != 3)
    {
        throw new IllegalArgumentException("Certificate must have an ExtendedKeyUsage extension.");
    }

    Extension ext = cert.getExtension(Extension.extendedKeyUsage);
    if (ext == null)
    {
        throw new TSPValidationException("Certificate must have an ExtendedKeyUsage extension.");
    }

    if (!ext.isCritical())
    {
        throw new TSPValidationException("Certificate must have an ExtendedKeyUsage extension marked as critical.");
    }

    ExtendedKeyUsage    extKey = ExtendedKeyUsage.getInstance(ext.getParsedValue());

    if (!extKey.hasKeyPurposeId(KeyPurposeId.id_kp_timeStamping) || extKey.size() != 1)
    {
        throw new TSPValidationException("ExtendedKeyUsage not solely time stamping.");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:36,代码来源:TSPUtil.java

示例4: validateCertificate

import org.bouncycastle.asn1.x509.ExtendedKeyUsage; //导入方法依赖的package包/类
/**
 * Validate the passed in certificate as being of the correct type to be used
 * for time stamping. To be valid it must have an ExtendedKeyUsage extension
 * which has a key purpose identifier of id-kp-timeStamping.
 *
 * @param cert the certificate of interest.
 * @throws TSPValidationException if the certificate fails on one of the check points.
 */
public static void validateCertificate(
    X509CertificateHolder cert)
    throws TSPValidationException
{
    if (cert.toASN1Structure().getVersionNumber() != 3)
    {
        throw new IllegalArgumentException("Certificate must have an ExtendedKeyUsage extension.");
    }

    Extension ext = cert.getExtension(Extension.extendedKeyUsage);
    if (ext == null)
    {
        throw new TSPValidationException("Certificate must have an ExtendedKeyUsage extension.");
    }

    if (!ext.isCritical())
    {
        throw new TSPValidationException("Certificate must have an ExtendedKeyUsage extension marked as critical.");
    }

    ExtendedKeyUsage    extKey = ExtendedKeyUsage.getInstance(ext.getParsedValue());

    if (!extKey.hasKeyPurposeId(KeyPurposeId.id_kp_timeStamping) || extKey.size() != 1)
    {
        throw new TSPValidationException("ExtendedKeyUsage not solely time stamping.");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:36,代码来源:TSPUtil.java

示例5: getExtendedKeyUsageStringValue

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

	/*
	 * ExtendedKeyUsage ::= ASN1Sequence SIZE (1..MAX) OF KeyPurposeId
	 *
	 * KeyPurposeId ::= OBJECT IDENTIFIER
	 */

	// @formatter:on

	StringBuilder sb = new StringBuilder();

	ExtendedKeyUsage extendedKeyUsage = ExtendedKeyUsage.getInstance(value);

	for (KeyPurposeId keyPurposeId : extendedKeyUsage.getUsages()) {
		String oid = keyPurposeId.getId();

		ExtendedKeyUsageType type = ExtendedKeyUsageType.resolveOid(oid);

		if (type != null) {
			sb.append(type.friendly());
		} else {
			// Unrecognised key purpose ID
			sb.append(oid);
		}

		sb.append(NEWLINE);
	}

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

示例6: prepopulateWithValue

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

	for (KeyPurposeId keyPurposeId : extendedKeyUsage.getUsages()) {
		ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) keyPurposeId.toASN1Primitive();

		ExtendedKeyUsageType type = ExtendedKeyUsageType.resolveOid(oid.getId());

		if (type == SERVER_AUTH) {
			jcbTlsWebServerAuthentication.setSelected(true);
		} else if (type == CLIENT_AUTH) {
			jcbTlsWebClientAuthentication.setSelected(true);
		} else if (type == CODE_SIGNING) {
			jcbCodeSigning.setSelected(true);
		} else if (type == DOCUMENT_SIGNING) {
			jcbDocumentSigning.setSelected(true);
		} else if (type == ADOBE_PDF_SIGNING) {
			jcbAdobePDFSigning.setSelected(true);
		} else if (type == EMAIL_PROTECTION) {
			jcbEmailProtection.setSelected(true);
		} else if (type == ENCRYPTED_FILE_SYSTEM) {
			jcbEncryptedFileSystem.setSelected(true);
		} else if (type == IPSEC_END_SYSTEM) {
			jcbIpSecurityEndSystem.setSelected(true);
		} else if (type == IPSEC_TUNNEL) {
			jcbIpSecurityTunnelTermination.setSelected(true);
		} else if (type == IPSEC_USER) {
			jcbIpSecurityUser.setSelected(true);
		} else if (type == SMARTCARD_LOGON) {
			jcbSmartcardLogon.setSelected(true);
		} else if (type == TIME_STAMPING) {
			jcbTimeStamping.setSelected(true);
		} else if (type == OCSP_SIGNING) {
			jcbOcspStamping.setSelected(true);
		} else if (type == ANY_EXTENDED_KEY_USAGE) {
			jcbAnyExtendedKeyUsage.setSelected(true);
		}
	}
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:40,代码来源:DExtendedKeyUsage.java

示例7: validateCertificate

import org.bouncycastle.asn1.x509.ExtendedKeyUsage; //导入方法依赖的package包/类
/**
 * Validate the passed in certificate as being of the correct type to be used
 * for time stamping. To be valid it must have an ExtendedKeyUsage extension
 * which has a key purpose identifier of id-kp-timeStamping.
 * 
 * @param cert the certificate of interest.
 * @throws TSPValidationException if the certicate fails on one of the check points.
 */
public static void validateCertificate(
    X509Certificate cert)
    throws TSPValidationException
{
    if (cert.getVersion() != 3)
    {
        throw new IllegalArgumentException("Certificate must have an ExtendedKeyUsage extension.");
    }
    
    byte[]  ext = cert.getExtensionValue(X509Extensions.ExtendedKeyUsage.getId());
    if (ext == null)
    {
        throw new TSPValidationException("Certificate must have an ExtendedKeyUsage extension.");
    }
    
    if (!cert.getCriticalExtensionOIDs().contains(X509Extensions.ExtendedKeyUsage.getId()))
    {
        throw new TSPValidationException("Certificate must have an ExtendedKeyUsage extension marked as critical.");
    }

    ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(ext));

    try
    {
        aIn = new ASN1InputStream(new ByteArrayInputStream(((ASN1OctetString)aIn.readObject()).getOctets()));
        
        ExtendedKeyUsage    extKey = ExtendedKeyUsage.getInstance(aIn.readObject());
        
        if (!extKey.hasKeyPurposeId(KeyPurposeId.id_kp_timeStamping) || extKey.size() != 1)
        {
            throw new TSPValidationException("ExtendedKeyUsage not solely time stamping.");
        }
    }
    catch (IOException e)
    {
        throw new TSPValidationException("cannot process ExtendedKeyUsage extension");
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:47,代码来源:TSPUtil.java


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