/// <summary>
        /// Checks the validity of this configuration.
        /// </summary>
        /// <param name="monitor">The monitor that will log warnings and errors.</param>
        /// <returns>True on success, false if the configuration is not valid and should not be used.</returns>
        public virtual bool CheckValid(IActivityMonitor monitor)
        {
            bool success = RemotePartyConfiguration.ValidateName(monitor, nameof(DomainName), DomainName, false);

            success &= RemotePartyConfiguration.ValidateName(monitor, nameof(EnvironmentName), EnvironmentName, false);
            if (ClockSkew < TimeSpan.FromSeconds(1) || ClockSkew > TimeSpan.FromHours(8))
            {
                monitor.Error($"ClockSkew must be between 1 second and 8 hour. (Value: {ClockSkew:c})");
                success = false;
            }
            if (MinSignatureDuration < TimeSpan.FromSeconds(1))
            {
                monitor.Error($"MinSignatureLifetime must be at least 1 second. (Value: {MinSignatureDuration:c})");
                success = false;
            }
            if (MaxSignatureDuration < MinSignatureDuration)
            {
                monitor.Error($"MaxSignatureLifetime ({MaxSignatureDuration:c}) must be greater than MinSignatureLifetime ({MinSignatureDuration:c}).");
                success = false;
            }
            success &= Local.CheckValid(monitor);
            foreach (var t in TrustedParties)
            {
                success &= t.CheckValid(monitor, EnvironmentName);
            }
            if (success)
            {
                Debug.Assert(Local.Name != null);
                HashSet <string> partyNames = new HashSet <string>();
                partyNames.Add(Local.Name);
                foreach (var p in TrustedParties)
                {
                    Debug.Assert(p.Name != null);
                    if (!partyNames.Add(p.Name))
                    {
                        monitor.Error($"Party Name '{p}' is already used. Names must be unique.");
                        success = false;
                    }
                }
            }
            return(success);
        }
        /// <summary>
        /// Checks the validity of this configuration.
        /// </summary>
        /// <param name="monitor">The monitor that will log warnings and errors.</param>
        /// <returns>True on success, false if the configuration is not valid and should not be used.</returns>
        public virtual bool CheckValid(IActivityMonitor monitor)
        {
            bool success = RemotePartyConfiguration.ValidateName(monitor, nameof(Name), Name, true);

            return(success);
        }