fun replaceCertificatesAndCRLs()

in jvm/src/main/kotlin/com/jetbrains/signatureverifier/bouncycastle/cms/CMSSignedData.kt [515:567]


    fun replaceCertificatesAndCRLs(
      signedData: CMSSignedData,
      certificates: Store<X509CertificateHolder>?,
      attrCerts: Store<X509AttributeCertificateHolder>?,
      revocations: Store<X509CRLHolder>?
    ): CMSSignedData {
      //
      // copy
      //
      val cms = CMSSignedData(signedData)

      //
      // replace the certs and revocations in the SignedData object
      //
      var certSet: ASN1Set? = null
      var crlSet: ASN1Set? = null
      if (certificates != null || attrCerts != null) {
        val certs = mutableListOf<Any>()
        if (certificates != null) {
          certs.addAll(CMSUtils.getCertificatesFromStore(certificates))
        }
        if (attrCerts != null) {
          certs.addAll(CMSUtils.getAttributeCertificatesFromStore(attrCerts))
        }
        val set = CMSUtils.createBerSetFromList(certs)
        if (set.size() != 0) {
          certSet = set
        }
      }
      if (revocations != null) {
        val set = CMSUtils.createBerSetFromList(CMSUtils.getCRLsFromStore(revocations))
        if (set.size() != 0) {
          crlSet = set
        }
      }

      //
      // replace the CMS structure.
      //
      cms.signedData = SignedData(
        signedData.signedData.digestAlgorithms,
        signedData.signedData.encapContentInfo,
        certSet,
        crlSet,
        signedData.signedData.signerInfos
      )

      //
      // replace the contentInfo with the new one
      //
      cms.contentInfo = ContentInfo(cms.contentInfo.contentType, cms.signedData)
      return cms
    }