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


Java DEREncodable类代码示例

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


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

示例1: dumpAsString

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Dump out the object as a string.
 *
 * @param obj  the object to be dumped
 * @param verbose  if true, dump out the contents of octet and bit strings.
 * @return  the resulting string.
 */
public static String dumpAsString(
    Object   obj,
    boolean  verbose)
{
    StringBuffer buf = new StringBuffer();

    if (obj instanceof DERObject)
    {
        _dumpAsString("", verbose, (DERObject)obj, buf);
    }
    else if (obj instanceof DEREncodable)
    {
        _dumpAsString("", verbose, ((DEREncodable)obj).getDERObject(), buf);
    }
    else
    {
        return "unknown object type " + obj.toString();
    }

    return buf.toString();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:29,代码来源:ASN1Dump.java

示例2: getSigAlgID

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
static AlgorithmIdentifier getSigAlgID(
    DERObjectIdentifier sigOid,
    String              algorithmName)
{
    if (noParams.contains(sigOid))
    {
        return new AlgorithmIdentifier(sigOid);
    }

    algorithmName = Strings.toUpperCase(algorithmName);

    if (params.containsKey(algorithmName))
    {
        return new AlgorithmIdentifier(sigOid, (DEREncodable)params.get(algorithmName));
    }
    else
    {
        return new AlgorithmIdentifier(sigOid, new DERNull());
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:21,代码来源:X509Util.java

示例3: addExtension

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Add an extension with the given oid and the passed in value to be included
 * in the OCTET STRING associated with the extension.
 *
 * @param oid  OID for the extension.
 * @param critical  true if critical, false otherwise.
 * @param value the ASN.1 object to be included in the extension.
 */
public void addExtension(
    DERObjectIdentifier oid,
    boolean             critical,
    DEREncodable        value)
{
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);

    try
    {
        dOut.writeObject(value);
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("error encoding value: " + e);
    }

    this.addExtension(oid, critical, bOut.toByteArray());
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:28,代码来源:X509ExtensionsGenerator.java

示例4: addExtension

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * add a given extension field for the standard extensions tag (tag 0)
 */
public void addExtension(
    DERObjectIdentifier OID,
    boolean             critical,
    DEREncodable        value)
{
    if (extensions == null)
    {
        extensions = new Hashtable();
        extOrdering = new Vector();
    }

    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DEROutputStream         dOut = new DEROutputStream(bOut);

    try
    {
        dOut.writeObject(value);
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("error encoding value: " + e);
    }

    this.addExtension(OID, critical, bOut.toByteArray());
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:29,代码来源:X509V2CRLGenerator.java

示例5: getObjectInTag

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
private ASN1Object getObjectInTag(int tagNo)
{
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements())
    {
        DEREncodable obj = (DEREncodable)e.nextElement();

        if (obj instanceof ASN1TaggedObject)
        {
            ASN1TaggedObject tag = (ASN1TaggedObject)obj;
            if (tag.getTagNo() == tagNo)
            {
                return (ASN1Object)((DEREncodable)tag.getObject()).getDERObject();
            }
        }
    }
    return null;
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:20,代码来源:ECPrivateKeyStructure.java

示例6: getRoleAuthorityAsString

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }
    
    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        DEREncodable value = names[i].getName();
        if(value instanceof DERString)
        {
            namesString[i] = ((DERString)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:29,代码来源:RoleSyntax.java

示例7: fromASN1Set

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Creates a new instance from an ASN.1 SET of SEQUENCE representing the
 * AttributeTypeAndValue type of section 2 of RFC 2253.
 *
 * @param set
 *            Set from which to create new RDN instance.
 *
 * @return New RDN from encoded data.
 */
public static RelativeDistinguishedName fromASN1Set(final ASN1Set set) {
	final List<AttributeTypeAndValue> values = new ArrayList<AttributeTypeAndValue>();
	for (int i = 0; i < set.size(); i++) {
		final DEREncodable value = set.getObjectAt(i);
		if (!(value instanceof ASN1Sequence)) {
			throw new IllegalArgumentException(
					"Value must be ASN.1 sequence.");
		}

		final ASN1Sequence seq = (ASN1Sequence) value;
		if (seq.size() != 2) {
			throw new IllegalArgumentException("Illegal sequence size "
					+ seq.size());
		}
		if (!(seq.getObjectAt(0) instanceof DERObjectIdentifier)) {
			throw new IllegalArgumentException(
					"First sequence item must be OID.");
		}
		values.add(new AttributeTypeAndValue(seq.getObjectAt(0).toString(),
				seq.getObjectAt(1).toString()));
	}
	return new RelativeDistinguishedName(values);
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:33,代码来源:RelativeDistinguishedName.java

示例8: createPolicyInformationList

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Creates a {@link PolicyInformationList} object from DER data.
 *
 * @param enc
 *            DER encoded policy information data; must be <code>
 * ASN1Sequence</code>.
 *
 * @return Certificate policy information listing.
 */
public static PolicyInformationList createPolicyInformationList(
		final DEREncodable enc) {
	if (!(enc instanceof ASN1Sequence)) {
		throw new IllegalArgumentException("Expected ASN1Sequence but got "
				+ enc);
	}

	final ASN1Sequence seq = (ASN1Sequence) enc;
	final List<PolicyInformation> policies = new ArrayList<PolicyInformation>(
			seq.size());
	for (int i = 0; i < seq.size(); i++) {
		policies.add(createPolicyInformation(seq.getObjectAt(i)));
	}
	return new PolicyInformationList(
			policies.toArray(new PolicyInformation[policies.size()]));
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:26,代码来源:ExtensionFactory.java

示例9: createPolicyInformation

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Creates a {@link PolicyInformation} object from DER data.
 *
 * @param enc
 *            DER encoded policy information data.
 *
 * @return Certificate policy information object.
 */
public static PolicyInformation createPolicyInformation(
		final DEREncodable enc) {
	final org.bouncycastle.asn1.x509.PolicyInformation info = org.bouncycastle.asn1.x509.PolicyInformation
			.getInstance(enc);
	final ASN1Sequence encodedQualifiers = info.getPolicyQualifiers();
	if (encodedQualifiers != null) {
		final int size = encodedQualifiers.size();
		final List<PolicyQualifierInfo> qualifiers = new ArrayList<PolicyQualifierInfo>(
				size);
		for (int i = 0; i < size; i++) {
			final DEREncodable item = encodedQualifiers.getObjectAt(i);
			qualifiers.add(createPolicyQualifierInfo(item));
		}
		return new PolicyInformation(info.getPolicyIdentifier().toString(),
				qualifiers.toArray(new PolicyQualifierInfo[size]));
	} else {
		return new PolicyInformation(info.getPolicyIdentifier().toString());
	}
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:28,代码来源:ExtensionFactory.java

示例10: createAuthorityKeyIdentifier

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * Creates a {@link AuthorityKeyIdentifier} object from DER data.
 *
 * @param enc
 *            DER encoded authority key identifier data.
 *
 * @return Authority key identifier.
 */
public static AuthorityKeyIdentifier createAuthorityKeyIdentifier(
		final DEREncodable enc) {
	final org.bouncycastle.asn1.x509.AuthorityKeyIdentifier aki = org.bouncycastle.asn1.x509.AuthorityKeyIdentifier
			.getInstance(enc);
	KeyIdentifier keyIdentifier = null;
	if (aki.getKeyIdentifier() != null) {
		keyIdentifier = new KeyIdentifier(aki.getKeyIdentifier());
	}

	GeneralNameList issuerNames = null;
	if (aki.getAuthorityCertIssuer() != null) {
		issuerNames = createGeneralNameList(aki.getAuthorityCertIssuer());
	}

	Integer issuerSerial = null;
	if (aki.getAuthorityCertSerialNumber() != null) {
		issuerSerial = aki.getAuthorityCertSerialNumber().intValue();
	}
	return new AuthorityKeyIdentifier(keyIdentifier, issuerNames,
			issuerSerial);
}
 
开发者ID:shivam091,项目名称:Java-Security,代码行数:30,代码来源:ExtensionFactory.java

示例11: decode

import org.bouncycastle.asn1.DEREncodable; //导入依赖的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

示例12: getBasicConstraints

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
    * Creates a <code>BasicConstraints</code> object from given
    * extension.
    *
    * @param ext the extension.
    * @return the <code>BasicConstraints</code> object.
    * @exception IOException if something fails.
    */
   public static BasicConstraints getBasicConstraints(X509Extension ext) 
throws IOException {
DERObject obj = BouncyCastleUtil.getExtensionObject(ext);
if (obj instanceof ASN1Sequence) {
    ASN1Sequence seq = (ASN1Sequence)obj;
    int size = seq.size();
    if (size == 0) {
	return new BasicConstraints(false);
    } else if (size == 1) {
	DEREncodable value = seq.getObjectAt(0);
	if (value instanceof DERInteger) {
	    int length = ((DERInteger)value).getValue().intValue();
	    return new BasicConstraints(false, length);
	} else if (value instanceof DERBoolean) {
	    boolean ca = ((DERBoolean)value).isTrue();
	    return new BasicConstraints(ca);
	}
    } 
}
return BasicConstraints.getInstance(obj);
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:30,代码来源:BouncyCastleUtil.java

示例13: setBagAttribute

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
public void setBagAttribute(
    DERObjectIdentifier oid,
    DEREncodable        attribute)
{
    if (pkcs12Attributes.containsKey(oid))
    {                           // preserve original ordering
        pkcs12Attributes.put(oid, attribute);
    }
    else
    {
        pkcs12Attributes.put(oid, attribute);
        pkcs12Ordering.addElement(oid);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:15,代码来源:PKCS12BagAttributeCarrierImpl.java

示例14: ContentInfo

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
public ContentInfo(
    DERObjectIdentifier contentType,
    DEREncodable        content)
{
    this.contentType = contentType;
    this.content = content;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:8,代码来源:ContentInfo.java

示例15: dumpAsString

import org.bouncycastle.asn1.DEREncodable; //导入依赖的package包/类
/**
 * dump out a DER object as a formatted string
 *
 * @param obj the DERObject to be dumped out.
 */
public static String dumpAsString(
    DEREncodable   obj)
{
    StringBuffer buf = new StringBuffer();

    _dumpAsString("", false, obj.getDERObject(), buf);

    return buf.toString();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:15,代码来源:DERDump.java


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