Ejemplo n.º 1
0
 public DirectoryAgentAdvert(ServiceUri uri)
     : this()
 {
     if (uri.ServiceType != "directory-agent")
         throw new ArgumentException("A directory-agent service URI is the only allowed value.");
     Uri = uri;
 }
Ejemplo n.º 2
0
 public ServiceAgentAdvert(ServiceUri uri)
     : this()
 {
     if (uri.ServiceType != "service-agent")
         throw new ArgumentException("A service-agent is the only allowable uri");
     Uri = uri;
 }
Ejemplo n.º 3
0
        internal override void Create(SlpReader reader)
        {
            base.Create(reader);

            ErrorCode     = (ServiceErrorCode)reader.ReadInt16();
            BootTimeStamp = reader.ReadDateTime();
            var url = reader.ReadString();

            Scopes.AddRange(reader.ReadList());
            Uri = new ServiceUri(url, Services.Locator.GetInstance <AttributeCollection>(reader));
            SpiStrings.AddRange(reader.ReadList());
            ReadAuthBlocks(reader, AuthBlocks);
        }
        public SsoResponse ValidateAuthenticationStatus(
            Identity identity,
            ServiceName serviceName,
            ServiceUri serviceUri
            )
        {
            var(controlledByRules, matchingAccessControl) = GetFirstMatchingAccessControl(serviceName, serviceUri, identity);
            if (matchingAccessControl != null)
            {
                var blockMessage = string.IsNullOrWhiteSpace(matchingAccessControl.BlockMessage)
                    ? _configurationService.Config.DefaultAccessDeniedMessage
                    : matchingAccessControl.BlockMessage;

                return(new SsoResponse(
                           true,
                           identity.IsAuthenticated,
                           true,
                           AccessTier.NoAccess,
                           403,
                           blockMessage
                           ));
            }
            else
            {
                var message = "";
                var status  = 200;
                if (!controlledByRules && identity.AccessTier == AccessTier.NoAccess)
                {
                    if (identity.IsAuthenticated)
                    {
                        status  = 403;
                        message = _configurationService.Config.DefaultAccessDeniedMessage;
                    }
                    else
                    {
                        status  = 401;
                        message = "Login Required";
                    }
                }

                return(new SsoResponse(
                           true,
                           identity.IsAuthenticated,
                           status != 200,
                           identity.AccessTier,
                           status,
                           message
                           ));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Calls GetImageUri() and asynchronously loads an ImageSource from the returned GetMap URL.
        /// </summary>
        protected override async Task <ImageSource> GetImageAsync()
        {
            if (Layers == null && // get first Layer
                ServiceUri != null &&
                ServiceUri.ToString().IndexOf("LAYERS=", StringComparison.OrdinalIgnoreCase) < 0)
            {
                Layers = (await GetLayerNamesAsync())?.FirstOrDefault() ?? "";
            }

            var uri = GetImageUri();

            return(uri != null
                ? await ImageLoader.LoadImageAsync(new Uri(uri.Replace(" ", "%20")))
                : null);
        }
Ejemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (Inputs != null ? Inputs.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Outputs != null ? Outputs.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ServiceUri != null ? ServiceUri.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ServiceName != null ? ServiceName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Category != null ? Category.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ RunWorkflowAsync.GetHashCode();
         hashCode = (hashCode * 397) ^ IsObject.GetHashCode();
         return(hashCode);
     }
 }
        private IEnumerable <Uri> GetEsServiceUriList(IHealthReporter healthReporter)
        {
            var esServiceUri = ServiceUri
                               .Split(';')
                               .Where(x => Uri.IsWellFormedUriString(x, UriKind.Absolute))
                               .Select(x => new Uri(x))
                               .ToList();

            if (!esServiceUri.Any())
            {
                //Invalid config string report and throw
                var errorMessage = $"{nameof(ElasticSearchOutput)}:  required 'serviceUri' configuration parameter is invalid";
                healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration);
                throw new Exception(errorMessage);
            }
            return(esServiceUri);
        }
