Exemple #1
0
        public CertRequestTests()
        {
            var log = new LoggerConfiguration()
                      .WriteTo.Debug()
                      .CreateLogger();

            _log           = new Loggy(log);
            certifyManager = new CertifyManager();
            iisManager     = new ServerProviderIIS();

            // see integrationtestbase for environment variable replacement
            PrimaryTestDomain = ConfigSettings["Cloudflare_TestDomain"];

            testSiteDomain = "integration1." + PrimaryTestDomain;
            testSitePath   = PrimaryIISRoot;

            _testCredStorageKey = ConfigSettings["TestCredentialsKey_Cloudflare"];

            if (ConfigSettings["HttpPort"] != null)
            {
                testSiteHttpPort = int.Parse(ConfigSettings["HttpPort"]);
            }

            //perform setup for IIS
            SetupIIS().Wait();
        }
Exemple #2
0
        public void WriteToNamed()
        {
            var myloggy = Loggy.Get("named");

            myloggy.Info("test");
            appender.MustCatch(LogLevel.Info, "test", "named");
        }
Exemple #3
0
 protected override void OnStart(string[] args)
 {
     Loggy.Add("Starting CrowdCodeService.");
     timerDelegate = new TimerCallback(DoSomething);
     seconds = secondsDefault;
     stateTimer = new Timer(timerDelegate, autoEvent, 0, seconds * 1000);
 }
Exemple #4
0
        public async Task <List <StatusMessage> > TestChallengeResponse(ManagedCertificate managedCertificate)
        {
            DebugLog();

            var progressState = new RequestProgressState(RequestState.Running, "Starting Tests..", managedCertificate);

            var progressIndicator = new Progress <RequestProgressState>(progressState.ProgressReport);

            //begin monitoring progress
            _certifyManager.BeginTrackingProgress(progressState);

            // perform challenge response test, log to string list and return in result
            var logList = new List <string>();

            using (var log = new LoggerConfiguration()

                             .WriteTo.Sink(new ProgressLogSink(progressIndicator, managedCertificate, _certifyManager))
                             .CreateLogger())
            {
                var theLog  = new Loggy(log);
                var results = await _certifyManager.TestChallenge(theLog, managedCertificate, isPreviewMode : true, progress : progressIndicator);

                return(results);
            }
        }
         public virtual void ExecuteCommand()
         {
             if (command == null)
                 throw new Exception("You forgot to set the command!!");
 
             try
             {
                 log(this.command.GetType().Name + " starting execution ");
                 command.Execute();
                 if (!command.Success)
                 {
                     log(this.command.GetType().Name + " completed execution but failed. Message: " + command.Message + " " + command.StatusCode.ToString());
                 }
                 else
                     log(this.command.GetType().Name + " completed execution. Success!");
 
             }
             catch (Exception ex)
             {
                 command.StatusCode = CommandStatusCode.Error;
                 Loggy.AddError("An unhandled error was caught in " + this.command.GetType().Name + ": " + ex.Message, ex);
                 command.Message = ex.ToString();
                 //throw;
             }
         }
Exemple #6
0
 public void Setup()
 {
     Loggy.Manager = null;
     Loggy.Manager = new LoggyManager();
     this.appender = new TestAppender {
         Level = LogLevel.Info
     };
     Loggy.Get().Appenders.Add(appender);
     Loggy.Level = LogLevel.Trace;
 }
Exemple #7
0
        public void ValidConfig()
        {
            var def = Loggy.Get();

            Assert.NotNull(def);
            Assert.True(def.Isolated);
            Assert.AreEqual(1, def.Appenders.Count);
            Assert.AreEqual(appender, def.Appenders[0]);
            Assert.AreEqual("default", def.Name);
        }
Exemple #8
0
        public void CanResetLogger()
        {
            var logger = Loggy.Get("named");

            Assert.False(logger.Isolated);
            Loggy.Manager.Loggers["named"] = new DefaultLoggy {
                Name = "xxxx"
            };
            var logger2 = Loggy.Get("named");

            Assert.AreEqual("xxxx", logger2.Name);
        }
