Exemple #1
0
        public string[] EncryptFilesWithStormshieldDataFile(string[] filePaths, string[] emailAddresses)
        {
            List <string> encryptedFilePaths = new List <string>();

            string recipients = CSharpArrayToCmdletList(emailAddresses);

            using (Stormshield.DataSecurity.Connector.API api = new Stormshield.DataSecurity.Connector.API())
            {
                object[] objects = api.Execute(string.Format("Get-SDSCertificate -EmailAddress {0}", recipients));
                if (objects == null || objects.Length != emailAddresses.Length)
                {
                    throw new InvalidOperationException("Certains certificats ne sont pas trouvés");
                }
                else
                {
                    KeyValuePair <string, object>[] parameters = new KeyValuePair <string, object>[]
                    {
                        new KeyValuePair <string, object>("-Path", filePaths),
                        new KeyValuePair <string, object>("-Coworkers", objects)
                    };
                    objects = api.Execute("Protect-SDSFile", parameters);
                    if (objects != null)
                    {
                        foreach (object item in objects)
                        {
                            SecureFile secureFile = item as SecureFile;
                            encryptedFilePaths.Add(secureFile.Path);
                        }
                    }
                }
            }

            return(encryptedFilePaths.ToArray());
        }
Exemple #2
0
        public X509Certificate GetCertificate(string emailAddress)
        {
            X509Certificate certificate = null;

            using (Stormshield.DataSecurity.Connector.API api = new Stormshield.DataSecurity.Connector.API())
            {
                object[] objects = api.Execute(string.Format("Get-SDSCertificate -EmailAddress {0}", emailAddress));
                if (objects != null)
                {
                    certificate = objects[0] as X509Certificate;
                }
            }

            return(certificate);
        }
Exemple #3
0
 /// <summary>
 /// Création d'une règle Team sur un dossier
 /// </summary>
 /// <param name="folderPath">Chemin complet du dossier</param>
 /// <param name="certificates">Liste des adresses email des collaborateurs</param>
 /// <remarks>
 /// L'utilisateur connecté à SDS est ajouté automatiquement dans la règle en tant que propriétaire.
 /// Les autres utilisateurs (paramètre 'certificates') sont ajoutés comme simples collaborateurs.
 /// </remarks>
 public void CreateTeamRule(string folderPath, X509Certificate[] certificates)
 {
     using (Stormshield.DataSecurity.Connector.API api = new Stormshield.DataSecurity.Connector.API())
     {
         KeyValuePair <string, object>[] parameters = new KeyValuePair <string, object>[]
         {
             new KeyValuePair <string, object>("-Path", folderPath),
             new KeyValuePair <string, object>("-Coworkers", certificates)
         };
         object[] objects = api.Execute("New-SDSTeamRule", parameters);
         if (objects == null || objects.Length == 0)
         {
             throw new InvalidOperationException();
         }
     }
 }
Exemple #4
0
        public X509Certificate[] GetCertificates(string[] emailAddresses)
        {
            X509Certificate[] certificates = null;

            using (Stormshield.DataSecurity.Connector.API api = new Stormshield.DataSecurity.Connector.API())
            {
                string   emailAddressArg = CSharpArrayToCmdletList(emailAddresses);
                object[] objects         = api.Execute(string.Format("Get-SDSCertificate -EmailAddress {0}", emailAddressArg));
                if (objects != null)
                {
                    certificates = Array.ConvertAll <object, X509Certificate>(objects, o => o as X509Certificate);
                }
            }

            return(certificates);
        }
Exemple #5
0
        public bool UserIsConnected()
        {
            bool userIsConnected = false;

            using (Stormshield.DataSecurity.Connector.API api = new Stormshield.DataSecurity.Connector.API())
            {
                object[] objects = api.Execute("Get-SDSUser");
                if (objects != null)
                {
                    User user = objects[0] as User;
                    userIsConnected = !user.Locked;
                }
            }

            return(userIsConnected);
        }
Exemple #6
0
        public string[] EncryptFileWithStormshieldDataFile(string filePath)
        {
            List <string> encryptedFilePaths = new List <string>();

            using (Stormshield.DataSecurity.Connector.API api = new Stormshield.DataSecurity.Connector.API())
            {
                object[] objects = api.Execute(string.Format("Protect-SDSFile '{0}'", filePath));
                if (objects != null)
                {
                    foreach (object item in objects)
                    {
                        SecureFile secureFile = item as SecureFile;
                        encryptedFilePaths.Add(secureFile.Path);
                    }
                }
            }

            return(encryptedFilePaths.ToArray());
        }