Пример #1
0
 public AsicePackageEntry(string fileName, MimeType type, MessageDigestAlgorithm messageDigestAlgorithm)
 {
     FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
     Type     = type ?? throw new ArgumentNullException(nameof(type));
     MessageDigestAlgorithm = messageDigestAlgorithm ??
                              throw new ArgumentNullException(nameof(messageDigestAlgorithm));
 }
Пример #2
0
 public AsiceArchive(ZipArchive archive, IManifestCreator creator, MessageDigestAlgorithm messageDigestAlgorithm, ICertificateHolder signatureCertificate)
 {
     Archive = archive ?? throw new ArgumentNullException(nameof(archive));
     this.manifestCreator   = creator ?? throw new ArgumentNullException(nameof(creator));
     MessageDigestAlgorithm = messageDigestAlgorithm ?? throw new ArgumentNullException(nameof(messageDigestAlgorithm));
     SignatureCertificate   = signatureCertificate;
 }
 public DeclaredDigestFile(
     byte[] digest,
     MessageDigestAlgorithm messageDigestAlgorithm,
     string fileName,
     MimeType mimeType)
 {
     this._digest           = digest ?? throw new ArgumentNullException(nameof(digest));
     MessageDigestAlgorithm = messageDigestAlgorithm ??
                              throw new ArgumentNullException(nameof(messageDigestAlgorithm));
     Name     = fileName ?? throw new ArgumentNullException(nameof(fileName));
     MimeType = mimeType ?? throw new ArgumentNullException(nameof(mimeType));
 }
Пример #4
0
 public CadesManifest(ASiCManifestType asiCManifestType) : base(ManifestSpec.Cades)
 {
     this._asiCManifestType = asiCManifestType ?? throw new ArgumentNullException(nameof(asiCManifestType));
     Digests = this._asiCManifestType?.DataObjectReference?
               .ToImmutableDictionary(
         d => d.URI,
         d => new DeclaredDigestFile(
             d.DigestValue,
             MessageDigestAlgorithm.FromUri(new Uri(d.DigestMethod.Algorithm)),
             d.URI,
             MimeType.ForString(d.MimeType)));
     RootFile = asiCManifestType.DataObjectReference?.Where(d => d.Rootfile).Select(d => d.URI).FirstOrDefault();
 }
Пример #5
0
 public AsiceReadEntry(ZipArchiveEntry zipArchiveEntry, MessageDigestAlgorithm digestAlgorithm, IDigestReceiver digestReceiver)
 {
     this._zipArchiveEntry = zipArchiveEntry ?? throw new ArgumentNullException(nameof(zipArchiveEntry));
     this._digestAlgorithm = digestAlgorithm ?? throw new ArgumentNullException(nameof(digestAlgorithm));
     this._digestReceiver  = digestReceiver;
 }
Пример #6
0
        public static AsiceArchive Create(Stream zipOutStream, IManifestCreator manifestCreator, ICertificateHolder signatureCertificateHolder, MessageDigestAlgorithm messageDigestAlgorithm)
        {
            Log.Debug("Creating ASiC-e Zip");
            var zipArchive = new ZipArchive(zipOutStream, ZipArchiveMode.Create, false, Encoding.UTF8);

            // Add mimetype entry
            var zipArchiveEntry = zipArchive.CreateEntry(AsiceConstants.FileNameMimeType);

            using (var stream = zipArchiveEntry.Open())
            {
                var contentAsBytes = Encoding.UTF8.GetBytes(AsiceConstants.ContentTypeASiCe);
                stream.Write(contentAsBytes, 0, contentAsBytes.Length);
            }

            return(new AsiceArchive(zipArchive, manifestCreator, messageDigestAlgorithm, signatureCertificateHolder));
        }
Пример #7
0
 public DigestContainer(byte[] digest, MessageDigestAlgorithm messageDigestAlgorithm)
 {
     this._digest = digest ?? throw new ArgumentNullException(nameof(digest));
     this._messageDigestAlgorithm = messageDigestAlgorithm ??
                                    throw new ArgumentNullException(nameof(messageDigestAlgorithm));
 }