Exemple #9
0
        public void LoggyTest()
        {
            var a = new Matrix(2, 2);

            a.InRandomize();
            var b = a.Duplicate();

            a = new Loggy().Forward(a);
            b.InMap((x) => Math.Tanh(x / 2.0));
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new Loggy().Type().ToString() + " Activation.");
        }
Exemple #10
0
        public void LoggyPrimeTest()
        {
            var a = new Matrix(2, 2);

            a.InRandomize();
            var b = a.Duplicate();

            a = new Loggy().Backward(a);
            b.InMap((x) => 1.0 / (Math.Cosh(x) + 1.0));
            Assert.IsTrue(Math.Abs(a.FrobeniusNorm() - b.FrobeniusNorm()) < 0.1,
                          new Loggy().Type().ToString() + " Derivative.");
        }
Exemple #11
0
        public DeploymentTaskTests()
        {
            var log = new LoggerConfiguration()
                      .WriteTo.Debug()
                      .CreateLogger();

            _log = new Loggy(log);

            certifyManager = new CertifyManager();

            // see integrationtestbase for environment variable replacement
            PrimaryTestDomain = ConfigSettings["Cloudflare_TestDomain"];
        }
        public async Task TestPortConnection()
        {
            var net = new NetworkUtils(enableProxyValidationAPI: true);

            var logImp = new LoggerConfiguration()
                         .WriteTo.Debug()
                         .CreateLogger();

            var log = new Loggy(logImp);

            var result = await net.CheckServiceConnection("webprofusion.com", 80);

            Assert.IsTrue(result.IsSuccess, "hostname should connect ok on port 80");
        }
Exemple #13
0
        public void WriteToSpecial()
        {
            var myappender = new TestAppender {
                Level = LogLevel.Debug
            };

            Loggy.Get("named", s => {
                s.Isolated = true;
                s.Level    = LogLevel.Info;
                s.Appenders.Add(myappender);
            });
            Loggy.Get("named").Info("test");
            appender.MustNotCatch(LogLevel.Info, "test", "named");
            myappender.MustCatch(LogLevel.Info, "test", "named");
        }
Exemple #14
0
        /// <summary>
        /// Setup app model
        /// </summary>
        private void Init()
        {
            Log = new Loggy(
                new LoggerConfiguration()
                .MinimumLevel.Verbose()
                .WriteTo.Debug()
                .WriteTo.File(Path.Combine(Management.Util.GetAppDataFolder("logs"), "ui.log"), shared: true, flushToDiskInterval: new TimeSpan(0, 0, 10))
                .CreateLogger()
                );

            ProgressResults = new ObservableCollection <RequestProgressState>();

            ImportedManagedCertificates = new ObservableCollection <ManagedCertificate>();
            ManagedCertificates         = new ObservableCollection <ManagedCertificate>();
        }
Exemple #15
0
        public async Task TestDNS_CheckTXT()
        {
            var net = new NetworkUtils(enableProxyValidationAPI: true);

            var logImp = new LoggerConfiguration()
                         .WriteTo.Debug()
                         .CreateLogger();

            var log = new Loggy(logImp);

            // check invalid domain
            var result = await net.GetDNSRecordTXT(log, "_acme-challenge-test.cointelligence.io");

            Assert.IsNull(result, "Non-existant DNS TXT record does not throw an error");
        }
         private void log(string msg)
         {
             switch (command.LoggingLevel)
             {
                 case Busker.Data.Constants.LoggingLevel.Debug:
                     Loggy.Debug(msg);
                     break;
                 case Busker.Data.Constants.LoggingLevel.Off:
                     break;
                 default:
                     Loggy.Add(msg);
                     break;
 
             }
 
         }
