本文整理汇总了Java中org.bouncycastle.asn1.DEROutputStream.writeObject方法的典型用法代码示例。如果您正苦于以下问题:Java DEROutputStream.writeObject方法的具体用法?Java DEROutputStream.writeObject怎么用?Java DEROutputStream.writeObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.DEROutputStream
的用法示例。
在下文中一共展示了DEROutputStream.writeObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSignatureBlock
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
private static byte[] generateSignatureBlock(
SignerConfig signerConfig, byte[] signatureFileBytes)
throws InvalidKeyException, CertificateEncodingException, SignatureException {
JcaCertStore certs = new JcaCertStore(signerConfig.certificates);
X509Certificate signerCert = signerConfig.certificates.get(0);
String jcaSignatureAlgorithm =
getJcaSignatureAlgorithm(
signerCert.getPublicKey(), signerConfig.signatureDigestAlgorithm);
try {
ContentSigner signer =
new JcaContentSignerBuilder(jcaSignatureAlgorithm)
.build(signerConfig.privateKey);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
gen.addSignerInfoGenerator(
new SignerInfoGeneratorBuilder(
new JcaDigestCalculatorProviderBuilder().build(),
SignerInfoSignatureAlgorithmFinder.INSTANCE)
.setDirectSignature(true)
.build(signer, new JcaX509CertificateHolder(signerCert)));
gen.addCertificates(certs);
CMSSignedData sigData =
gen.generate(new CMSProcessableByteArray(signatureFileBytes), false);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded())) {
DEROutputStream dos = new DEROutputStream(out);
dos.writeObject(asn1.readObject());
}
return out.toByteArray();
} catch (OperatorCreationException | CMSException | IOException e) {
throw new SignatureException("Failed to generate signature", e);
}
}
示例2: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
public byte[] getEncoded()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
try
{
dOut.writeObject(info);
dOut.close();
}
catch (IOException e)
{
throw new RuntimeException("Error encoding RSA public key");
}
return bOut.toByteArray();
}
示例3: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
public byte[] getEncoded()
throws CRLException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
dOut.writeObject(c);
return bOut.toByteArray();
}
catch (IOException e)
{
throw new CRLException(e.toString());
}
}
示例4: getTBSCertList
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
public byte[] getTBSCertList()
throws CRLException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
dOut.writeObject(c.getTBSCertList());
return bOut.toByteArray();
}
catch (IOException e)
{
throw new CRLException(e.toString());
}
}
示例5: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* return a DER encoded byte array representing this object
*/
public byte[] getEncoded()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
dOut.writeObject(this);
}
catch (IOException e)
{
throw new RuntimeException(e.toString());
}
return bOut.toByteArray();
}
示例6: addExtension
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的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());
}
示例7: addExtension
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的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());
}
示例8: getSigAlgParams
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
public byte[] getSigAlgParams()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
if ( c.getSignatureAlgorithm().getParameters() != null )
{
try
{
DEROutputStream dOut = new DEROutputStream(bOut);
dOut.writeObject(c.getSignatureAlgorithm().getParameters());
}
catch (Exception e)
{
throw new RuntimeException("exception getting sig parameters " + e);
}
return bOut.toByteArray();
}
return null;
}
示例9: respondExiting
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* @param s
* @throws Exception
*/
protected void respondExiting(Socket s)
throws Exception
{
OutputStream sOut = s.getOutputStream();
DEROutputStream aOut = new DEROutputStream(sOut);
// TODO: NodeInfo actually is the first object in the protocol
aOut.writeObject(new MessageReply(MessageReply.Type.EXITING));
aOut.flush();
aOut.close();
s.close();
}
示例10: derEncode
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
private byte[] derEncode(
BigInteger r,
BigInteger s)
throws IOException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERInteger(r));
v.add(new DERInteger(s));
dOut.writeObject(new DERSequence(v));
return bOut.toByteArray();
}
示例11: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
public byte[] getEncoded()
throws CRLException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
dOut.writeObject(c);
return bOut.toByteArray();
}
catch (IOException e)
{
throw new CRLException(e.toString());
}
}
示例12: testBigIntegerMessage_1
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
@Test
public void testBigIntegerMessage_1()
throws Exception
{
BigIntegerMessage msg = new BigIntegerMessage(BigInteger.valueOf(Long.MAX_VALUE));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DEROutputStream derOut = new DEROutputStream(bos);
derOut.writeObject(msg.toASN1Primitive());
ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
ASN1InputStream din = new ASN1InputStream(bin);
BigIntegerMessage res = BigIntegerMessage.getInstance(din.readObject());
TestCase.assertEquals(msg.getValue(), res.getValue());
}
示例13: testPermuteAndMoveRoundTrip_1
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
@Test
public void testPermuteAndMoveRoundTrip_1()
throws Exception
{
PermuteAndMoveMessage msg = new PermuteAndMoveMessage(1, "Cat", 0, "Doc", "Fish", "Rabbit");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DEROutputStream derOut = new DEROutputStream(bos);
derOut.writeObject(msg.toASN1Primitive());
ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
ASN1InputStream din = new ASN1InputStream(bin);
PermuteAndMoveMessage res = PermuteAndMoveMessage.getInstance(din.readObject());
TestCase.assertEquals(msg.getBoardName(), res.getBoardName());
TestCase.assertEquals(msg.getDestinationNode(), res.getDestinationNode());
TestCase.assertEquals(msg.getKeyID(), res.getKeyID());
TestCase.assertEquals(msg.getTransformName(), res.getTransformName());
}
示例14: engineGetEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
protected byte[] engineGetEncoded()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
dOut.writeObject(params);
}
catch (IOException e)
{
throw new RuntimeException("Oooops! " + e.toString());
}
return bOut.toByteArray();
}
示例15: engineGetEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* in the abscence of a standard way of doing it this will do for
* now...
*/
protected byte[] engineGetEncoded()
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
try
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString(currentSpec.getDerivationV()));
v.add(new DEROctetString(currentSpec.getEncodingV()));
v.add(new DERInteger(currentSpec.getMacKeySize()));
dOut.writeObject(new DERSequence(v));
dOut.close();
}
catch (IOException e)
{
throw new RuntimeException("Error encoding IESParameters");
}
return bOut.toByteArray();
}