本文整理汇总了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();
}
示例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);
}
示例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.");
}
}
示例4: PKCS12PfxPdu
import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
public PKCS12PfxPdu(Pfx pfx)
{
this.pfx = pfx;
}
示例5: toASN1Structure
import org.bouncycastle.asn1.pkcs.Pfx; //导入依赖的package包/类
/**
* Return the underlying ASN.1 object.
*
* @return a Pfx object.
*/
public Pfx toASN1Structure()
{
return pfx;
}