Exemple #17
0
        private void InitLogging(Shared.ServiceConfig serverConfig)
        {
            _loggingLevelSwitch = new Serilog.Core.LoggingLevelSwitch(Serilog.Events.LogEventLevel.Information);

            SetLoggingLevel(serverConfig?.LogLevel);

            _serviceLog = new Loggy(
                new LoggerConfiguration()
                .MinimumLevel.ControlledBy(_loggingLevelSwitch)
                .WriteTo.Debug()
                .WriteTo.File(Path.Combine(Util.GetAppDataFolder("logs"), "session.log"), shared: true, flushToDiskInterval: new TimeSpan(0, 0, 10), rollOnFileSizeLimit: true, fileSizeLimitBytes: 5 * 1024 * 1024)
                .CreateLogger()
                );

            _serviceLog?.Information($"Logging started: {_loggingLevelSwitch.MinimumLevel}");
        }
Exemple #18
0
        public CertifyManager()
        {
            _serviceLog = new Loggy(
                new LoggerConfiguration()
                .MinimumLevel.Verbose()
                .WriteTo.Debug()
                .WriteTo.File(Util.GetAppDataFolder("logs") + "\\sessionlog.txt", shared: true, flushToDiskInterval: new TimeSpan(0, 0, 10))
                .CreateLogger()
                );

            Util.SetSupportedTLSVersions();

            _itemManager    = new ItemManager();
            _serverProvider = (ICertifiedServer) new ServerProviderIIS();

            _progressResults = new ObservableCollection <RequestProgressState>();

            _pluginManager = new PluginManager();
            _pluginManager.LoadPlugins();

            // TODO: convert providers to plugins
            var certes = new Certify.Providers.Certes.CertesACMEProvider(Management.Util.GetAppDataFolder() + "\\certes");

            _acmeClientProvider = certes;
            _vaultProvider      = certes;

            // init remaining utilities and optionally enable telematics
            _challengeDiagnostics = new ChallengeDiagnostics(CoreAppSettings.Current.EnableValidationProxyAPI);

            if (CoreAppSettings.Current.EnableAppTelematics)
            {
                _tc = new Util().InitTelemetry();
            }

            PerformUpgrades();

            var serverConfig = Util.GetAppServiceConfig();

            _httpChallengePort = serverConfig.HttpChallengeServerPort;
            _httpChallengeServerClient.Timeout = new TimeSpan(0, 0, 5);

            if (_tc != null)
            {
                _tc.TrackEvent("ServiceStarted");
            }
        }
Exemple #19
0
        public async Task TestDNSTests()
        {
            var net = new NetworkUtils(enableProxyValidationAPI: true);

            var logImp = new LoggerConfiguration()
                         .WriteTo.Debug()
                         .CreateLogger();

            var log = new Loggy(logImp);

            // check invalid domain
            var result = await net.CheckDNS(log, "fdlsakdfoweinoijsjdfpsdkfspdf.com");

            Assert.IsFalse(result.All(r => r.IsSuccess), "Non-existant DNS does not throw an error");

            result = await net.CheckDNS(log, "cloudapp.net");

            Assert.IsFalse(result.All(r => r.IsSuccess), "Valid domain that does not resolve to an IP Address does not throw an error");

            // certifytheweb.com = no CAA records
            result = await net.CheckDNS(log, "webprofusion.com");

            Assert.IsTrue(result.All(r => r.IsSuccess), "CAA records are not required");

            // google.com = no letsencrypt.org CAA records (returns "pki.goog" only)
            result = await net.CheckDNS(log, "google.com");

            Assert.IsFalse(result.All(r => r.IsSuccess), "If CAA records are present, letsencrypt.org is returned.");

            // dnsimple.com = correctly configured letsencrypt.org CAA record
            result = await net.CheckDNS(log, "dnsimple.com");

            Assert.IsTrue(result.All(r => r.IsSuccess), "Correctly configured LE CAA entries work");

            // example.com = correctly configured DNSSEC record
            result = await net.CheckDNS(log, "example.com");

            Assert.IsTrue(result.All(r => r.IsSuccess), "correctly configured DNSSEC record should pass dns check");

            // dnssec-failed.org = incorrectly configured DNSSEC record
            result = await net.CheckDNS(log, "dnssec-failed.org");

            Assert.IsFalse(result.All(r => r.IsSuccess), "incorrectly configured DNSSEC record should fail dns check");
        }
