public IWebApiCredentials CredentialsShallowCopy()
    {
      var result = new SecureStringPasswordProvider();
      result.providerImpl = this.providerImpl.PasswordProviderCopy();

      return result;
    }
Esempio n. 2
0
        public IWebApiCredentials CredentialsShallowCopy()
        {
            var result = new SecureStringPasswordProvider();

            result.providerImpl = this.providerImpl.PasswordProviderCopy();

            return(result);
        }
    public void TestPasswordStorageAllowsWhitespaceLogin()
    {
      const string login = "******";
      const string password = "******";

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);
      }
    }
    public void TestPasswordStorageReturnsSameValues()
    {
      const string login = "******";
      const string password = "******";

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);
      }
    }
    private static void Main(string[] args)
    {
      using (var demoCredentials = new SecureStringPasswordProvider("admin", "b"))
      {
        string instanceUrl = "http://mobiledev1ua1.dk.sitecore.net:7220";

        using 
        (
          var session =
            SitecoreWebApiSessionBuilder.AuthenticatedSessionWithHost(instanceUrl)
                                        .Credentials(demoCredentials)
                                        .Site("/sitecore/shell")
                                        .DefaultDatabase("web")
                                        .DefaultLanguage("en")
                                        .MediaLibraryRoot("/sitecore/media library")
                                        .MediaPrefix("~/media/")
                                        .DefaultMediaResourceExtension("ashx")
                                        .BuildReadonlySession()
        )
        {
          var request =
            ItemWebApiRequestBuilder.ReadItemsRequestWithPath("/sitecore/content/home")
                                    .AddScope(ScopeType.Self)
                                    .Payload(PayloadType.Content)
                                    .Build();
          var readHomeItemTask = session.ReadItemAsync(request);

          // @adk : cannot use "await" in main
          Task.WaitAll(readHomeItemTask);

          ScItemsResponse items = readHomeItemTask.Result;
          string fieldText = items[0]["Text"].RawValue;

          Console.BackgroundColor = ConsoleColor.White;
          Console.ForegroundColor = ConsoleColor.Black;
          Console.Clear();

          Console.WriteLine("Home Item Text");
          Console.WriteLine();
          Console.WriteLine(fieldText);

          Console.ReadKey();
        }
      }
    }
    public void TestPasswordStorageCopyReturnsSameValues()
    {
      const string login = "******";
      const string password = "******";

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);

        using (var passwordStorageCopy = passwordStorage.CredentialsShallowCopy())
        {
          Assert.AreNotSame(passwordStorage, passwordStorageCopy);

          Assert.AreEqual(login, passwordStorageCopy.Username);
          Assert.AreEqual(password, passwordStorageCopy.Password);
        }
      }
    }
    public void TestPasswordStorageAllowsNullPassword()
    {
      const string login = "******";
      const string password = null;

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);
      }
    }