Package org.bouncycastle.cms

Examples of org.bouncycastle.cms.SignerInformationStore


    CollectionStore certificatesStore = (CollectionStore) signedDataParser.getCertificates();

    boolean verified = true;

    SignerInformationStore signerInformationStore = signedDataParser.getSignerInfos();
    for (Object o : signerInformationStore.getSigners()) {
      SignerInformation signerInformation = (SignerInformation) o;

      if (!BouncyCastleSignerHelper.verifySignature(signerInformation, certificatesStore, data, true)) {
        verified = false;
        break;
View Full Code Here


  @SuppressWarnings("unchecked")
  public Signature[] getSignatures(final byte[] data) {
    try {
      CMSSignedData signedData = new CMSSignedData(data);
      Collection<X509CertificateHolder> certificates = signedData.getCertificates().getMatches(null);
      SignerInformationStore signerInformationStore = signedData.getSignerInfos();
      Collection<SignerInformation> informations = signerInformationStore.getSigners();
      Collection<Signature> signatures = new ArrayList<Signature>();

      // 1.2.840.113549.1.9.3 -- content type
      // 1.2.840.113549.1.9.4 -- messagedigest
      // 1.2.840.113549.1.9.5 -- sign time
View Full Code Here

      } else {
        signedData = signedDataGenerator.generate(content, encapsulate);
      }

      if (timeStampClient != null) {
        SignerInformationStore signerInformationStore = signedData.getSignerInfos();
        List list = new ArrayList();
        for (Object o : signerInformationStore.getSigners()) {
          SignerInformation signerInformation = (SignerInformation) o;
          TimeStamp timeStamp = timeStampClient.getTimeStamp(signerInformation.getSignature());
          DERObject derObject = BouncyCastleProviderHelper.toDERObject(timeStamp.getEncoded());
          DERSet derSet = new DERSet(derObject);

          Hashtable hashtable = new Hashtable();
          Attribute attribute = new Attribute(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, derSet);
          hashtable.put(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, attribute);

          AttributeTable unsignedAtts = new AttributeTable(hashtable);

          list.add(SignerInformation.replaceUnsignedAttributes(signerInformation, unsignedAtts));
        }

        SignerInformationStore tmpSignerInformationStore = new SignerInformationStore(list);

        signedData = CMSSignedData.replaceSigners(signedData, tmpSignerInformationStore);
      }

      return signedData.getEncoded();
View Full Code Here

  private boolean verifyAttached(final byte[] data, final byte[] signature) throws CMSException, IOException, OperatorCreationException, GeneralSecurityException {
    CMSSignedData signedData = new CMSSignedData(new CMSProcessableByteArray(data), signature);

    CollectionStore certificatesStore = (CollectionStore) signedData.getCertificates();

    SignerInformationStore signerInformationStore = signedData.getSignerInfos();
    boolean verified = true;
    for (Object o : signerInformationStore.getSigners()) {
      SignerInformation signerInformation = (SignerInformation) o;

      verified = BouncyCastleSignerHelper.verifySignature(signerInformation, certificatesStore, data, false);
      if (!verified) {
        break;
View Full Code Here

    CollectionStore certificatesStore = (CollectionStore) signedDataParser.getCertificates();

    boolean verified = true;

    SignerInformationStore signerInformationStore = signedDataParser.getSignerInfos();
    for (Object o : signerInformationStore.getSigners()) {
      SignerInformation signerInformation = (SignerInformation) o;

      if (!BouncyCastleSignerHelper.verifySignature(signerInformation, certificatesStore, data, true)) {
        verified = false;
        break;
View Full Code Here

  @SuppressWarnings("unchecked")
  public Signature[] getSignatures(final byte[] data) {
    try {
      CMSSignedData signedData = new CMSSignedData(data);
      Collection<X509CertificateHolder> certificates = signedData.getCertificates().getMatches(null);
      SignerInformationStore signerInformationStore = signedData.getSignerInfos();
      Collection<SignerInformation> informations = signerInformationStore.getSigners();
      Collection<Signature> signatures = new ArrayList<Signature>();

      // 1.2.840.113549.1.9.3 -- content type
      // 1.2.840.113549.1.9.4 -- messagedigest
      // 1.2.840.113549.1.9.5 -- sign time
View Full Code Here

TOP

Related Classes of org.bouncycastle.cms.SignerInformationStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.