Ejemplo n.º 1
0
 public void SetPasswordViaPlainTextString() {
     var password = new Password("secret");
     var cred = new UserCredentials {
         Password = password
     };
     Assert.AreEqual(password.ToString(), cred.Password.ToString());
 }
Ejemplo n.º 2
0
 public void SetAndGetObfuscatedPassword() {
     string passwd = "Test";
     string obfuscated = new Password(passwd).ObfuscatedPassword;
     Password password = new Password { ObfuscatedPassword = obfuscated };
     Assert.NotNull(password.ObfuscatedPassword);
     Assert.AreEqual(obfuscated, password.ObfuscatedPassword);
     Assert.AreEqual(passwd, password.ToString());
 }
Ejemplo n.º 3
0
        public void EnsureSerializationOnlyContainsObfuscatedPassword() {
            string plaintext = "secret";
            Password pw = new Password(plaintext);
            XmlSerializer xmlSerializer = new XmlSerializer(pw.GetType());
            StringWriter textWriter = new StringWriter();

            xmlSerializer.Serialize(textWriter, pw);

            Assert.IsTrue(textWriter.ToString().Contains(pw.ObfuscatedPassword));
            Assert.IsFalse(textWriter.ToString().Contains(plaintext));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a cmis Atom Pub session with the given credentials.
        /// </summary>
        /// <returns>
        /// The session.
        /// </returns>
        /// <param name='user'>
        /// User.
        /// </param>
        /// <param name='password'>
        /// Password.
        /// </param>
        /// <param name='url'>
        /// URL.
        /// </param>
        /// <param name='repoId'>
        /// Repo identifier.
        /// </param>
        public static ISession CreateSession(
            string user,
            Password password,
            string url,
            string repoId,
            string binding)
        {
            Dictionary<string, string> cmisParameters = new Dictionary<string, string>();
            if (binding.Equals(BindingType.AtomPub, StringComparison.OrdinalIgnoreCase)) {
                cmisParameters[SessionParameter.BindingType] = BindingType.AtomPub;
                cmisParameters[SessionParameter.AtomPubUrl] = url;
            } else if (binding.Equals(BindingType.Browser, StringComparison.OrdinalIgnoreCase)) {
                cmisParameters[SessionParameter.BindingType] = BindingType.Browser;
                cmisParameters[SessionParameter.BrowserUrl] = url;
            }

            cmisParameters[SessionParameter.User] = user;
            cmisParameters[SessionParameter.Password] = password.ToString();
            cmisParameters[SessionParameter.RepositoryId] = repoId;

            // Sets the Connect Timeout to 60 secs
            cmisParameters[SessionParameter.ConnectTimeout] = "60000";

            ISession session = SessionFactory.NewInstance().CreateSession(cmisParameters);
            HashSet<string> filters = new HashSet<string>();
            filters.Add(PropertyIds.ObjectId);
            filters.Add(PropertyIds.Name);
            filters.Add(PropertyIds.ContentStreamFileName);
            filters.Add(PropertyIds.ContentStreamLength);
            filters.Add(PropertyIds.LastModificationDate);
            filters.Add(PropertyIds.CreationDate);
            filters.Add(PropertyIds.Path);
            filters.Add(PropertyIds.ChangeToken);
            filters.Add(PropertyIds.SecondaryObjectTypeIds);
            filters.Add(PropertyIds.IsVersionSeriesCheckedOut);
            filters.Add(PropertyIds.VersionSeriesCheckedOutId);
            HashSet<string> renditions = new HashSet<string>();
            renditions.Add("cmis:none");
            session.DefaultContext = session.CreateOperationContext(filters, false, true, false, IncludeRelationshipsFlag.None, null, true, null, true, 100);
            return session;
        }
Ejemplo n.º 5
0
 public void OnePasswordEqualsAnotherInstanceWithTheSameStoredPassword() {
     var underTest = new Password("secret");
     Assert.That(underTest, Is.EqualTo(new Password("secret")));
 }
Ejemplo n.º 6
0
 public void ConstructorTakingAPaintextPassword() {
     string passwd = "Test";
     var password = new Password(passwd);
     Assert.NotNull(password.ObfuscatedPassword);
     Assert.AreEqual(passwd, password.ToString());
 }
Ejemplo n.º 7
0
 public void DefaultConstructor() {
     var password = new Password();
     Assert.IsNull(password.ObfuscatedPassword);
     Assert.IsNull(password.ToString());
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets the password.
 /// </summary>
 /// <param name="password">Password instance.</param>
 public virtual void SetPassword(Password password) {
     this.credentials.Password = new Password { ObfuscatedPassword = password.ObfuscatedPassword };
 }
Ejemplo n.º 9
0
        public void CreateMultipleServerCredentialsBasedOnTheGivenOne() {
            var userName = "******";
            var originalUrl = "https://demo.deutsche-wolke.de/wrongStuff";
            var password = new Password(Guid.NewGuid().ToString());
            var originalCredentials = new ServerCredentials {
                Address = new Uri(originalUrl),
                Password = password,
                Binding = BindingType.Browser,
                UserName = userName
            };

            var list = originalCredentials.CreateFuzzyCredentials();

            Assert.That(list, Is.Not.Null);
            Assert.That(list, Is.Not.Empty);
            Assert.That(list.First().Credentials, Is.EqualTo(originalCredentials));
            Assert.That(list[1].Credentials.Address.ToString(), Is.EqualTo(originalCredentials.Address.ToString()));
            Assert.That(list[1].Credentials.Binding, Is.Not.EqualTo(originalCredentials.Binding));
            foreach (var entry in list) {
                Assert.That(entry.Credentials.Password.ToString(), Is.EqualTo(password.ToString()));
                Assert.That(entry.Credentials.UserName, Is.EqualTo(userName));
                Console.WriteLine(entry);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Sets the password.
 /// </summary>
 /// <param name="password">Password instance.</param>
 public virtual void SetPassword(Password password)
 {
     this.credentials.Password = new Password {
         ObfuscatedPassword = password.ObfuscatedPassword
     };
 }