Ejemplo n.º 8
0
        private string GetRequestUri(string request)
        {
            var uri = ServiceUri.ToString();

            if (!uri.EndsWith("?") && !uri.EndsWith("&"))
            {
                uri += !uri.Contains("?") ? "?" : "&";
            }

            if (uri.IndexOf("SERVICE=", StringComparison.OrdinalIgnoreCase) < 0)
            {
                uri += "SERVICE=WMS&";
            }

            if (uri.IndexOf("VERSION=", StringComparison.OrdinalIgnoreCase) < 0)
            {
                uri += "VERSION=1.3.0&";
            }

            return(uri + "REQUEST=" + request);
        }
        private (bool, AccessControl) GetFirstMatchingAccessControl(ServiceName serviceName,
                                                                    ServiceUri serviceUri,
                                                                    Identity identity)
        {
            var controls = GetAccessControls(serviceName);
            var matching = controls
                           .Where(control => control.Path == null || serviceUri.Value.StartsWith(control.Path))
                           .FirstOrDefault(control =>
            {
                var block = control.ControlType == ControlType.Allow
                        ? identity.AccessTier.IsHigherTierThan(control.MinimumAccessTier ?? AccessTier.Failure)
                        : identity.AccessTier.IsLowerTierThan(control.MinimumAccessTier ?? AccessTier.NoAccess);
                if (control.Exempt.Contains(identity.Username))
                {
                    block = !block;
                }

                return(block);
            });

            return(controls.Length > 0, matching);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Loads an ImageSource from the URL returned by GetMapRequestUri().
        /// </summary>
        protected override async Task <ImageSource> GetImageAsync()
        {
            ImageSource image = null;

            if (ServiceUri != null)
            {
                if (Layers == null &&
                    ServiceUri.ToString().IndexOf("LAYERS=", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    Layers = (await GetLayerNamesAsync())?.FirstOrDefault() ?? ""; // get first Layer from Capabilities
                }

                var uri = GetMapRequestUri();

                if (!string.IsNullOrEmpty(uri))
                {
                    image = await ImageLoader.LoadImageAsync(new Uri(uri));
                }
            }

            return(image);
        }
        /// <summary>
        /// Initializes the target. Can be used by inheriting classes
        /// to initialize logging.
        /// </summary>
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            _machineName = GetMachineName();

            string connectionString = string.Empty;
            string serviceUri       = string.Empty;
            string tenantIdentity   = string.Empty;
            string resourceIdentity = string.Empty;
            string clientIdentity   = string.Empty;
            string accountName      = string.Empty;
            string accessKey        = string.Empty;

            var defaultLogEvent = LogEventInfo.CreateNullEvent();

            try
            {
                connectionString = ConnectionString?.Render(defaultLogEvent);
                if (string.IsNullOrEmpty(connectionString))
                {
                    serviceUri       = ServiceUri?.Render(defaultLogEvent);
                    tenantIdentity   = TenantIdentity?.Render(defaultLogEvent);
                    resourceIdentity = ResourceIdentity?.Render(defaultLogEvent);
                    clientIdentity   = ClientIdentity?.Render(defaultLogEvent);
                    accountName      = AccountName?.Render(defaultLogEvent);
                    accessKey        = AccessKey?.Render(defaultLogEvent);
                }

                _cloudTableService.Connect(connectionString, serviceUri, tenantIdentity, resourceIdentity, clientIdentity, accountName, accessKey);
                InternalLogger.Trace("AzureDataTablesTarget(Name={0}): Initialized", Name);
            }
            catch (Exception ex)
            {
                InternalLogger.Error(ex, "AzureDataTablesTarget(Name={0}): Failed to create TableClient with connectionString={1}.", Name, connectionString);
                throw;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Display the active options/settings for this Certificate as stored in the registry
        /// </summary>
        public void DisplayOptions()
        {
            _logger.Info("Displaying WinCertes current configuration:");
            _logger.Info("[{0}]", Registry.FullRegistryKey);
            IDNSChallengeValidator dnsChallengeValidator = DNSChallengeValidatorFactory.GetDNSChallengeValidator();
            string ui = ServiceUri.ToString();

            _logger.Info("Service URI:\t\t{0}", (ui == null) ? Certes.Acme.WellKnownServers.LetsEncryptV2.ToString() : ui);
            _logger.Info("Domain(s):\t\t{0}", Domains.Count > 0 ? string.Join(",", Domains) : "ERROR none specified");
            _logger.Info("Account Email:\t{0}", AccountEmail == null ? "ERROR not set" : AccountEmail);
            string accountKey = Registry.ReadStringParameter("AccountKey");

            _logger.Info("AccountKey:\t\t{0}", (accountKey == null || accountKey.Length < 1) ? "Account not registered" : "PrivateKey stored in registry");
            _logger.Info("Registered:\t\t{0}", Registry.ReadIntParameter("Registered") == 1 ? "yes" : "no");
            _logger.Info("Generated:\t\t{0}", Registry.ReadIntParameter("Generated") == 1 ? "yes" : "no");
            if (dnsChallengeValidator != null)
            {
                _logger.Info("Auth. Mode:\t\tdns-01 validation");
            }
            else
            {
                _logger.Info("Auth. Mode:\t\t{0}", Standalone ? "http-01 validation standalone" : "http-01 validation with external web server");
                if (Standalone)
                {
                    _logger.Info("HTTP Port:\t\t{0}", HttpPort);
                }
                else
                {
                    _logger.Info("Web Root:\t\t{0}", WebRoot != null ? WebRoot : Standalone ? "NA" : "ERROR: Missing");
                }
            }
            _logger.Info("IIS Bind Name:\t{0}", BindName ?? "none");
            _logger.Info("Import in CSP:\t{0}", Registry.IsThereConfigParam("noCsp") ? "no" : "yes");
            _logger.Info("PS Script File:\t{0}", ScriptFile ?? "none");
            _logger.Info("Renewal Delay:\t{0}", RenewalDelay + " days");
            _logger.Info("Task Scheduled:\t{0}", Utils.IsScheduledTaskCreated() ? "yes" : "no");
            _logger.Info("Cert Enrolled:\t{0}", Registry.IsThereConfigParam("certSerial") ? "yes" : "no");
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Synchronised write of the registration information. Any change to the Uri or AccountEmail resets registration.
        /// </summary>
        /// <param name="registered"></param>
        private void SaveRegistration(bool registered)
        {
            if (!Initialised)
            {
                return;
            }

            if (registered)
            {
                if (!Registry.ReadBooleanParameter("Registry", false))
                {
                    _logger.Info("Registered: updating AccountEmail, ServiceUri and Registered values in the Certificate Registry store({0})", CertificateName);
                    Registry.WriteBooleanParameter("Registered", registered);
                }
                if (Registry.ReadStringParameter("AccountEmail") != AccountEmail)
                {
                    _logger.Info("Registered: updating AccountEmail in the Certificate Registry store({0})", CertificateName);
                    Registry.WriteStringParameter("AccountEmail", AccountEmail);
                }
                string uri = ServiceUri.ToString();
                if (Registry.ReadStringParameter("ServiceUri") != uri)
                {
                    _logger.Info("Registered: updating ServiceUri in the Certificate Registry store({0})", CertificateName);
                    Registry.WriteStringParameter("ServiceUri", uri);
                }
            }
            else
            {
                if (Registry.ReadBooleanParameter("Registry", true))
                {
                    _logger.Info("Cancelling account registration");
                    Registry.WriteBooleanParameter("Registered", false);
                }
                CertificateGenerated = false;
            }
        }
Ejemplo n.º 14
0
 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
 // ReSharper disable once CSharpWarnings::CS1998
 public async Task ExecuteAsync(Guid eId, object[] parameters, ServiceUri callbackUri)
 {
     this.Execute(eId, parameters, callbackUri);
 }
Ejemplo n.º 15
0
        internal override void Create(SlpReader reader)
        {
            base.Create(reader);

            ErrorCode = (ServiceErrorCode)reader.ReadInt16();
            BootTimeStamp = reader.ReadDateTime();
            var url = reader.ReadString();
            Scopes.AddRange(reader.ReadList());
            Uri = new ServiceUri(url, Services.Locator.GetInstance<AttributeCollection>(reader));
            SpiStrings.AddRange(reader.ReadList());
            ReadAuthBlocks(reader, AuthBlocks);
        }
 public bool Equals(ServiceConnectionString other) =>
 ServiceUri.Equals(other?.ServiceUri) &&
 PartitionKind.Equals(other?.PartitionKind);
Ejemplo n.º 17
0
 public SlpError Update(UInt16 lifetime)
 {
     return(SlpNativeMethods.Reg(hSlp, ServiceUri.ToString(), lifetime, ServiceType, AttributeString, SlpBoolean.False,
                                 (SlpHandle h, SlpError err, IntPtr cookie) => { }, IntPtr.Zero));
 }
        public async Task InvokeGenerateReadRequest(FtpOption ftpOption)
        {
            var ftpDispatchRequest = new DispatchRequest(ftpOption, typeof(FtpOption), ftpOption?.Domain, ReponseParserActor, null);

            //if using sb
            //await GenerateRequestAsync(ftpDispatchEvent);

            // testing only
            var newExecutableOrder = new ExecutableOrchestrationOrder()
            {
                ActorId         = GenerateActorId(),
                ActorServiceUri = (FtpDispatcherActorService != null) ? $"{ApplicationName}/{FtpDispatcherActorService}" : ServiceUri.ToString()
            };

            await ChainNextActorsAsync <IDefaultFtpDispatchAction>(
                c => c.InvokeDispatchReadRequest(ftpDispatchRequest),
                new ActorRequestContext(Id.ToString(),
                                        "FTP_READ_DISPATCH_ACTION_NAME",
                                        Guid.NewGuid().ToString(), CurrentFlowInstanceId), newExecutableOrder, CancellationToken.None);
        }
Ejemplo n.º 19
0
        public override byte[] ConsumeService(Uri ServiceUri, string HttpMethod, byte[] Parameters)
        {
            // apply access token.
            if (string.IsNullOrEmpty(ServiceUri.Query))
            {
                ServiceUri = new Uri(ServiceUri.ToString() + "?access_token=" + this.Token);
            }
            else
            {
                ServiceUri = new Uri(ServiceUri.ToString() + "&access_token=" + this.Token);
            }

            var request = WebRequest.Create(ServiceUri) as HttpWebRequest;

            request.Method = HttpMethod;

            if (HttpMethod == "POST" || HttpMethod == "PUT")
            {
                if (Parameters != null && Parameters.Length > 0)
                {
                    Task <Stream> getRequestStream = Task.Factory.FromAsync(
                        request.BeginGetRequestStream,
                        ar => request.EndGetRequestStream(ar),
                        TaskCreationOptions.None);

                    getRequestStream.ContinueWith(t =>
                    {
                        t.Result.Write(Parameters, 0, Parameters.Length);
                    }).Wait();
                }
            }

            try
            {
                Task <WebResponse> getResponseTask = Task.Factory.FromAsync(
                    request.BeginGetResponse,
                    ar => request.EndGetResponse(ar),
                    TaskCreationOptions.None);
                var ms = new MemoryStream();

                getResponseTask.ContinueWith(t =>
                {
                    using (var s = t.Result.GetResponseStream())
                    {
                        byte[] d      = new byte[4096];
                        int readcount = 0;

                        do
                        {
                            readcount = s.Read(d, 0, d.Length);

                            if (readcount == 0)
                            {
                                break;
                            }

                            ms.Write(d, 0, readcount);
                        }while (readcount > 0);
                    }
                }).Wait();

                ms.Flush();
                ms.Position = 0;

                byte[] data = ms.ToArray();
                ms.Close();

                return(data);
            }
            catch (WebException we)
            {
                var    errorResponse = we.Response as HttpWebResponse;
                string errorInfo     = (new StreamReader(errorResponse.GetResponseStream())).ReadToEnd();

                if (errorResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    throw new OAuthFailedException("ERROR_UNAUTHORIZED", errorInfo);
                }
                else if (errorResponse.StatusCode == HttpStatusCode.BadRequest)
                {
                    throw new OAuthFailedException("ERROR_BAD_REQUEST", errorInfo);
                }
                else
                {
                    throw new OAuthFailedException("ERROR_OTHER", errorInfo);
                }
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initializes the target. Can be used by inheriting classes
        /// to initialize logging.
        /// </summary>
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            string connectionString = string.Empty;
            string serviceUri       = string.Empty;
            string tenantIdentity   = string.Empty;
            string resourceIdentity = string.Empty;

            Dictionary <string, string> blobMetadata = null;
            Dictionary <string, string> blobTags     = null;

            var defaultLogEvent = LogEventInfo.CreateNullEvent();

            try
            {
                connectionString = ConnectionString?.Render(defaultLogEvent);
                if (string.IsNullOrEmpty(connectionString))
                {
                    serviceUri       = ServiceUri?.Render(defaultLogEvent);
                    tenantIdentity   = TenantIdentity?.Render(defaultLogEvent);
                    resourceIdentity = ResourceIdentity?.Render(defaultLogEvent);
                }

                if (BlobMetadata?.Count > 0)
                {
                    blobMetadata = new Dictionary <string, string>();
                    foreach (var metadata in BlobMetadata)
                    {
                        if (string.IsNullOrWhiteSpace(metadata.Name))
                        {
                            continue;
                        }

                        var metadataValue = metadata.Layout?.Render(defaultLogEvent);
                        if (string.IsNullOrEmpty(metadataValue))
                        {
                            continue;
                        }

                        blobMetadata[metadata.Name.Trim()] = metadataValue;
                    }
                }

                if (BlobTags?.Count > 0)
                {
                    blobTags = new Dictionary <string, string>();
                    foreach (var tag in BlobTags)
                    {
                        if (string.IsNullOrWhiteSpace(tag.Name))
                        {
                            continue;
                        }

                        var metadataValue = tag.Layout?.Render(defaultLogEvent);
                        blobTags[tag.Name.Trim()] = metadataValue ?? string.Empty;
                    }
                }

                _cloudBlobService.Connect(connectionString, serviceUri, tenantIdentity, resourceIdentity, blobMetadata, blobTags);
                InternalLogger.Trace("AzureBlobStorageTarget - Initialized");
            }
            catch (Exception ex)
            {
                if (string.IsNullOrEmpty(connectionString) && !string.IsNullOrEmpty(serviceUri))
                {
                    InternalLogger.Error(ex, "AzureBlobStorageTarget(Name={0}): Failed to create BlobClient with ServiceUri={1}.", Name, serviceUri);
                }
                else
                {
                    InternalLogger.Error(ex, "AzureBlobStorageTarget(Name={0}): Failed to create BlobClient with connectionString={1}.", Name, connectionString);
                }
                throw;
            }
        }
Ejemplo n.º 21
0
 public void Execute(Guid eId, object[] parameters, ServiceUri callbackUri)
 {
     this.Execute(eId, parameters, callbackUri != null ? new Services.ServiceUri() { Address = callbackUri.Address } : null);
 }
Ejemplo n.º 22
0
        public override byte[] ConsumeService(Uri ServiceUri, string HttpMethod, byte[] Parameters)
        {
            // apply access token.
            if (string.IsNullOrEmpty(ServiceUri.Query))
            {
                ServiceUri = new Uri(ServiceUri.ToString() + "?access_token=" + this.Token);
            }
            else
            {
                ServiceUri = new Uri(ServiceUri.ToString() + "&access_token=" + this.Token);
            }

            var request = WebRequest.Create(ServiceUri) as HttpWebRequest;

            request.Method = HttpMethod;

            if (HttpMethod == "POST" || HttpMethod == "PUT")
            {
                var requestStream = request.GetRequestStream();

                if (Parameters != null && Parameters.Length > 0)
                {
                    requestStream.Write(Parameters, 0, Parameters.Length);
                }

                requestStream.Close();
            }

            try
            {
                var    response       = request.GetResponse();
                var    responseStream = response.GetResponseStream();
                var    ms             = new MemoryStream();
                byte[] data           = new byte[4096];
                int    readcount      = 0;

                do
                {
                    readcount = responseStream.Read(data, 0, data.Length);

                    if (readcount == 0)
                    {
                        break;
                    }

                    ms.Write(data, 0, readcount);
                }while (readcount > 0);

                responseStream.Close();

                ms.Flush();
                ms.Position = 0;

                data = ms.ToArray();
                ms.Close();

                return(data);
            }
            catch (WebException we)
            {
                var    errorResponse = we.Response as HttpWebResponse;
                string errorInfo     = (new StreamReader(errorResponse.GetResponseStream())).ReadToEnd();

                if (errorResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    throw new OAuthFailedException("ERROR_UNAUTHORIZED", errorInfo);
                }
                else if (errorResponse.StatusCode == HttpStatusCode.BadRequest)
                {
                    throw new OAuthFailedException("ERROR_BAD_REQUEST", errorInfo);
                }
                else
                {
                    throw new OAuthFailedException("ERROR_OTHER", errorInfo);
                }
            }
        }
Ejemplo n.º 23
0
        internal override void Create(SlpReader reader)
        {
            base.Create(reader);

            var tmp = reader.ReadString();
            Scopes.AddRange(reader.ReadList());
            Uri = new ServiceUri(tmp, Services.Locator.GetInstance<AttributeCollection>(reader));
            ReadAuthBlocks(reader, AuthBlocks);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Writes command line parameters into the specified config
        /// </summary>
        /// <remarks>CertificatePath is only ever read from the registry</remarks>
        /// <param name="config">the configuration object</param>
        public void WriteOptionsIntoConfiguration()
        {
            try
            {
                // Private key for the account
                AccountKey = Registry.WriteAndReadStringParameter("AccountKey", AccountKey, null);
                // Should we bind to IIS? If yes, let's do some config
                BindName = Registry.WriteAndReadStringParameter("BindName", BindName);
                // Let's store the CSP name, if any
                Csp = Registry.WriteAndReadStringParameter("CSP", Csp);
                // List of domains to register or already registered
                Domains = Registry.WriteAndReadStringListParameter("Domains", Domains).ConvertAll(d => d.ToLower());
                // write account email into conf, or reads from it, if any
                AccountEmail = Registry.WriteAndReadStringParameter("AccountEmail", AccountEmail);
                // Export the certificate and private key in PEM format
                ExportPem = Registry.WriteAndReadBooleanParameter("ExportPem", ExportPem);
                // Writing HTTP listening Port in conf
                HttpPort = Registry.WriteAndReadIntParameter("HttpPort", HttpPort, 80);
                // Should we store certificate in the CSP?
                noCsp = Registry.WriteAndReadBooleanParameter("NoCsp", noCsp);
                // Certificate file name
                CertificateChallenged = Registry.WriteAndReadBooleanParameter("CertificateChallenged", CertificateChallenged);
                CertificateGenerated  = Registry.WriteAndReadBooleanParameter("CertificateGenerated", CertificateGenerated);
                CertificateName       = Registry.WriteAndReadStringParameter("CertificateName", CertificateName);
                CertificatePath       = Registry.WriteAndReadStringParameter("CertificatePath", CertificatePath);
                // Password for the Certificate
                PfxPassword = Registry.WriteAndReadStringParameter("PfxPassword", pfxPassword);
                // The key has been registered
                Registered = Registry.WriteAndReadBooleanParameter("Registered", Registered);
                // Writing renewal delay to conf
                RenewalDelay = Registry.WriteAndReadIntParameter("RenewalDays", RenewalDelay, 30);
                // Should we execute some PowerShell ? If yes, let's do some config
                ScriptFile = Registry.WriteAndReadStringParameter("ScriptFile", ScriptFile, null);
                // write service URI into conf, or reads from it, if any
                ServiceUri = new Uri(Registry.WriteAndReadStringParameter("ServiceUri", ServiceUri.ToString()));
                // Should we work with the built-in web server
                Standalone = Registry.WriteAndReadBooleanParameter("Standalone", Standalone);
                // do we have a webroot parameter to handle?
                WebRoot = Registry.WriteAndReadStringParameter("WebRoot", WebRoot);

                // DNS keys write if not null or empty string
                Registry.WriteAndReadStringParameter("DNSValidatorType", DNSValidatorType, "");
                Registry.WriteAndReadStringParameter("DNSServerURL", DNSServerURL, "");
                Registry.WriteAndReadStringParameter("DNSServerUser", DNSServerUser, "");
                Registry.WriteAndReadStringParameter("DNSServerKey", DNSServerKey, "");
                Registry.WriteAndReadStringParameter("DNSServerSubDomain", DNSServerSubDomain, "");
                Registry.WriteAndReadStringParameter("DNSServerZone", DNSServerZone, "");
                Registry.WriteAndReadStringParameter("DNSServerPassword", DNSServerPassword, "");
                Registry.WriteAndReadStringParameter("DNSServerHost", DNSServerHost, "");
            }
            catch (Exception e)
            {
                _logger.Error($"Could not Read/Write command line parameters to configuration: {e.Message}");
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Initializes the target. Can be used by inheriting classes
        /// to initialize logging.
        /// </summary>
        protected override void InitializeTarget()
        {
            base.InitializeTarget();

            string connectionString = string.Empty;
            string serviceUri       = string.Empty;
            string tenantIdentity   = string.Empty;
            string resourceIdentity = string.Empty;
            string clientIdentity   = string.Empty;

            Dictionary <string, string> queueMetadata = null;

            var defaultLogEvent = LogEventInfo.CreateNullEvent();

            try
            {
                connectionString = ConnectionString?.Render(defaultLogEvent);
                if (string.IsNullOrEmpty(connectionString))
                {
                    serviceUri       = ServiceUri?.Render(defaultLogEvent);
                    tenantIdentity   = TenantIdentity?.Render(defaultLogEvent);
                    resourceIdentity = ResourceIdentity?.Render(defaultLogEvent);
                    clientIdentity   = ClientIdentity?.Render(defaultLogEvent);
                }

                if (QueueMetadata?.Count > 0)
                {
                    queueMetadata = new Dictionary <string, string>();
                    foreach (var metadata in QueueMetadata)
                    {
                        if (string.IsNullOrWhiteSpace(metadata.Name))
                        {
                            continue;
                        }

                        var metadataValue = metadata.Layout?.Render(defaultLogEvent);
                        if (string.IsNullOrEmpty(metadataValue))
                        {
                            continue;
                        }

                        queueMetadata[metadata.Name.Trim()] = metadataValue;
                    }
                }

                var timeToLive = RenderDefaultTimeToLive();
                if (timeToLive <= TimeSpan.Zero)
                {
                    timeToLive = default(TimeSpan?);
                }

                _cloudQueueService.Connect(connectionString, serviceUri, tenantIdentity, resourceIdentity, clientIdentity, timeToLive, queueMetadata);
                InternalLogger.Trace("AzureQueueStorageTarget - Initialized");
            }
            catch (Exception ex)
            {
                if (string.IsNullOrEmpty(connectionString) && !string.IsNullOrEmpty(serviceUri))
                {
                    InternalLogger.Error(ex, "AzureQueueStorageTarget(Name={0}): Failed to create QueueClient with ServiceUri={1}.", Name, serviceUri);
                }
                else
                {
                    InternalLogger.Error(ex, "AzureQueueStorageTarget(Name={0}): Failed to create QueueClient with connectionString={1}.", Name, connectionString);
                }
                throw;
            }
        }
        public async Task InvokeGenerateWriteRequest(object content)
        {
            if (content is ICsvContent csvContent)
            {
                var csvData            = csvContent.ToCsv();
                var ftpOption          = (await GetFtpConfigsAsync()).ToList().First();
                var ftpWriterOption    = new FtpWriterOption(ftpOption.FtpConfig, csvData.Item1, csvData.Item2);
                var ftpDispatchRequest = new DispatchRequest(ftpWriterOption, typeof(FtpWriterOption), null, ReponseParserActor,
                                                             null);
                // for dispatcher if need to send events
                //await GenerateRequestAsync(ftpDispatchEvent);

                // testing only
                var newExecutableOrder = new ExecutableOrchestrationOrder()
                {
                    ActorId         = GenerateActorId(),
                    ActorServiceUri = (FtpDispatcherActorService != null) ? $"{ApplicationName}/{FtpDispatcherActorService}" : ServiceUri.ToString()
                };

                await ChainNextActorsAsync <IDefaultFtpDispatchAction>(c => c.InvokeDispatchWriteRequest(ftpDispatchRequest), new ActorRequestContext(Id.ToString(), "FTP_WRITE_DISPATCH_ACTION_NAME",
                                                                                                                                                      Guid.NewGuid().ToString(), CurrentFlowInstanceId), newExecutableOrder, CancellationToken.None);
            }
            else
            {
                throw new NotImplementedException($"{CurrentActor} failed to generate content to write to ftp. Interface {nameof(ICsvContent)} or {nameof(IXmlContent)} not implemented on the entity. ");
            }
        }
Ejemplo n.º 27
0
        internal override void Create(SlpReader reader)
        {
            base.Create(reader);

            ReadIPList(reader, PreviousResponders);
            Uri = new ServiceUri(reader.ReadString());
            Scopes.AddRange(reader.ReadList());
            Tags.AddRange(reader.ReadList());
            Spi = reader.ReadString();
        }
Ejemplo n.º 28
0
 public void Setup(IRemoteExecutorService remoteExecutorService, ServiceUri callbackUri)
 {
     this.Initialize(remoteExecutorService);
     if (callbackUri != null)
     {
         this.callbackUri = callbackUri;
         this.callbacksEnabled = true;
     }
     else
     {
         this.callbacksEnabled = false;
     }
 }