Exemple #20
0
 private void CreateLogger()
 {
     if (LoggerHost != "" && LoggerPort != 0 && LoggerName != "")
     {
         Console.WriteLine("LOGLEVEL " + LogLevel);
         var def = Loggy.Get();
         def.Level = LogLevel;
         def.Appenders.Add(new UdpAppender(LoggerHost, LoggerPort)
         {
             AutoFlushSize = 1, Format = LoggerFormat
         });
         def.Debug("debug test тест");
         def.Trace("trace test тест");
         def.Info("info test тест");
         def.Warn("warning test тест");
         def.Error("error test тест", new Exception("Test exception"));
         def.Fatal("fatal test тест");
     }
 }
         /// <summary>
         /// Executes the command using the default invoker.
         /// </summary>
         /// <param name="aCommand"></param>
         public static void Invoke(this Command aCommand)
         {
             System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
             System.Reflection.MethodBase m = stackTrace.GetFrame(1).GetMethod();
             String strMethodName = m.DeclaringType.Name + "." + m.Name;
 
             try
             {
                 Invoker invoker = new Invoker();
                 invoker.SetCommand(aCommand);
                 invoker.ExecuteCommand();
             }
             catch (Exception ex)
             {
                 Loggy.AddError("An error occured in Extensions.Invoke. + " + strMethodName ,ex);
                 throw ex;
             }
             
         }
Exemple #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="server"></param>
        /// <param name="context"></param>
        /// <param name="callbackEndPoint"></param>
        /// <param name="cancel"></param>
        /// <returns></returns>
        protected override HandlerResult GetResult(IHostServer server, WebContext context, string callbackEndPoint, CancellationToken cancel)
        {
            var ctx      = RequestParameters.Create(context);
            var login    = ctx.Get("login");
            var password = ctx.Get("pass");
            var identity = (Identity)LogonService.Logon(login, password);

            context.User = new GenericPrincipal(identity, null);
            var logondata = new LogonInfo {
                Identity       = identity,
                RemoteEndPoint = context.Request.RemoteEndPoint,
                LocalEndPoint  = context.Request.LocalEndPoint,
                UserAgent      = context.Request.UserAgent
            };
            var strRemoteIp = logondata.RemoteEndPoint.Address.ToString();

            if (identity.IsAuthenticated && !identity.IsGuest)
            {
                var token = TokenService.Create(context.Request);
                identity.User = identity.User ?? new User {
                    Login = identity.Name
                };
                var resolvedUsername = identity.User.Login;
                if (!string.IsNullOrWhiteSpace(identity.User.Domain))
                {
                    resolvedUsername = resolvedUsername + "@" + identity.User.Domain;
                }
                TokenService.Store(context.Response, context.Request.Uri, token);
                Loggy.Info("Login: "******", " + logondata.UserAgent + " from " + strRemoteIp);
                return(new HandlerResult {
                    Result = new{ auth = true, state = identity.State, stateinfo = identity.StateInfo }, Data = logondata
                });
            }
            if (!identity.IsAuthenticated && !identity.IsGuest)
            {
                Loggy.Warn("Login failed: " + context.User.Identity.Name + ", User Agent: [" + logondata.UserAgent + "] from ip: " + strRemoteIp);
            }
            TokenService.Store(context.Response, context.Request.Uri, null);
            return(new HandlerResult {
                Result = new { auth = false, state = identity.State, stateinfo = identity.StateInfo }, Data = logondata
            });
        }
Exemple #23
0
 /// <summary>
 /// Explicitly wait for log operation finish
 /// </summary>
 public void WaitLog()
 {
     Log.Synchronize();
     Loggy.Flush();
 }
