Java 类org.bouncycastle.asn1.BERSet 实例源码

项目:ipack    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:ipack    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:gwt-crypto    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:gwt-crypto    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:Aki-SSL    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:Aki-SSL    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:TinyTravelTracker    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:CryptMeme    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:irma_future_id    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:irma_future_id    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:irma_future_id    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:bc-java    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:bc-java    文件:CMSEnvelopedDataStreamGenerator.java   
public void close()
    throws IOException
{
    _out.close();
    _eiGen.close();

    if (unprotectedAttributeGenerator != null)
    {
        AttributeTable attrTable = unprotectedAttributeGenerator.getAttributes(new HashMap());

        ASN1Set unprotectedAttrs = new BERSet(attrTable.toASN1EncodableVector());

        _envGen.addObject(new DERTaggedObject(false, 1, unprotectedAttrs));
    }

    _envGen.close();
    _cGen.close();
}
项目:bc-java    文件:SignedData.java   
public SignedData(
    ASN1Set     digestAlgorithms,
    ContentInfo contentInfo,
    ASN1Set     certificates,
    ASN1Set     crls,
    ASN1Set     signerInfos)
{
    this.version = calculateVersion(contentInfo.getContentType(), certificates, crls, signerInfos);
    this.digestAlgorithms = digestAlgorithms;
    this.contentInfo = contentInfo;
    this.certificates = certificates;
    this.crls = crls;
    this.signerInfos = signerInfos;
    this.crlsBer = crls instanceof BERSet;
    this.certsBer = certificates instanceof BERSet;
}
项目:ipack    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:gwt-crypto    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:Aki-SSL    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:ExemplosDemoiselle    文件:CMSUtils.java   
/**
 * Gera em formato BER ASN.1
 * @param derObjects -> lista sem tipo definido
 * @return ASN1Set
 * @see org.bouncycastle.asn1.ASN1Set 
 */
