本文整理汇总了Java中org.bouncycastle.util.io.Streams.drain方法的典型用法代码示例。如果您正苦于以下问题:Java Streams.drain方法的具体用法?Java Streams.drain怎么用?Java Streams.drain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.util.io.Streams
的用法示例。
在下文中一共展示了Streams.drain方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMac
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
/**
* Return the MAC calculated for the recipient. Note: this call is only meaningful once all
* the content has been read.
*
* @return byte array containing the mac.
*/
public byte[] getMac()
{
if (resultMac == null)
{
if (operator.isMacBased())
{
if (additionalData != null)
{
try
{
Streams.drain(operator.getInputStream(new ByteArrayInputStream(additionalData.getAuthAttributes().getEncoded(ASN1Encoding.DER))));
}
catch (IOException e)
{
throw new IllegalStateException("unable to drain input: " + e.getMessage());
}
}
resultMac = operator.getMac();
}
}
return resultMac;
}
示例2: parseTimeStamps
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private void parseTimeStamps()
throws CMSException
{
try
{
if (util == null)
{
InputStream cont = this.getContent();
if (cont != null)
{
Streams.drain(cont);
}
util = new TimeStampDataUtil(timeStampedData);
}
}
catch (IOException e)
{
throw new CMSException("unable to parse evidence block: " + e.getMessage(), e);
}
}
示例3: getMac
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
/**
* Return the MAC calculated for the recipient. Note: this call is only meaningful once all
* the content has been read.
*
* @return byte array containing the mac.
*/
public byte[] getMac()
{
if (resultMac == null)
{
if (operator.isMacBased())
{
if (additionalData != null)
{
try
{
Streams.drain(operator.getInputStream(new ByteArrayInputStream(additionalData.getAuthAttributes().getEncoded(ASN1Encoding.DER))));
}
catch (IOException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
resultMac = operator.getMac();
}
}
return resultMac;
}
示例4: drain
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void drain()
throws IOException
{
Streams.drain(_in);
_in.close();
}
示例5: testMissingSubpackets
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private void testMissingSubpackets(byte[] signature)
throws IOException
{
PGPObjectFactory f = new PGPObjectFactory(signature);
Object obj = f.nextObject();
while (!(obj instanceof PGPSignatureList))
{
obj = f.nextObject();
if (obj instanceof PGPLiteralData)
{
InputStream in = ((PGPLiteralData)obj).getDataStream();
Streams.drain(in);
}
}
PGPSignature sig = ((PGPSignatureList)obj).get(0);
if (sig.getVersion() > 3)
{
PGPSignatureSubpacketVector v = sig.getHashedSubPackets();
if (v.getKeyExpirationTime() != 0)
{
fail("key expiration time not zero for missing subpackets");
}
if (!sig.hasSubpackets())
{
fail("hasSubpackets() returns false with packets");
}
}
else
{
if (sig.getHashedSubPackets() != null)
{
fail("hashed sub packets found when none expected");
}
if (sig.getUnhashedSubPackets() != null)
{
fail("unhashed sub packets found when none expected");
}
if (sig.hasSubpackets())
{
fail("hasSubpackets() returns true with no packets");
}
}
}
示例6: parseEnveloped
import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
private void parseEnveloped(byte[] data) throws IOException
{
ASN1StreamParser aIn = new ASN1StreamParser(data);
ContentInfoParser cP = new ContentInfoParser((ASN1SequenceParser)aIn.readObject());
EnvelopedDataParser eP = new EnvelopedDataParser((ASN1SequenceParser)cP.getContent(BERTags.SEQUENCE));
eP.getRecipientInfos().toASN1Primitive(); // Must drain the parser!
EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();
ASN1OctetStringParser content = (ASN1OctetStringParser)ecP.getEncryptedContent(BERTags.OCTET_STRING);
Streams.drain(content.getOctetStream());
}