Example usage for org.bouncycastle.cms.jcajce JcaSimpleSignerInfoGeneratorBuilder setDirectSignature

List of usage examples for org.bouncycastle.cms.jcajce JcaSimpleSignerInfoGeneratorBuilder setDirectSignature

Introduction

In this page you can find the example usage for org.bouncycastle.cms.jcajce JcaSimpleSignerInfoGeneratorBuilder setDirectSignature.

Prototype

public JcaSimpleSignerInfoGeneratorBuilder setDirectSignature(boolean hasNoSignedAttributes) 

Source Link

Document

If the passed in flag is true, the signer signature will be based on the data, not a collection of signed attributes, and no signed attributes will be included.

Usage

From source file:com.mycompany.mavenproject1.Signer.java

public void init(P12KeyContainer keyContainer)
        throws CertificateEncodingException, OperatorCreationException, CMSException {

    Security.addProvider(new BouncyCastleProvider());

    List certList = new ArrayList();
    X509Certificate cert = (X509Certificate) keyContainer.certificate;
    certList.add(cert);/*ww  w . j  a va  2 s . com*/
    Store certsStore = new JcaCertStore(certList);
    generator = new CMSSignedDataGenerator();

    JcaSimpleSignerInfoGeneratorBuilder genInfo = new JcaSimpleSignerInfoGeneratorBuilder();
    genInfo.setProvider("BC");
    genInfo.setDirectSignature(true);

    SignerInfoGenerator signerInfoGenerator = genInfo.build("GOST3411withECGOST3410",
            (PrivateKey) keyContainer.privateKey, cert);

    generator.addSignerInfoGenerator(signerInfoGenerator);
    generator.addCertificates(certsStore);
}