예제 #1
0
        public void PrepairProjectForCreation(Project project)
        {
            ProjectHttpClient    projClient;
            TeamProjectReference onlineProject;
            Uri tfsUri = new Uri(project.ProjectAreaPath);
            VssBasicCredential credentials = new VssBasicCredential(project.UserName, project.Password);
            VssConnection      connection  = new VssConnection(tfsUri, credentials);

            _teamClient             = connection.GetClientAsync <TeamHttpClient>().Result;
            projClient              = connection.GetClientAsync <ProjectHttpClient>().Result;
            _workItemTrackingClient = connection.GetClient <WorkItemTrackingHttpClient>();
            IPagedList <TeamProjectReference> projects = projClient.GetProjects().Result;

            onlineProject = projects.FirstOrDefault(pro => pro.Name.ToUpperInvariant().Equals(project.ProjectName.ToUpperInvariant(), StringComparison.InvariantCulture));
            if (onlineProject != null)
            {
                project.CreationDate     = DateTime.Now;
                OnlineTfsTeamProjectName = project.ProjectName;
                OnlineTfsProjectId       = onlineProject.Id.ToString();
                project.ProjectType      = Projects.Enums.ProjectType.Online.ToString();
                project.Password         = project.AuthType == 1 ? encryption.DecryptString(project.Password, DecryptionKey) : project.Password;
                ConnectToOnLineTfsAndCreateQuries(project.ProjectName);
            }
            else
            {
                throw new UserFriendlyException($"Project Path: '{project.ProjectAreaPath}' Was Not Found!");
            }
        }
        public string GetDecryptedPath(string path)
        {
            var parts = path.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);

            for (byte i = 0; i < parts.Length; i++)
            {
                parts[i] = _encryption.DecryptString(parts[i]);
            }
            return(string.Join(Path.DirectorySeparatorChar, parts));
        }
예제 #3
0
 private void Decrypt(BasicRequest request)
 {
     if (_settings.Encrypt)
     {
         var compressedFlatArray = _encryption.DecryptString(request.Source);
         var flatArray           = _compression.Decompress(compressedFlatArray);
         var doubleArray         = flatArray.Split('|').Select(o => Convert.ToInt32(o)).ToArray();
         var unicodeString       = new String(doubleArray.Select(o => (char)o).ToArray());
         var split = unicodeString.Split(new[] { "[ENDSEED]" }, StringSplitOptions.None);
         request.Seed   = split[0].Split('|').Select(o => Convert.ToInt32(o)).ToList();
         request.Source = split[1];
     }
 }
예제 #4
0
        public void EncryptString()
        {
            //Arange
            _fakeInput = "abc";
            //Act
            var resultEncrypt = _encryption.EncryptString(_fakeInput, _fakeKey, _fakeIV);
            var resultDecrypt = _encryption.DecryptString(resultEncrypt, _fakeKey, _fakeIV);

            //Assert
            Assert.IsNotNull(resultEncrypt);
            Assert.That(resultEncrypt.Length, Is.GreaterThan(0));
            Assert.IsNotNull(resultDecrypt);
            Assert.That(resultDecrypt.Length, Is.GreaterThan(0));
            Assert.That(resultDecrypt, Is.EqualTo(_fakeInput));
        }
 public static string Decrypt(this string value, IEncryption encryption)
 {
     return(encryption.DecryptString(value));
 }
예제 #6
0
        public BasicClient Deserialise(string key, string iv, string client)
        {
            _encryption.SetKeyAndIv(key, iv);
            var serlizedBasicClient = _serialisation.Deserialise <SerlializedBasicClient>(_compression.Decompress(_encryption.DecryptString(client)));

            return(new BasicClient(serlizedBasicClient.GeneratorSettings, serlizedBasicClient.ServiceSettings, serlizedBasicClient.TokenTable));
        }