Exemple #24
0
        public async Task TestAccessControlChecks()
        {
            var log = new LoggerConfiguration()
                      .WriteTo.Debug()
                      .CreateLogger();

            var loggy = new Loggy(log);

            var access = new AccessControl(loggy, new MemoryObjectStore());

            var contextUserId = "[test]";

            // add test security principles
            var allPrinciples = GetTestSecurityPrinciples();

            foreach (var p in allPrinciples)
            {
                _ = await access.AddSecurityPrinciple(p, contextUserId, bypassIntegrityCheck : true);
            }

            // assign resource roles per principle
            var allResourceProfiles = GetTestResourceProfiles();

            foreach (var r in allResourceProfiles)
            {
                _ = await access.AddResourceProfile(r, contextUserId, bypassIntegrityCheck : true);
            }

            // assert

            var hasAccess = await access.IsPrincipleInRole("admin_01", StandardRoles.Administrator.Id, contextUserId);

            Assert.IsTrue(hasAccess, "User should be in role");

            hasAccess = await access.IsPrincipleInRole("admin_02", StandardRoles.Administrator.Id, contextUserId);

            Assert.IsFalse(hasAccess, "User should not be in role");

            // check user can consume a cert for a given domain
            var isAuthorised = await access.IsAuthorised("devops_user_01", StandardRoles.CertificateConsumer.Id, ResourceTypes.Domain, "www.example.com", contextUserId);

            Assert.IsTrue(isAuthorised, "User should be a cert consumer for this domain");

            // check user can't consume a cert for a subdomain they haven't been granted
            isAuthorised = await access.IsAuthorised("devops_user_01", StandardRoles.CertificateConsumer.Id, ResourceTypes.Domain, "secure.example.com", contextUserId);

            Assert.IsFalse(isAuthorised, "User should not be a cert consumer for this domain");

            // check user can consume any subdomain via a granted wildcard
            isAuthorised = await access.IsAuthorised("devops_user_01", StandardRoles.CertificateConsumer.Id, ResourceTypes.Domain, "random.microsoft.com", contextUserId);

            Assert.IsTrue(isAuthorised, "User should be a cert consumer for this subdomain via wildcard");

            // check user can't consume a random wildcard
            isAuthorised = await access.IsAuthorised("devops_user_01", StandardRoles.CertificateConsumer.Id, ResourceTypes.Domain, "*  lkjhasdf98862364", contextUserId);

            Assert.IsFalse(isAuthorised, "User should not be a cert consumer for random wildcard");

            // check user can't consume a random wildcard
            isAuthorised = await access.IsAuthorised("devops_user_01", StandardRoles.CertificateConsumer.Id, ResourceTypes.Domain, "  lkjhasdf98862364.*.microsoft.com", contextUserId);

            Assert.IsFalse(isAuthorised, "User should not be a cert consumer for random wildcard");

            // random user should not be authorised
            isAuthorised = await access.IsAuthorised("randomuser", StandardRoles.CertificateConsumer.Id, ResourceTypes.Domain, "random.microsoft.com", contextUserId);

            Assert.IsFalse(isAuthorised, "Unknown user should not be a cert consumer for this subdomain via wildcard");
        }
Exemple #25
0
 public void WriteToDefault()
 {
     Loggy.Info("test");
     appender.MustCatch(LogLevel.Info, "test", "default");
 }
