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


Java Pfx类代码示例

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


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

示例1: convertToDefiniteLength

import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
/**
 * Just re-encode the outer layer of the PKCS#12 file to definite length encoding.
 *
 * @param berPKCS12File - original PKCS#12 file
 * @return a byte array representing the DER encoding of the PFX structure
 * @throws IOException
 */
public static byte[] convertToDefiniteLength(byte[] berPKCS12File)
    throws IOException
{
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);

    Pfx pfx = Pfx.getInstance(berPKCS12File);

    bOut.reset();

    dOut.writeObject(pfx);

    return bOut.toByteArray();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:PKCS12Util.java

示例2: build

import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
/**
 * Build the Pfx structure, protecting it with a MAC calculated against the passed in password.
 *
 * @param macCalcBuilder a builder for a PKCS12 mac calculator.
 * @param password the password to use.
 * @return a Pfx object.
 * @throws PKCSException on a encoding or processing error.
 */
public PKCS12PfxPdu build(PKCS12MacCalculatorBuilder macCalcBuilder, char[] password)
    throws PKCSException
{
    AuthenticatedSafe auth = AuthenticatedSafe.getInstance(new DLSequence(dataVector));
    byte[]            encAuth;

    try
    {
        encAuth = auth.getEncoded();
    }
    catch (IOException e)
    {
        throw new PKCSException("unable to encode AuthenticatedSafe: " + e.getMessage(), e);
    }

    ContentInfo       mainInfo = new ContentInfo(PKCSObjectIdentifiers.data, new DEROctetString(encAuth));
    MacData           mData = null;

    if (macCalcBuilder != null)
    {
        MacDataGenerator mdGen = new MacDataGenerator(macCalcBuilder);

        mData = mdGen.build(password, encAuth);
    }

    //
    // output the Pfx
    //
    Pfx pfx = new Pfx(mainInfo, mData);

    return new PKCS12PfxPdu(pfx);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:41,代码来源:PKCS12PfxPduBuilder.java

示例3: performTest

import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
public void performTest()
    throws Exception
{
    testPKCS12Store();
    testGOSTStore();

    // converter tests

    KeyStore kS = KeyStore.getInstance("PKCS12", "BC");

    byte[] data = PKCS12Util.convertToDefiniteLength(pkcs12);
    kS.load(new ByteArrayInputStream(data), passwd);     // check MAC

    ASN1Encodable obj = new ASN1StreamParser(data).readObject();
    if (!(obj instanceof DERSequenceParser))
    {
        fail("Failed DER conversion test.");
    }

    data = PKCS12Util.convertToDefiniteLength(pkcs12, passwd, "BC");
    kS.load(new ByteArrayInputStream(data), passwd); //check MAC

    obj = new ASN1StreamParser(data).readObject();
    if (!(obj instanceof DERSequenceParser))
    {
        fail("Failed deep DER conversion test - outer.");
    }

    Pfx pfx = Pfx.getInstance(obj);

    obj = new ASN1StreamParser(ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets()).readObject();
    if (!(obj instanceof DERSequenceParser))
    {
        fail("Failed deep DER conversion test - inner.");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:37,代码来源:PKCS12StoreTest.java

示例4: PKCS12PfxPdu

import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
public PKCS12PfxPdu(Pfx pfx)
{
    this.pfx = pfx;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:PKCS12PfxPdu.java

示例5: toASN1Structure

import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
/**
 * Return the underlying ASN.1 object.
 *
 * @return a Pfx object.
 */
public Pfx toASN1Structure()
{
    return pfx;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:PKCS12PfxPdu.java


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