/// <summary>
        /// Sets the password. This is done by setting the value of the password-secret stored in the credentials.
        /// </summary>
        /// <param name="password">The new password.</param>
        public void SetPassword(string password)
        {
            Util.ThrowIfParameterNull(password, "password");

            var session = _connection.Session;

            if (session != null)
            {
                string secretRef = Secret.get_by_uuid(session, PasswordSecret);
                Secret.set_value(_connection.Session, secretRef, password);
            }
        }
示例#2
0
        public void SetStorageLinkCredentials(string host, string username, string password)
        {
            var otherConfig = new Dictionary <string, string>(other_config);

            if (host == null)
            {
                otherConfig.Remove("storagelink_host");
            }
            else
            {
                otherConfig["storagelink_host"] = host;
            }

            if (username == null)
            {
                otherConfig.Remove("storagelink_user");
            }
            else
            {
                otherConfig["storagelink_user"] = username;
            }

            if (password == null)
            {
                otherConfig.Remove("storagelink_password_secret");
            }
            else if (otherConfig.ContainsKey("storagelink_password_secret"))
            {
                try
                {
                    string secretRef = Secret.get_by_uuid(Connection.Session, otherConfig["storagelink_password_secret"]);
                    Secret.set_value(Connection.Session, secretRef, password);
                }
                catch (Failure)
                {
                    otherConfig["storagelink_password_secret"] = Secret.CreateSecret(Connection.Session, password);
                }
                catch (WebException)
                {
                    otherConfig["storagelink_password_secret"] = Secret.CreateSecret(Connection.Session, password);
                }
            }
            else
            {
                otherConfig["storagelink_password_secret"] = Secret.CreateSecret(Connection.Session, password);
            }

            Pool.set_other_config(Connection.Session, opaque_ref, otherConfig);
        }