static ASN1Set createBerSetFromList(List<?> derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator<?> it = derObjects.iterator(); it.hasNext();)
    {
        v.add((DEREncodable)it.next());
    }

    return new BERSet(v);
}
项目:irma_future_id    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:irma_future_id    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:irma_future_id    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:irma_future_id    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:bc-java    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:bc-java    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:bc-java    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:bc-java    文件:CMSUtils.java   
static ASN1Set createBerSetFromList(List derObjects)
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    for (Iterator it = derObjects.iterator(); it.hasNext();)
    {
        v.add((ASN1Encodable)it.next());
    }

    return new BERSet(v);
}
项目:ipack    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:ipack    文件:CMSAuthenticatedDataStreamGenerator.java   
public void close()
    throws IOException
{
    dataStream.close();
    eiGen.close();

    Map parameters;

    if (digestCalculator != null)
    {
        parameters = Collections.unmodifiableMap(getBaseParameters(contentType, digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));

        if (authGen == null)
        {
            authGen = new DefaultAuthenticatedAttributeTableGenerator();
        }

        ASN1Set authed = new DERSet(authGen.getAttributes(parameters).toASN1EncodableVector());

        OutputStream mOut = macCalculator.getOutputStream();

        mOut.write(authed.getEncoded(ASN1Encoding.DER));

        mOut.close();

        envGen.addObject(new DERTaggedObject(false, 2, authed));
    }
    else
    {
        parameters = Collections.unmodifiableMap(new HashMap());                
    }

    envGen.addObject(new DEROctetString(macCalculator.getMac()));

    if (unauthGen != null)
    {
        envGen.addObject(new DERTaggedObject(false, 3, new BERSet(unauthGen.getAttributes(parameters).toASN1EncodableVector())));
    }

    envGen.close();
    cGen.close();
}
项目:gwt-crypto    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:gwt-crypto    文件:CMSAuthenticatedDataStreamGenerator.java   
public void close()
    throws IOException
{
    dataStream.close();
    eiGen.close();

    Map parameters;

    if (digestCalculator != null)
    {
        parameters = Collections.unmodifiableMap(getBaseParameters(contentType, digestCalculator.getAlgorithmIdentifier(), macCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));

        if (authGen == null)
        {
            authGen = new DefaultAuthenticatedAttributeTableGenerator();
        }

        ASN1Set authed = new DERSet(authGen.getAttributes(parameters).toASN1EncodableVector());

        OutputStream mOut = macCalculator.getOutputStream();

        mOut.write(authed.getEncoded(ASN1Encoding.DER));

        mOut.close();

        envGen.addObject(new DERTaggedObject(false, 2, authed));
    }
    else
    {
        parameters = Collections.unmodifiableMap(new HashMap());                
    }

    envGen.addObject(new DEROctetString(macCalculator.getMac()));

    if (unauthGen != null)
    {
        envGen.addObject(new DERTaggedObject(false, 3, new BERSet(unauthGen.getAttributes(parameters).toASN1EncodableVector())));
    }

    envGen.close();
    cGen.close();
}
项目:Aki-SSL    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:Aki-SSL    文件:CMSAuthenticatedDataStreamGenerator.java   
public void close()
    throws IOException
{
    dataStream.close();
    eiGen.close();

    Map parameters;

    if (digestCalculator != null)
    {
        parameters = Collections.unmodifiableMap(getBaseParameters(contentType, digestCalculator.getAlgorithmIdentifier(), macCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));

        if (authGen == null)
        {
            authGen = new DefaultAuthenticatedAttributeTableGenerator();
        }

        ASN1Set authed = new DERSet(authGen.getAttributes(parameters).toASN1EncodableVector());

        OutputStream mOut = macCalculator.getOutputStream();

        mOut.write(authed.getEncoded(ASN1Encoding.DER));

        mOut.close();

        envGen.addObject(new DERTaggedObject(false, 2, authed));
    }
    else
    {
        parameters = Collections.unmodifiableMap(new HashMap());                
    }

    envGen.addObject(new DEROctetString(macCalculator.getMac()));

    if (unauthGen != null)
    {
        envGen.addObject(new DERTaggedObject(false, 3, new BERSet(unauthGen.getAttributes(parameters).toASN1EncodableVector())));
    }

    envGen.close();
    cGen.close();
}
项目:irma_future_id    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:irma_future_id    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:irma_future_id    文件:CMSAuthenticatedDataStreamGenerator.java   
public void close()
    throws IOException
{
    dataStream.close();
    eiGen.close();

    Map parameters;

    if (digestCalculator != null)
    {
        parameters = Collections.unmodifiableMap(getBaseParameters(contentType, digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));

        if (authGen == null)
        {
            authGen = new DefaultAuthenticatedAttributeTableGenerator();
        }

        ASN1Set authed = new DERSet(authGen.getAttributes(parameters).toASN1EncodableVector());

        OutputStream mOut = macCalculator.getOutputStream();

        mOut.write(authed.getEncoded(ASN1Encoding.DER));

        mOut.close();

        envGen.addObject(new DERTaggedObject(false, 2, authed));
    }
    else
    {
        parameters = Collections.unmodifiableMap(new HashMap());                
    }

    envGen.addObject(new DEROctetString(macCalculator.getMac()));

    if (unauthGen != null)
    {
        envGen.addObject(new DERTaggedObject(false, 3, new BERSet(unauthGen.getAttributes(parameters).toASN1EncodableVector())));
    }

    envGen.close();
    cGen.close();
}
项目:irma_future_id    文件:CMSAuthenticatedDataStreamGenerator.java   
public void close()
    throws IOException
{
    dataStream.close();
    eiGen.close();

    Map parameters;

    if (digestCalculator != null)
    {
        parameters = getBaseParameters(contentType, digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest());

        if (authGen == null)
        {
            authGen = new DefaultAuthenticatedAttributeTableGenerator();
        }

        ASN1Set authed = new DERSet(authGen.getAttributes(parameters).toASN1EncodableVector());

        OutputStream mOut = macCalculator.getOutputStream();

        mOut.write(authed.getEncoded(ASN1Encoding.DER));

        mOut.close();

        envGen.addObject(new DERTaggedObject(false, 2, authed));
    }
    else
    {
        parameters = new HashMap();                
    }

    envGen.addObject(new DEROctetString(macCalculator.getMac()));

    if (unauthGen != null)
    {
        envGen.addObject(new DERTaggedObject(false, 3, new BERSet(unauthGen.getAttributes(parameters).toASN1EncodableVector())));
    }

    envGen.close();
    cGen.close();
}
项目:irma_future_id    文件:EqualsAndHashCodeTest.java   
public TestResult perform()
{
    byte[]    data = { 0, 1, 0, 1, 0, 0, 1 };

    ASN1Primitive    values[] = {
            new BERConstructedOctetString(data),
            new BERSequence(new DERPrintableString("hello world")),
            new BERSet(new DERPrintableString("hello world")),
            new BERTaggedObject(0, new DERPrintableString("hello world")),
            new DERApplicationSpecific(0, data),
            new DERBitString(data),
            new DERBMPString("hello world"),
            new DERBoolean(true),
            new DERBoolean(false),
            new DEREnumerated(100),
            new DERGeneralizedTime("20070315173729Z"),
            new DERGeneralString("hello world"),
            new DERIA5String("hello"),
            new DERInteger(1000),
            new DERNull(),
            new DERNumericString("123456"),
            new DERObjectIdentifier("1.1.1.10000.1"),
            new DEROctetString(data),
            new DERPrintableString("hello world"),
            new DERSequence(new DERPrintableString("hello world")),
            new DERSet(new DERPrintableString("hello world")),
            new DERT61String("hello world"),
            new DERTaggedObject(0, new DERPrintableString("hello world")),
            new DERUniversalString(data),
            new DERUTCTime(new Date()),
            new DERUTF8String("hello world"),
            new DERVisibleString("hello world")
        };

    try
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

        for (int i = 0; i != values.length; i++)
        {
            aOut.writeObject(values[i]);
        }

        ASN1Primitive[] readValues = new ASN1Primitive[values.length];

        ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());
        ASN1InputStream         aIn = new ASN1InputStream(bIn);

        for (int i = 0; i != values.length; i++)
        {
            ASN1Primitive o = aIn.readObject();
            if (!o.equals(values[i]))
            {
                return new SimpleTestResult(false, getName() + ": Failed equality test for " + o.getClass());
            }

            if (o.hashCode() != values[i].hashCode())
            {
                return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o.getClass());
            }
        }
    }
    catch (Exception e)
    {
        return new SimpleTestResult(false, getName() + ": Failed - exception " + e.toString(), e);
    }

    return new SimpleTestResult(true, getName() + ": Okay");
}
项目:bc-java    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:bc-java    文件:CMSEnvelopedDataStreamGenerator.java   
protected OutputStream open(
    ASN1ObjectIdentifier dataType,
    OutputStream         out,
    ASN1EncodableVector  recipientInfos,
    OutputEncryptor      encryptor)
    throws IOException
{
    //
    // ContentInfo
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(out);

    cGen.addObject(CMSObjectIdentifiers.envelopedData);

    //
    // Encrypted Data
    //
    BERSequenceGenerator envGen = new BERSequenceGenerator(cGen.getRawOutputStream(), 0, true);

    envGen.addObject(getVersion());

    if (originatorInfo != null)
    {
        envGen.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }

    if (_berEncodeRecipientSet)
    {
        envGen.getRawOutputStream().write(new BERSet(recipientInfos).getEncoded());
    }
    else
    {
        envGen.getRawOutputStream().write(new DERSet(recipientInfos).getEncoded());
    }

    BERSequenceGenerator eiGen = new BERSequenceGenerator(envGen.getRawOutputStream());

    eiGen.addObject(dataType);

    AlgorithmIdentifier encAlgId = encryptor.getAlgorithmIdentifier();

    eiGen.getRawOutputStream().write(encAlgId.getEncoded());

    OutputStream octetStream = CMSUtils.createBEROctetOutputStream(
        eiGen.getRawOutputStream(), 0, false, _bufferSize);

    OutputStream cOut = encryptor.getOutputStream(octetStream);

    return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
}
项目:bc-java    文件:CMSAuthenticatedDataStreamGenerator.java   
public void close()
    throws IOException
{
    dataStream.close();
    eiGen.close();

    Map parameters;

    if (digestCalculator != null)
    {
        parameters = Collections.unmodifiableMap(getBaseParameters(contentType, digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));

        if (authGen == null)
        {
            authGen = new DefaultAuthenticatedAttributeTableGenerator();
        }

        ASN1Set authed = new DERSet(authGen.getAttributes(parameters).toASN1EncodableVector());

        OutputStream mOut = macCalculator.getOutputStream();

        mOut.write(authed.getEncoded(ASN1Encoding.DER));

        mOut.close();

        envGen.addObject(new DERTaggedObject(false, 2, authed));
    }
    else
    {
        parameters = Collections.unmodifiableMap(new HashMap());                
    }

    envGen.addObject(new DEROctetString(macCalculator.getMac()));

    if (unauthGen != null)
    {
        envGen.addObject(new DERTaggedObject(false, 3, new BERSet(unauthGen.getAttributes(parameters).toASN1EncodableVector())));
    }

    envGen.close();
    cGen.close();
}