Esempio n. 1
0
 private void Sign(string container, string path, bool strongName)
 {
     try
     {
         var tempPath = _azureClient.CopyFileToTemp(container, path);
         var cert     = _certs.Get();
         if (FileSensing.IsItAZipFile(tempPath))
         {
             AttemptToSignOPC(tempPath, cert);
             _log.Debug("OPC Signing is done");
         }
         else
         {
             AttemptToSignAuthenticode(tempPath, strongName, cert);
             _log.Debug("Authenticode is done");
         }
         _log.Debug(@"let's copy the file from {0} to {1}\{2}".format(tempPath, container, path));
         _azureClient.CopyFileToAzure(container, path, tempPath);
         _log.Debug(@"finished {0} to {1}\{2}".format(tempPath, container, path));
     }
     catch (Exception e)
     {
         _log.Fatal("error", e);
         throw;
     }
 }
Esempio n. 2
0
        public GetUploadLocationResponse Post(GetUploadLocationRequest request)
        {
            _log.StartLog(request);
            try
            {
                var contName = "deletable" + Guid.NewGuid().ToString("D").ToLowerInvariant();

                var container = _azure.CreateContainerIfDoesNotExist(contName);

                var blobPolicy = new SharedAccessBlobPolicy {
                    Permissions            = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.List,
                    SharedAccessExpiryTime = DateTimeOffset.Now.AddHours(HOURS_FILE_SHOULD_BE_ACCESSIBLE)
                };

                var permissions = new BlobContainerPermissions();
                permissions.SharedAccessPolicies.Add("mypolicy", blobPolicy);
                permissions.PublicAccess = BlobContainerPublicAccessType.Container;
                container.SetPermissions(permissions);
                var sharedAccessSignature = container.GetSharedAccessSignature("mypolicy");

                return(new GetUploadLocationResponse {
                    Name = container.Name, Location = container.Uri.ToString(), Sas = sharedAccessSignature, Account = _azure.Account
                });
            }
            catch (Exception e)
            {
                _log.Fatal("error", e);
                Errors.Add(e.Message + " " + e.StackTrace);

                return(new GetUploadLocationResponse {
                    Errors = Errors
                });
            }
        }