Exemple #26
0
        /// <summary>
        ///     Загружает конфигурационный файл из XML
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="context"></param>
        public void LoadXmlConfig(XElement xml, IBSharpContext context = null)
        {
            foreach (var condition in xml.Elements("machine"))
            {
                var machine = condition.Attr("code").ToLowerInvariant();
                var not     = false;
                if (machine == "not" && !string.IsNullOrWhiteSpace(condition.Attr("name")))
                {
                    not     = true;
                    machine = condition.Attr("name").ToLowerInvariant();
                }
                if ((machine == MachineName && !not) || (not && machine != MachineName))
                {
                    var target = condition.Attr("use");
                    if (context == null)
                    {
                        throw new Exception("Cannot resolve machine-related config cause context is null");
                    }
                    var config = context[target];
                    if (config == null)
                    {
                        throw new Exception("Cannot resolve machine-related config");
                    }
                    xml = config.Compiled;
                    Log.Info("Usage config " + target + " because machine name is " + (not ? "not " : "") + MachineName);
                    break;
                }
            }
            this.BSharpContext = context;
            this.Definition    = xml;
            RootFolder         = xml.ResolveValue("root", RootFolder);
            RootFolder         = xml.ResolveValue(HostUtils.RootFolderXmlName, RootFolder);
            ConfigFolder       = xml.ResolveValue(HostUtils.ConfigFolderXmlName, ConfigFolder);
            DllFolder          = xml.ResolveValue(HostUtils.DllFolderXmlName, DllFolder);
            LogFolder          = xml.ResolveValue(HostUtils.LogFolderXmlName, LogFolder);
            TmpFolder          = xml.ResolveValue(HostUtils.TmpFolderXmlName, TmpFolder);
            LogLevel           = xml.ResolveValue(HostUtils.LogLevelXmlName, "Info").To <LogLevel>();
            UseApplicationName = xml.ResolveValue(HostUtils.UseApplicationName, "false").To <bool>();
            AuthCookieName     = xml.ResolveValue(HostUtils.AuthCookieName, AuthCookieName);
            AuthCookieDomain   = xml.ResolveValue(HostUtils.AuthCookieDomain, AuthCookieDomain);
            EncryptBasis       = xml.ResolveValue(HostUtils.EncryptBasis, Guid.NewGuid().ToString());
            DefaultPage        = xml.ResolveValue(HostUtils.DefaultPage, "default.html");
            MaxRequestSize     = xml.ResolveValue("maxrequestsize", "10000000").ToInt();
            RequireLogin       = xml.ResolveValue("requirelogin").ToBool();
            foreach (XElement bind in xml.Elements(HostUtils.BindingXmlName))
            {
                var  excludehost = bind.Attr("excludehost").SmartSplit();
                bool process     = true;
                if (0 != excludehost.Count)
                {
                    var machine = Environment.MachineName.ToUpperInvariant();
                    foreach (var h in excludehost)
                    {
                        if (machine == h.ToUpperInvariant().Trim())
                        {
                            process = false;
                            break;
                        }
                    }
                }
                if (!process)
                {
                    continue;
                }
                var hostbind = new HostBinding();
                hostbind.Port      = bind.Attr(HostUtils.PortXmlName).ToInt();
                hostbind.Interface = bind.Attr(HostUtils.InterfaceXmlName);
                string schema = bind.Attr(HostUtils.SchemaXmlName);
                if (!string.IsNullOrWhiteSpace(schema))
                {
                    if (schema == HostUtils.HttpsXmlValue)
                    {
                        hostbind.Schema = HostSchema.Https;
                    }
                }
                if (hostbind.Port == 0)
                {
                    hostbind.Port = HostUtils.DefaultBindingPort;
                }
                if (string.IsNullOrWhiteSpace(hostbind.Interface))
                {
                    hostbind.Interface = HostUtils.DefaultBindingInterface;
                }
                Bindings.Add(hostbind);
            }
            foreach (var constant in xml.Elements("constant"))
            {
                if (string.IsNullOrWhiteSpace(constant.Attr("code")))
                {
                    continue;
                }
                Constants[constant.Attr("code").ToLowerInvariant()] = constant.Attr("name");
            }
            foreach (XElement e in xml.Elements(HostUtils.ContentFolder))
            {
                ContentFolders.Add(e.Attr("code"));
            }
            ReadModules(xml);
            foreach (var e in xml.Elements("connection"))
            {
                var name = e.Attr("code");
                var cstr = e.Attr("name");
                if (string.IsNullOrWhiteSpace(name))
                {
                    continue;
                }
                if (string.IsNullOrWhiteSpace(cstr))
                {
                    continue;
                }
                ConnectionStrings[name] = cstr;
            }
            foreach (var e in xml.Elements("static"))
            {
                var name   = e.Attr("code");
                var folder = EnvironmentInfo.ResolvePath(e.Attr("name"));
                var role   = e.Attr("role");
                if (!name.StartsWith("/"))
                {
                    name = "/" + name;
                }
                if (!name.EndsWith("/"))
                {
                    name += "/";
                }
                if (e.Attr("cache").ToBool())
                {
                    this.StaticContentCacheMap[name] = e;
                }
                else
                {
                    this.StaticContentMap[name] = new StaticFolderDescriptor {
                        Key = name, Path = folder, Role = role
                    };
                }
            }
            foreach (var e in xml.Elements("startup"))
            {
                var name = e.Attr("code");
                Initializers.Add(name);
            }
            foreach (XElement e in xml.Elements(HostUtils.ExContentFolder))
            {
                ExtendedContentFolders.Add(e.Attr("code"));
            }
            foreach (XElement e in xml.Elements(HostUtils.IncludeConfigXmlName))
            {
                IncludeConfigMasks.Add(e.Describe().GetEfficienValue());
            }
            foreach (XElement e in xml.Elements(HostUtils.ExcludeConfigXmlName))
            {
                ExcludeConfigMasks.Add(e.Describe().GetEfficienValue());
            }
            foreach (XElement e in xml.Elements("cache"))
            {
                Cached.Add(e.Value);
            }
            foreach (XElement e in xml.Elements("proxize"))
            {
                var key = e.Attr("code");
                var url = e.Attr("url");
                if (string.IsNullOrWhiteSpace(url))
                {
                    if (!string.IsNullOrWhiteSpace(e.Attr("appid")))
                    {
                        url += "appid=" + e.Attr("appid") + ";";
                    }
                    if (!string.IsNullOrWhiteSpace(e.Attr("secure")))
                    {
                        url += "secure=" + e.Attr("secure") + ";";
                    }
                    if (!string.IsNullOrWhiteSpace(e.Attr("server")))
                    {
                        url += "server=" + e.Attr("server") + ";";
                    }
                }
                Proxize[key] = url;
            }
            foreach (XElement e in xml.Elements("lib"))
            {
                AutoconfigureAssemblies.Add(e.AttrOrValue("code"));
            }
            ForceNoCache = xml.Attr("forcenocache").ToBool();

            var appid = xml.ResolveValue("appid", "0").ToInt();

            if (appid != 0)
            {
                AddQorpentBinding(appid);
                Loggy.Info(string.Concat("AppId is [", appid, "]"));
            }

            LoggerName   = xml.ResolveValue("loggername", "");
            LoggerHost   = xml.ResolveValue("loggerhost", "");
            LoggerPort   = xml.ResolveValue("loggerport", "0").ToInt();
            LoggerFormat = xml.ResolveValue("loggerformat", "").Replace("%{", "${");

            this.AccessAllowOrigin = xml.ResolveValue("origin", "");

            foreach (var e in xml.Elements("require"))
            {
                var appname = e.Attr("code") + e.Attr("suffix");

                var proxize = e.GetSmartValue("proxize").ToBool() || e.Attr("name") == "proxize";
                if (proxize)
                {
                    if (null == context)
                    {
                        this.Log.Error("context not provi " + appname);
                    }
                    var cls = context[appname];
                    if (null == cls)
                    {
                        this.Log.Error("cannot find application for proxize " + appname);
                    }
                    else
                    {
                        var sappid   = cls.Compiled.ResolveValue("appid");
                        var services = cls.Compiled.Elements("service");
                        foreach (var srv in services)
                        {
                            var root   = srv.Attr("code");
                            var server = e.Attr("server");
                            var cp     = "appid=" + sappid + ";";
                            if (!string.IsNullOrWhiteSpace(server))
                            {
                                cp += "server=" + server;
                            }
                            this.Proxize[root] = cp;
                        }
                    }
                }
            }
        }
Exemple #27
0
 public TrustedOrigin()
 {
     this.logg = Loggy.Get("sys.sec.trusted");
 }
Exemple #28
0
 public void ValidLevelDetection()
 {
     Assert.True(Loggy.IsForInfo());
     Assert.False(Loggy.IsForTrace());
 }