本文整理汇总了Java中org.bouncycastle.asn1.DEROutputStream.close方法的典型用法代码示例。如果您正苦于以下问题:Java DEROutputStream.close方法的具体用法?Java DEROutputStream.close怎么用?Java DEROutputStream.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.DEROutputStream
的用法示例。
在下文中一共展示了DEROutputStream.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: PolicyQualifierInfo
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Creates an instance of <code>PolicyQualifierInfo</code> from the
* encoded bytes. The encoded byte array is copied on construction.<br />
* <br />
* Uses {@link org.bouncycastle.asn1.ASN1InputStream ASN1InputStream},
* {@link org.bouncycastle.asn1.ASN1Sequence ASN1Sequence},
* {@link org.bouncycastle.asn1.ASN1ObjectIdentifier ASN1ObjectIdentifier} and
* {@link org.bouncycastle.asn1.DEROutputStream DEROutputStream}
*
* @param encoded
* a byte array containing the qualifier in DER encoding
*
* @exception IOException
* thrown if the byte array does not represent a valid and
* parsable policy qualifier
*/
public PolicyQualifierInfo(byte[] encoded) throws IOException
{
this.encoded = (byte[])encoded.clone();
try
{
ByteArrayInputStream inStream = new ByteArrayInputStream(
this.encoded);
ASN1InputStream derInStream = new ASN1InputStream(inStream);
ASN1Sequence obj = (ASN1Sequence)derInStream.readObject();
id = ((ASN1ObjectIdentifier)obj.getObjectAt(0)).getId();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DEROutputStream derOutStream = new DEROutputStream(outStream);
derOutStream.writeObject(obj.getObjectAt(1));
derOutStream.close();
qualifier = outStream.toByteArray();
}
catch (Exception ex)
{
throw new IOException("parsing exception : " + ex.toString());
}
}
示例4: parseRfc822
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Parse the given rfc822 addr-spec into DER encoded byte array
* representation.
*
* @param the
* rfc822 addr-spec in well known String format
*
* @return the rfc822 addr-spec as byte array
*
* @exception IOException
* if the String could not be parsed
*/
private static byte[] parseRfc822(String data) throws IOException
{
int tmpInt = data.indexOf('@');
if (tmpInt < 0 || tmpInt >= data.length() - 1)
{
throw new IOException("wrong format of rfc822Name:" + data);
}
// TODO more test for illegal charateers
ASN1Object derData = new DERIA5String(data);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DEROutputStream derOutStream = new DEROutputStream(outStream);
derOutStream.writeObject(derData);
derOutStream.close();
return outStream.toByteArray();
}
示例5: derEncodeToStream
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
static void derEncodeToStream(ASN1Encodable obj, OutputStream stream)
{
DEROutputStream dOut = new DEROutputStream(stream);
try
{
dOut.writeObject(obj);
dOut.close();
}
catch (IOException e)
{
throw new CRMFRuntimeException("unable to DER encode object: " + e.getMessage(), e);
}
}
示例6: derEncodeToStream
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
static void derEncodeToStream(ASN1Encodable obj, OutputStream stream)
{
DEROutputStream dOut = new DEROutputStream(stream);
try
{
dOut.writeObject(obj);
dOut.close();
}
catch (IOException e)
{
throw new CMPRuntimeException("unable to DER encode object: " + e.getMessage(), e);
}
}
示例7: writeSignatureBlock
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Write the certificate file with a digital signature.
*/
private void writeSignatureBlock(CMSTypedData data,
X509Certificate publicKey,
PrivateKey privateKey) throws IOException, CertificateEncodingException, OperatorCreationException, CMSException {
ArrayList<X509Certificate> certList = new ArrayList<X509Certificate>();
certList.add(publicKey);
JcaCertStore certs = new JcaCertStore(certList);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1with" +
privateKey.getAlgorithm()).build(
privateKey);
gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder()
.build()).setDirectSignature(
true).build(sha1Signer, publicKey));
gen.addCertificates(certs);
CMSSignedData sigData = gen.generate(data, false);
ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded());
DEROutputStream dos = new DEROutputStream(mOutputJar);
dos.writeObject(asn1.readObject());
dos.flush();
dos.close();
asn1.close();
}
示例8: encodeMechs
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* @param mechs
* @return
* @throws CIFSException
*/
private static byte[] encodeMechs ( ASN1ObjectIdentifier[] mechs ) throws CIFSException {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DEROutputStream dos = new DEROutputStream(bos);
dos.writeObject(new DERSequence(mechs));
dos.close();
return bos.toByteArray();
}
catch ( IOException e ) {
throw new CIFSException("Failed to encode mechList", e);
}
}
示例9: writeSignatureBlock
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/** Write the certificate file with a digital signature. */
private void writeSignatureBlock(CMSTypedData data, X509Certificate publicKey,
PrivateKey privateKey)
throws IOException,
CertificateEncodingException,
OperatorCreationException,
CMSException {
ArrayList<X509Certificate> certList = new ArrayList<X509Certificate>();
certList.add(publicKey);
JcaCertStore certs = new JcaCertStore(certList);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
ContentSigner sha1Signer = new JcaContentSignerBuilder(
"SHA1with" + privateKey.getAlgorithm())
.build(privateKey);
gen.addSignerInfoGenerator(
new JcaSignerInfoGeneratorBuilder(
new JcaDigestCalculatorProviderBuilder()
.build())
.setDirectSignature(true)
.build(sha1Signer, publicKey));
gen.addCertificates(certs);
CMSSignedData sigData = gen.generate(data, false);
ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded());
DEROutputStream dos = new DEROutputStream(mOutputJar);
dos.writeObject(asn1.readObject());
dos.flush();
dos.close();
asn1.close();
}
示例10: getBytes
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
public byte[] getBytes() throws DSSException {
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
final DEROutputStream derOutputStream = new DEROutputStream(output);
final byte[] encoded = signedData.getEncoded();
final ASN1Primitive asn1Primitive = DSSASN1Utils.toASN1Primitive(encoded);
derOutputStream.writeObject(asn1Primitive);
derOutputStream.close();
return output.toByteArray();
} catch (IOException e) {
throw new DSSException(e);
}
}
示例11: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Gets encoded bytes of this object
* @return the bytes of ContentInfo
* @throws SmartCardException
*/
public byte[] getEncoded() throws SmartCardException {
try {
final ByteArrayOutputStream bOut = new ByteArrayOutputStream();
final DEROutputStream dout = new DEROutputStream(bOut);
dout.writeObject(toASN1Object());
dout.close();
return bOut.toByteArray();
} catch (IOException ex) {
throw new SmartCardException(ExceptionSupport.getValue("IOException"), ex);
}
}
示例12: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Returns the encoded form of this certification path, using
* the specified encoding.
*
* <b>TODO: implement PKCS7 decoding</b>
*
* @param encoding the name of the encoding to use
* @return the encoded bytes
* @exception CertificateEncodingException if an encoding error
* occurs or the encoding requested is not supported
*
**/
public byte[] getEncoded(String encoding)
throws CertificateEncodingException
{
DERObject encoded = null;
if ( encoding.equals("PkiPath") )
{
ASN1EncodableVector v = new ASN1EncodableVector();
// TODO check ListIterator implementation for JDK 1.1
ListIterator iter = certificates.listIterator(certificates.size());
while ( iter.hasPrevious() )
{
v.add(getEncodedX509Certificate((X509Certificate)iter.previous()));
}
encoded = new DERSequence(v);
}
else
throw new CertificateEncodingException( "unsupported encoding" );
if ( encoded == null )
return null;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DEROutputStream derOutStream = new DEROutputStream(outStream);
try {
derOutStream.writeObject( encoded );
derOutStream.close();
} catch ( IOException ex ) {
throw new CertificateEncodingException( "IOExeption thrown: " + ex.toString() );
}
return outStream.toByteArray();
}
示例13: getSequence
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
private byte[] getSequence(byte[] init, MessageChooser chooser)
throws Exception
{
CMSSignedDataParser cmsParser = new CMSSignedDataParser(new BcDigestCalculatorProvider(), new ByteArrayInputStream(init));
ASN1InputStream aIn = new ASN1InputStream(cmsParser.getSignedContent().getContentStream());
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
CMSSignedDataStreamGenerator cmsGen = new CMSSignedDataStreamGenerator();
OutputStream outputStream = cmsGen.open(bOut, true);
DEROutputStream dOut = new DEROutputStream(outputStream);
ASN1Primitive obj;
int count = 0;
while ((obj = aIn.readObject()) != null)
{
if (chooser.chooseMessage(count++))
{
dOut.writeObject(obj);
}
}
dOut.close();
cmsParser.close();
outputStream.close();
return bOut.toByteArray();
}
示例14: engineGetEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
*/
protected byte[] engineGetEncoded()
throws IOException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
PSSParameterSpec pssSpec = (PSSParameterSpec)currentSpec;
RSASSAPSSparams pssP = new RSASSAPSSparams(RSASSAPSSparams.DEFAULT_HASH_ALGORITHM, RSASSAPSSparams.DEFAULT_MASK_GEN_FUNCTION, new ASN1Integer(pssSpec.getSaltLength()), RSASSAPSSparams.DEFAULT_TRAILER_FIELD);
dOut.writeObject(pssP);
dOut.close();
return bOut.toByteArray();
}
示例15: getEncoded
import org.bouncycastle.asn1.DEROutputStream; //导入方法依赖的package包/类
/**
* Returns the ASN.1 encoding of this object.
*
* @returns the ASN.1 encoding.
* @throws IOException if error occurs when constructing its ASN.1 encoding.
*/
public byte[] getEncoded()
throws IOException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dOut = new DEROutputStream(bOut);
dOut.writeObject(infoObj);
dOut.close();
return bOut.toByteArray();
}