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


Java ASN1Object.fromByteArray方法代码示例

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


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

示例1: decode

import org.bouncycastle.asn1.ASN1Object; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected PublicKey decode(final byte[] encoded) throws CryptException {
	try {
		final ASN1Sequence seq = (ASN1Sequence) ASN1Object
				.fromByteArray(encoded);
		final ASN1Sequence innerSeq = (ASN1Sequence) seq.getObjectAt(0);
		final DEREncodable algId = innerSeq.getObjectAt(0);
		final String algorithm;
		if (RSA_ID.equals(algId)) {
			algorithm = "RSA";
		} else if (EC_ID.equals(algId)) {
			algorithm = "EC";
		} else if (DSA_ID.equals(algId)) {
			algorithm = "DSA";
		} else {
			throw new CryptException("Unsupported public key algorithm ID "
					+ algId);
		}
		return CryptProvider.getKeyFactory(algorithm).generatePublic(
				new X509EncodedKeySpec(encoded));
	} catch (Exception e) {
		throw new CryptException("Invalid public key.", e);
	}
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:25,代码来源:PublicKeyCredentialReader.java

示例2: getInstance

import org.bouncycastle.asn1.ASN1Object; //导入方法依赖的package包/类
/**
 * Returns an instance of <code>ProxyCertInfo</code> from given object.
 * 
 * @param obj
 *            the object to create the instance from.
 * @return <code>ProxyCertInfo</code> instance.
 * @exception IllegalArgumentException
 *                if unable to convert the object to
 *                <code>ProxyCertInfo</code> instance.
 */
public static ProxyCertInfo getInstance(Object obj) {
	if (obj instanceof ProxyCertInfo)
		return (ProxyCertInfo) obj;

	if (obj instanceof byte[]) {
		try {
			obj = ASN1Object.fromByteArray((byte[]) obj);
		} catch (IOException ignored) {
		}
	}

	if (obj instanceof ASN1Sequence)
		return new ProxyCertInfo((ASN1Sequence) obj);

	throw new IllegalArgumentException("unknown object in factory");
}
 
开发者ID:NCIP,项目名称:cagrid2,代码行数:27,代码来源:ProxyCertInfo.java

示例3: convertValueToObject

import org.bouncycastle.asn1.ASN1Object; //导入方法依赖的package包/类
/**
 * Convert the value of the passed in extension to an object
 * @param ext the extension to parse
 * @return the object the value string contains
 * @exception IllegalArgumentException if conversion is not possible
 */
public static ASN1Object convertValueToObject(
    X509Extension ext)
    throws IllegalArgumentException
{
    try
    {
        return ASN1Object.fromByteArray(ext.getValue().getOctets());
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("can't convert extension: " +  e);
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:20,代码来源:X509Extension.java

示例4: readECParameters

import org.bouncycastle.asn1.ASN1Object; //导入方法依赖的package包/类
private ECNamedCurveParameterSpec readECParameters(String endMarker)
    throws IOException
{
    DERObjectIdentifier oid = (DERObjectIdentifier)ASN1Object.fromByteArray(readBytes(endMarker));

    return ECNamedCurveTable.getParameterSpec(oid.getId());
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:8,代码来源:PEMReader.java


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