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


Java Streams.drain方法代码示例

本文整理汇总了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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:RecipientInformation.java

示例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);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:CMSTimeStampedDataParser.java

示例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;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:30,代码来源:RecipientInformation.java

示例4: drain

import org.bouncycastle.util.io.Streams; //导入方法依赖的package包/类
public void drain() 
    throws IOException
{
    Streams.drain(_in);
    _in.close();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:CMSTypedStream.java

示例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");
        }
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:50,代码来源:PGPSignatureTest.java

示例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());
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:17,代码来源:ParseTest.java


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