本文整理汇总了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);
}
}
示例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");
}
示例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);
}
}
示例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());
}