public void Both_hostIds_for_paths_with_spaces_are_equal()
        {
            var information3 = HostInformation.CreateHostInformation("\"pathto\\mysuper duper.exe\" \"somevar with spaces\"", "MyMachine");
            var information4 = HostInformation.CreateHostInformation("\"pathto\\mysuper duper.exe\" somevar", "MyMachine");

            Assert.IsTrue(information3.HostId == information4.HostId);
        }
            public Configuration(Settings settings,
                                 List <Type> availableTypes,
                                 CriticalError criticalError,
                                 StartupDiagnosticEntries startupDiagnostics,
                                 string diagnosticsPath,
                                 Func <string, Task> hostDiagnosticsWriter,
                                 string endpointName,
                                 IServiceCollection services,
                                 string installationUserName,
                                 bool shouldRunInstallers,
                                 List <Action <IServiceCollection> > userRegistrations)
            {
                AvailableTypes        = availableTypes;
                CriticalError         = criticalError;
                StartupDiagnostics    = startupDiagnostics;
                DiagnosticsPath       = diagnosticsPath;
                HostDiagnosticsWriter = hostDiagnosticsWriter;
                EndpointName          = endpointName;
                Services             = services;
                InstallationUserName = installationUserName;
                ShouldRunInstallers  = shouldRunInstallers;
                UserRegistrations    = userRegistrations;

                settings.ApplyHostIdDefaultIfNeeded();
                HostInformation = new HostInformation(settings.HostId, settings.DisplayName, settings.Properties);
            }
 public void SetUp()
 {
     information1 = HostInformation.CreateHostInformation("\"pathto\\mysuperduper.exe\" somevar", "MyMachine");
     information2 = HostInformation.CreateHostInformation("pathto\\mysuperduper.exe somevar", "MyMachine");
     information3 = HostInformation.CreateHostInformation("\"pathto\\mysuper duper.exe\" \"somevar with spaces\"", "MyMachine");
     information4 = HostInformation.CreateHostInformation("\"pathto\\mysuper duper.exe\" somevar", "MyMachine");
 }
Exemplo n.º 4
0
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            var defaultAddress = context.Settings.LocalAddress();
            var hostInfo       = new HostInformation(context.Settings.Get <Guid>("NServiceBus.HostInformation.HostId"),
                                                     context.Settings.Get <string>("NServiceBus.HostInformation.DisplayName"),
                                                     context.Settings.Get <Dictionary <string, string> >("NServiceBus.HostInformation.Properties"));

            context.Container.ConfigureComponent <Unicast.UnicastBus>(DependencyLifecycle.SingleInstance)
            .ConfigureProperty(u => u.InputAddress, defaultAddress)
            .ConfigureProperty(u => u.HostInformation, hostInfo);

            ConfigureSubscriptionAuthorization(context);

            context.Container.ConfigureComponent <PipelineExecutor>(DependencyLifecycle.SingleInstance);
            ConfigureBehaviors(context);

            var knownMessages = context.Settings.GetAvailableTypes()
                                .Where(context.Settings.Get <Conventions>().IsMessageType)
                                .ToList();

            RegisterMessageOwnersAndBusAddress(context, knownMessages);

            ConfigureMessageRegistry(context, knownMessages);

            if (context.Settings.GetOrDefault <bool>("Endpoint.SendOnly"))
            {
                return;
            }

            SetTransportThresholds(context);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Puts down a record representing an event describing a Message Processing event.
        /// </summary>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="isSent">Whether the message is a request to the remote service (or a response from that service).</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="content">The content associated with the record.</param>
        /// <param name="invocationTarget">The target of the request (a null reference if it's a response).</param>
        /// <param name="methodName">The name of the method.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="transportName">The name of the transport.</param>
        /// <param name="connectionId">The identifier of the connection.</param>
        /// <param name="clssId">The identifier of the Security Session used on the connection level.</param>
        /// <param name="clssName">The name of the Security Session used on the connection level.</param>
        /// <param name="ilssId">The identifier of the Security Session used on the invocation level.</param>
        /// <param name="ilssName">The name of the Security Session used on the invocation level.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteMessageCreatedEvent(string author, LogMessageType type, Exception exception, Message message, bool isSent,
                                             HostInformation remote, Stream content, string invocationTarget, string methodName, int sourceThreadId,
                                             string sourceThreadName, string transportName, int connectionId,
                                             int clssId, string clssName, int ilssId, string ilssName, string description, params object[] parameters)
        {
            if (message == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteMessageCreatedEvent", LogMessageType.Error, null,
                                                     sourceThreadId, sourceThreadName, "The message is not provided. Stack trace: " + Environment.StackTrace);
                return;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.MessageRecord, LogCategory.MessageProcessing, type, author);
                this.WriteException(exception);

                this.WriteMessage(message, isSent, invocationTarget, methodName);
                this.WriteHostInformationId(remote);
                this.WriteBinaryContent(content);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteString(transportName);
                this.BinaryWriter.Write((int)connectionId);
                this.BinaryWriter.Write((int)clssId);
                this.WriteString(clssName);
                this.BinaryWriter.Write((int)ilssId);
                this.WriteString(ilssName);
                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Puts down a record representing an event connected with the specified Security Session Parameters.
        /// </summary>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySessionParameters">The Security Session Parameters.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteSecuritySessionParametersEvent(string author, LogMessageType type, Exception exception,
                                                        Message message, HostInformation remote, int sourceThreadId, string sourceThreadName,
                                                        SecuritySessionParameters securitySessionParameters, string description, params object[] parameters)
        {
            if (message == null || securitySessionParameters == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteMessageCreatedEvent", LogMessageType.Error, null,
                                                     sourceThreadId, sourceThreadName, "The message or SSP is not provided. Stack trace: " + Environment.StackTrace);
                return;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.SecuritySessionParameters, LogCategory.Security, type, author);
                this.WriteException(exception);

                this.WriteMessageSeqNo(message);
                this.WriteHostInformationId(remote);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteSecuritySessionParameters(securitySessionParameters);
                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Puts down detailed information about the specified instance of the HostInformation class.
        /// </summary>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySession">The Security Session.</param>
        /// <param name="securitySessionName">The name of the Security Session</param>
        /// <param name="connectionId">The connection identifier.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteHostInformationEvent(string author, LogMessageType type, Exception exception,
                                              HostInformation remote, int sourceThreadId, string sourceThreadName,
                                              SecuritySession securitySession, string securitySessionName, int connectionId,
                                              string description, params object[] parameters)
        {
            if (remote == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteHostInformationCreatedEvent", LogMessageType.Error, null,
                                                     sourceThreadId, sourceThreadName, "The reference is null. Stack trace: " + Environment.StackTrace);
                return;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.HostInformationInfo, LogCategory.HostInformation, type, author);
                this.WriteException(exception);

                this.WriteHostInformation(remote);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteSecuritySessionId(securitySession);
                this.WriteString(securitySessionName);

                this.BinaryWriter.Write((int)connectionId);
                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Exemplo n.º 8
0
        public unsafe PropertySuite(System.Windows.Media.Imaging.BitmapSource source, ImageModes imageMode)
#endif

        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            getPropertyProc = new GetPropertyProc(PropertyGetProc);
            setPropertyProc = new SetPropertyProc(PropertySetProc);
            this.imageMode  = imageMode;
#if GDIPLUS
            documentWidth  = source.Width;
            documentHeight = source.Height;
#else
            documentWidth  = source.PixelWidth;
            documentHeight = source.PixelHeight;
#endif
            imageMetadata    = new ImageMetadata(source);
            iptcData         = new IPTCData();
            hostInfo         = new HostInformation();
            numberOfChannels = 0;
            hostSerial       = "0";
            disposed         = false;
        }
 public void SetUp()
 {
     information1 = HostInformation.CreateHostInformation("\"pathto\\mysuperduper.exe\" somevar", "MyMachine");
     information2 = HostInformation.CreateHostInformation("pathto\\mysuperduper.exe somevar", "MyMachine");
     information3 = HostInformation.CreateHostInformation("\"pathto\\mysuper duper.exe\" \"somevar with spaces\"", "MyMachine");
     information4 = HostInformation.CreateHostInformation("\"pathto\\mysuper duper.exe\" somevar", "MyMachine");
 }
Exemplo n.º 10
0
 /// <summary>
 /// Puts down the ID of the remote host.
 /// </summary>
 /// <param name="remote">The remote host.</param>
 private void WriteHostInformationId(HostInformation remote)
 {
     this.BinaryWriter.Write((bool)(remote != null));
     if (remote != null)
     {
         this.BinaryWriter.Write((int)remote.LocalHostUniqueIdentifier);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Constructs an instance of the SecuritySession_ZpaServer class.
        /// </summary>
        /// <param name="name">Name of the SecuritySession being created.</param>
        /// <param name="remote">The remote host.</param>
        /// <param name="keyProvider_ZpaServer">The server key provider.</param>
        public SecuritySession_ZpaServer(string name, HostInformation remote, KeyProvider_ZpaServer keyProvider_ZpaServer)
            : base(name, remote, keyProvider_ZpaServer.ZpaFeatureFlags)
        {
            this.KeyProvider_ZpaServer = keyProvider_ZpaServer;
            Random random = new Random();

            this.Salt = ZeroProofAuthorizationUtility.GenerateArbitrarySequence(128 + random.Next(128));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Runs a set of basic test on a target HTTP or WebSocket to see if things are properly configured.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="family"></param>
        /// <returns></returns>
        private async Task <HostInformation> ParseHost(string host, ushort port, AddressFamily family = AddressFamily.InterNetwork)
        {
            //Check if the host is valid
            var hostInformation = new HostInformation
            {
                HostName           = host,
                Port               = port,
                AddressFamily      = family,
                AddressInformation = new List <AddressInformation>(),
                HostValid          = await HostValid(host)
            };

            if (!hostInformation.HostValid)
            {
                return(hostInformation);
            }
            var lookup = new LookupClient();
            var result = await lookup.QueryAsync(host, family == AddressFamily.InterNetwork?QueryType.A : QueryType.AAAA);

            if (result == null)
            {
                throw new DnsResponseException("DNS Failed to parse.");
            }

            hostInformation.AddressInformation = GetRecords(result.Answers, port, family);
            if (hostInformation.AddressInformation.Count == 0)
            {
                return(hostInformation);
            }

            hostInformation.HasTargetAddressFamily = true;
            //Can we reach the host?
            hostInformation.CouldPingHostName = PingHost(host, port, family);
            if (!hostInformation.CouldPingHostName)
            {
                return(hostInformation);
            }
            using (var client = new TcpClient(family))
            {
                client.LingerState = new LingerOption(true, 0);
                await client.ConnectAsync(host, port);

                using (var stream = client.GetStream())
                    //Check for an SSL cert on the remote host and attempt to validate it.
                    using (var sslStream = new SslStream(stream, false, (o, certificate, chain, errors) => UserCertificateValidationCallback(o, certificate, chain, errors, ref hostInformation)))
                    {
                        try
                        {
                            sslStream.AuthenticateAsClient(host);
                            return(hostInformation);
                        }
                        catch
                        {
                            return(hostInformation);
                        }
                    }
            }
        }
 public HeartbeatSender(IMessageDispatcher dispatcher, HostInformation hostInfo, ServiceControlBackend backend, string endpointName, TimeSpan interval, TimeSpan timeToLive)
 {
     this.dispatcher   = dispatcher;
     this.hostInfo     = hostInfo;
     this.backend      = backend;
     this.endpointName = endpointName;
     this.interval     = interval;
     this.timeToLive   = timeToLive;
 }
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            var hostInformation = new HostInformation(context.Settings.Get<Guid>(HostIdSettingsKey),
                context.Settings.Get<string>("NServiceBus.HostInformation.DisplayName"),
                context.Settings.Get<Dictionary<string, string>>("NServiceBus.HostInformation.Properties"));

            context.Container.ConfigureComponent(() => hostInformation, DependencyLifecycle.SingleInstance);

            var endpointName = context.Settings.EndpointName();
            context.Pipeline.Register("AuditHostInformation", new AuditHostInformationBehavior(hostInformation, endpointName), "Adds audit host information");
            context.Pipeline.Register("AddHostInfoHeaders", new AddHostInfoHeadersBehavior(hostInformation, endpointName), "Adds host info headers to outgoing headers");
        }
Exemplo n.º 15
0
        public bool InitializeSecurityData(ResourceProperties resourceProperties, string clientKey, string storeNumber, PawnSecVO pSecVo,
                                           out string machineName, out string ipAddress, out string macAddress)
        {
            machineName = string.Empty;
            ipAddress   = string.Empty;
            macAddress  = string.Empty;
            if (this.encryptedConfig != null)
            {
                return(true);
            }
            this.pawnSecLogger.logMessage(LogLevel.DEBUG, this, "InitializeSecurityData()...");
            if (this.dataAccessor == null || this.state == PawnSecState.DISCONNECTED)
            {
                this.pawnSecLogger.logMessage(LogLevel.ERROR, this, "- Data Accessor is invalid or disconnected");
                return(false);
            }

            //Retrieve the machine name
            machineName = System.Environment.MachineName;
            if (this.pawnSecLogger.IsLogDebug)
            {
                this.pawnSecLogger.logMessage(
                    LogLevel.DEBUG, "- Machine Name From Environment: {0}", machineName);
            }
            machineName = string.Concat(machineName, MACHINE_SERVER);
            this.pawnSecLogger.logMessage(LogLevel.INFO, this, "- Machine Name = {0}", machineName);

            try
            {
                //Create the host information object
                this.hostInfo = new HostInformation(this.pawnSecLogger);

                //Retrieve the Ip address
                ipAddress = hostInfo.IPAddress;
                this.pawnSecLogger.logMessage(LogLevel.DEBUG, this, "- IP Address  = {0}", ipAddress);

                //Retrieve the MAC address
                macAddress = hostInfo.MACAddress;
                this.pawnSecLogger.logMessage(LogLevel.DEBUG, this, "- MAC Address = {0}", macAddress);
            }
            catch (Exception eX)
            {
                ipAddress  = null;
                macAddress = null;
                this.pawnSecLogger.logMessage(LogLevel.WARN, this, "- Could not retrieve MAC address or IP address - default to machine name: {0}", machineName);
                return(false);
            }

            this.encryptedConfig = new EncryptedConfigContainer(resourceProperties.PrivateKey,
                                                                clientKey, storeNumber, pSecVo);
            return(true);
        }
Exemplo n.º 16
0
        protected internal override void Setup(FeatureConfigurationContext context)
        {
            var hostInformation = new HostInformation(context.Settings.Get <Guid>(HostIdSettingsKey),
                                                      context.Settings.Get <string>("NServiceBus.HostInformation.DisplayName"),
                                                      context.Settings.Get <Dictionary <string, string> >("NServiceBus.HostInformation.Properties"));

            context.Container.ConfigureComponent(() => hostInformation, DependencyLifecycle.SingleInstance);

            var endpointName = context.Settings.EndpointName();

            context.Pipeline.Register("AuditHostInformation", new AuditHostInformationBehavior(hostInformation, endpointName), "Adds audit host information");
            context.Pipeline.Register("AddHostInfoHeaders", new AddHostInfoHeadersBehavior(hostInformation, endpointName), "Adds host info headers to outgoing headers");
        }
        public void Run()
        {
            if (SafeRoleEnvironment.IsAvailable)
            {
                var host = SafeRoleEnvironment.CurrentRoleName;
                var instance = SafeRoleEnvironment.CurrentRoleInstanceId;
                var hostId = DeterministicGuid(instance, host);

#pragma warning disable 618
                var hostInfo = new HostInformation(hostId, host, instance);
#pragma warning restore 618

                unicastBus.HostInformation = hostInfo;
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Constructs an instance of the SecuritySession_SelfEstablishingSymmetric class.
 /// </summary>
 /// <param name="name">Name of the SecuritySession being created.</param>
 /// <param name="remote">The remote host.</param>
 public SecuritySession_SelfEstablishingSymmetric(string name, HostInformation remote)
     : base(name, remote)
 {
     // to avoid an issue described in Q322371
     try
     {
         // try the usual way, and if fails, use the patch in the catch block
         this._rsaCryptoServiceProviderDecryptor = new RSACryptoServiceProvider();
     }
     catch
     {
         CspParameters _CSPParam = new CspParameters();
         _CSPParam.Flags = CspProviderFlags.UseMachineKeyStore;
         this._rsaCryptoServiceProviderDecryptor = new RSACryptoServiceProvider(_CSPParam);
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Sends one-way message to the remote host. Ignores all exceptions and does not
        /// receive the response.
        /// </summary>
        /// <param name="destination">The remote host.</param>
        /// <param name="serviceName">The name of the entry.</param>
        /// <param name="content">The content.</param>
        public void SendOneWay(HostInformation destination, string serviceName, Stream content)
        {
            try
            {
                // create the message
                Message message = new Message(this.ITransportContext, destination, 0, new TransportHeaders(), content);
                message.IsOneWay                = true;
                message.GenuineMessageType      = GenuineMessageType.ExternalStreamConsumer;
                message.DestinationMarshalByRef = serviceName;

                // and send the message
                this.ITransportContext.ConnectionManager.Send(message);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Sends the content of the log to the remote host.
        /// </summary>
        /// <param name="stream">The stream containing a request or a response.</param>
        /// <param name="sender">The remote host that sent this request.</param>
        /// <returns>The response.</returns>
        public Stream HandleMessage(Stream stream, HostInformation sender)
        {
            if (_stopped)
            {
                return(Stream.Null);
            }

            int expectedSize = 640000;

            // copy to an intermediate stream
            GenuineChunkedStream intermediateStream = new GenuineChunkedStream(true);

            GenuineUtility.CopyStreamToStream(this._memoryWritingStream, intermediateStream, expectedSize);

            // and send it as one chunk
            return(intermediateStream);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Sends the content to the specified remote host and redirects a response to the callback.
        /// </summary>
        /// <param name="destination">The remote host.</param>
        /// <param name="serviceName">The name of the service.</param>
        /// <param name="content">The content.</param>
        /// <param name="iStreamResponseHandler">The response handler.</param>
        /// <param name="tag">The object that contains data about this invocation.</param>
        public void SendAsync(HostInformation destination, string serviceName, Stream content, IStreamResponseHandler iStreamResponseHandler, object tag)
        {
            // create the message
            Message message = new Message(this.ITransportContext, destination, 0, new TransportHeaders(), content);

            message.IsSynchronous           = false;
            message.GenuineMessageType      = GenuineMessageType.ExternalStreamConsumer;
            message.DestinationMarshalByRef = serviceName;
            message.Tag = tag;

            // register the response catcher
            UniversalAsyncResponseProcessor universalAsyncResponseProcessor = new UniversalAsyncResponseProcessor(message, null, iStreamResponseHandler);

            this.ITransportContext.IIncomingStreamHandler.RegisterResponseProcessor(message.MessageId, universalAsyncResponseProcessor);

            // and send the message
            this.ITransportContext.ConnectionManager.Send(message);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes an instance of the SecuritySession class.
        /// </summary>
        /// <param name="name">The name of the Security Session.</param>
        /// <param name="remote">Information about remote host.</param>
        public SecuritySession(string name, HostInformation remote)
        {
            this._name  = name;
            this.Remote = remote;

            // LOG:
            BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;

            if (binaryLogWriter != null && binaryLogWriter[LogCategory.Security] > 0)
            {
                binaryLogWriter.WriteEvent(LogCategory.Security, "SecuritySession.SecuritySession",
                                           LogMessageType.SecuritySessionCreated, null, null, remote, null,
                                           GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, this,
                                           name, -1,
                                           0, 0, 0, this.GetType().Name, null, null, null,
                                           "Security Session has been created.");
            }
        }
        /// <summary>
        /// Closes the specified connections to the remote host and releases acquired resources.
        /// </summary>
        /// <param name="hostInformation">The host information.</param>
        /// <param name="genuineConnectionType">A value indicating what kind of connections will be affected by this operation.</param>
        /// <param name="reason">The reason of resource releasing.</param>
        public override void ReleaseConnections(HostInformation hostInformation, GenuineConnectionType genuineConnectionType, Exception reason)
        {
            BinaryLogWriter binaryLogWriter = this.ITransportContext.BinaryLogWriter;

            reason = GenuineExceptions.Get_Channel_ConnectionShutDown(reason);

            // LOG:
            if (binaryLogWriter != null && binaryLogWriter[LogCategory.Connection] > 0)
            {
                binaryLogWriter.WriteEvent(LogCategory.Connection, "SharedMemoryConnectionManager.ReleaseConnections",
                                           LogMessageType.ReleaseConnections, reason, null, hostInformation, null,
                                           GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                                           null, null, -1, 0, 0, 0, Enum.Format(typeof(GenuineConnectionType), genuineConnectionType, "g"), null, null, null,
                                           "Connections \"{0}\" will be terminated.", Enum.Format(typeof(GenuineConnectionType), genuineConnectionType, "g"), null);
            }

            if (hostInformation == null)
            {
                this.InternalDispose(reason);
                return;
            }

            SharedMemoryConnection sharedMemoryConnection = null;

            if (hostInformation.Url != null)
            {
                sharedMemoryConnection = this._persistent[hostInformation.Url] as SharedMemoryConnection;
            }
            if (sharedMemoryConnection != null)
            {
                this.ConnectionFailed(reason, sharedMemoryConnection);
            }

            sharedMemoryConnection = null;
            if (hostInformation.Uri != null)
            {
                sharedMemoryConnection = this._persistent[hostInformation.Uri] as SharedMemoryConnection;
            }
            if (sharedMemoryConnection != null)
            {
                this.ConnectionFailed(reason, sharedMemoryConnection);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Puts down a structure describing the specified remote host.
        /// </summary>
        /// <param name="remote">The HostInformation.</param>
        private void WriteHostInformation(HostInformation remote)
        {
            if (remote == null)
            {
                this.BinaryWriter.Write((bool)false);
            }
            else
            {
                this.BinaryWriter.Write((bool)true);

                this.BinaryWriter.Write((int)remote.LocalHostUniqueIdentifier);
                this.BinaryWriter.Write((int)remote.RemoteHostUniqueIdentifier);
                this.WriteString(remote.Url);
                this.WriteString(remote.Uri);
                this.WriteString(remote.PrimaryUri);
                this.BinaryWriter.Write((int)GenuineUtility.GetMillisecondsLeft(remote.ExpireTime));
                this.WriteObjectAsString(remote.LocalPhysicalAddress);
                this.WriteObjectAsString(remote.PhysicalAddress);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Puts down a record containing Connection Parameters.
        /// </summary>
        /// <param name="logCategory">The category of the event.</param>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="iParameterProvider">The connection parameters.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="connectionId">The identifier of the connection.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteConnectionParameterEvent(LogCategory logCategory, string author, LogMessageType type, Exception exception,
                                                  HostInformation remote, IParameterProvider iParameterProvider, int sourceThreadId, string sourceThreadName,
                                                  int connectionId, string description, params object[] parameters)
        {
            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.ConnectionParametersRecord, logCategory, type, author);
                this.WriteException(exception);

                this.WriteHostInformationId(remote);
                this.BinaryWriter.Write((int)connectionId);
                this.WriteConnectionParameters(iParameterProvider);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
 static void AddDiagnostics(ReadOnlySettings settings, HostInformation hostInformation)
 {
     settings.AddStartupDiagnosticsSection("Hosting", new
     {
         hostInformation.HostId,
         HostDisplayName = hostInformation.DisplayName,
         RuntimeEnvironment.MachineName,
         OSPlatform = Environment.OSVersion.Platform,
         OSVersion  = Environment.OSVersion.VersionString,
         GCSettings.IsServerGC,
         GCLatencyMode = GCSettings.LatencyMode,
         Environment.ProcessorCount,
         Environment.Is64BitProcess,
         CLRVersion = Environment.Version,
         Environment.WorkingSet,
         Environment.SystemPageSize,
         HostName = Dns.GetHostName(),
         Environment.UserName,
         PathToExe = PathUtilities.SanitizedPath(Environment.CommandLine)
     });
 }
Exemplo n.º 27
0
        public void SetUp()
        {
            bus = MockRepository.GenerateStub <IBus>();
            var transportInspector = MockRepository.GenerateStub <ITransportInspector>();

            transportInfo = new TransportInfo {
                Adress = "test@localhost"
            };

            transportInspector.Stub(x => x.GetTransportInformation()).Return(transportInfo);

            var hostInspector = MockRepository.GenerateStub <IHostInspector>();

            hostInformation = new HostInformation();
            hostInspector.Stub(x => x.GetHostInformation()).Return(hostInformation);

            var endpointMonotor = new EndpointMonitor(bus,
                                                      transportInspector,
                                                      hostInspector);

            endpointMonotor.Start();
        }
Exemplo n.º 28
0
        /// <summary>
        /// Puts down a record describing a general Genuine Channels event.
        /// </summary>
        /// <param name="logCategory">The category of the event.</param>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="content">The content associated with the record.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySession">The Security Session.</param>
        /// <param name="securitySessionName">The name of the Security Session</param>
        /// <param name="writeDispatcherSettings">A value indicating whether it is necessary to put down broadcast dispatcher's settings.</param>
        /// <param name="dispatcher">The broadcast dispatcher.</param>
        /// <param name="resultCollector">The broadcast result collector.</param>
        /// <param name="writeReceiverInfoSettings">A value indicating whether it is necessary to put down information about the specified broadcast recipient.</param>
        /// <param name="receiverInfo">The broadcast recipient.</param>
        /// <param name="string1">The first string that elaborates the current event.</param>
        /// <param name="string2">The second string that elaborates the current event.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteBroadcastEngineEvent(LogCategory logCategory, string author, LogMessageType type, Exception exception,
                                              Message message, HostInformation remote, Stream content, int sourceThreadId, string sourceThreadName,
                                              SecuritySession securitySession, string securitySessionName,
                                              bool writeDispatcherSettings, Dispatcher dispatcher, ResultCollector resultCollector, bool writeReceiverInfoSettings,
                                              ReceiverInfo receiverInfo, string string1, string string2, string description, params object[] parameters)
        {
            if (dispatcher == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteBroadcastEngineEvent", LogMessageType.Error, null,
                                                     sourceThreadId, sourceThreadName, "The reference is null. Stack trace: " + Environment.StackTrace);
                return;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.TransportBroadcastEngineRecord, logCategory, type, author);
                this.WriteException(exception);

                this.WriteMessageSeqNo(message);
                this.WriteHostInformationId(remote);
                this.WriteBinaryContent(content);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteSecuritySessionId(securitySession);
                this.WriteString(securitySessionName);

                this.WriteResultCollectorId(resultCollector);
                this.WriteDispatcherSettings(writeDispatcherSettings, dispatcher);
                this.WriteReceiverInfo(writeReceiverInfoSettings, receiverInfo);

                this.WriteString(string1);
                this.WriteString(string2);
                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Constructs an instance of the Message class.
        /// </summary>
        /// <param name="iTransportContext">The Transport Context.</param>
        /// <param name="recipient">Recipient.</param>
        /// <param name="replyToId">Source id or zero.</param>
        /// <param name="iTransportHeaders">Transport headers.</param>
        /// <param name="stream">Message.</param>
        public Message(ITransportContext iTransportContext, HostInformation recipient, int replyToId, ITransportHeaders iTransportHeaders, Stream stream)
        {
            this.ITransportContext = iTransportContext;
            this.ITransportHeaders = iTransportHeaders;
            this.Recipient         = recipient;
            this.ReplyToId         = replyToId;
            this.Stream            = stream;

            if (this.ITransportHeaders != null)
            {
                this.ITransportHeaders[TransportHeadersSenderEntryName] = this.Sender;
            }

            this.MessageId = Interlocked.Increment(ref _currentMessageId);

#if TRIAL
            if (this.MessageId > 3001)
            {
                throw GenuineExceptions.Get_Channel_TrialConditionExceeded("The maximum number of messages restriction has been exceeded. You can not send more than 3000 messages using TRIAL version.");
            }
#endif
        }
Exemplo n.º 30
0
        /// <summary>
        /// Parameterless Constructor to establish default assignments
        /// </summary>
        public SecurityAccessor()
        {
            this.dataAccessor = null;
            this.errorMessage = String.Empty;
            this.state        = PawnSecState.DISCONNECTED;
            this.hostInfo     = null;

            this.dbHost     = String.Empty;
            this.dbPassword = String.Empty;
            this.dbPort     = String.Empty;
            this.dbSchema   = String.Empty;
            this.dbService  = String.Empty;
            this.dbUser     = String.Empty;

            var dNow     = DateTime.Now;
            var yearStr  = dNow.Date.Year.ToString().PadLeft(4, '0');
            var monthStr = dNow.Date.Month.ToString().PadLeft(2, '0');
            var dayStr   = dNow.Date.Day.ToString().PadLeft(2, '0');
            var hrStr    = dNow.Hour.ToString().PadLeft(2, '0');
            var minStr   = dNow.Minute.ToString().PadLeft(2, '0');
            var sb       = new StringBuilder(64);
            //Determine current executable location and log directory if it exists
            string curDir = System.IO.Directory.GetCurrentDirectory();

            sb.Append(curDir + @"\logs\pawnsec_details_");
            sb.AppendFormat("{0}_{1}_{2}-{3}_{4}.log", yearStr, monthStr, dayStr, hrStr, minStr);
            this.pawnSecLogger = new TempFileLogger(sb.ToString(),
                                                    DefaultLoggerHandlers.defaultLogLevelCheckHandler,
                                                    DefaultLoggerHandlers.defaultLogLevelGenerator,
                                                    DefaultLoggerHandlers.defaultLogMessageHandler,
                                                    DefaultLoggerHandlers.defaultLogMessageFormatHandler,
                                                    DefaultLoggerHandlers.defaultDateStampGenerator);
            this.pawnSecLogger.setLogLevel(LogLevel.DEBUG);
            this.pawnSecLogger.logMessage(LogLevel.INFO, this, "PAWNSECAccessor instance constructed");

            //Clear out encrypted container
            this.encryptedConfig = null;
        }
Exemplo n.º 31
0
        /// <summary>
        /// Puts down a record describing a general Genuine Channels event.
        /// </summary>
        /// <param name="logCategory">The category of the event.</param>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="content">The content associated with the record.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySession">The Security Session.</param>
        /// <param name="securitySessionName">The name of the Security Session</param>
        /// <param name="connectionId">The identifier of the connection.</param>
        /// <param name="number1">An additional integer parameter.</param>
        /// <param name="number2">An additional integer parameter.</param>
        /// <param name="number3">An additional integer parameter.</param>
        /// <param name="string1">The first string that elaborates the current event.</param>
        /// <param name="string2">The second string that elaborates the current event.</param>
        /// <param name="string3">The third string that elaborates the current event.</param>
        /// <param name="string4">The fourth string that elaborates the current event.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteEvent(LogCategory logCategory, string author, LogMessageType type, Exception exception,
                               Message message, HostInformation remote, Stream content, int sourceThreadId, string sourceThreadName,
                               SecuritySession securitySession, string securitySessionName,
                               int connectionId, int number1, int number2, int number3, string string1, string string2, string string3, string string4, string description, params object[] parameters)
        {
            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.GeneralRecord, logCategory, type, author);
                this.WriteException(exception);

                this.WriteMessageSeqNo(message);
                this.WriteHostInformationId(remote);
                this.WriteBinaryContent(content);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteSecuritySessionId(securitySession);
                this.WriteString(securitySessionName);

                this.BinaryWriter.Write((int)connectionId);

                this.BinaryWriter.Write((int)number1);
                this.BinaryWriter.Write((int)number2);
                this.BinaryWriter.Write((int)number3);

                this.WriteString(string1);
                this.WriteString(string2);
                this.WriteString(string3);
                this.WriteString(string4);

                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// Constructs an instance of the SecuritySession_SspiClient class.
 /// </summary>
 /// <param name="name">Name of the SecuritySession being created.</param>
 /// <param name="remote">The remote host.</param>
 /// <param name="keyProvider_SspiServer">Parent KeyProvider_SspiServer instance to get settings from.</param>
 public SecuritySession_SspiServer(string name, HostInformation remote, KeyProvider_SspiServer keyProvider_SspiServer)
     : base(name, remote)
 {
     this.KeyProvider_SspiServer = keyProvider_SspiServer;
 }
 /// <summary>
 /// Constructs an instance of the ConnectionSignaller class.
 /// </summary>
 /// <param name="remote">The remote host.</param>
 /// <param name="iGenuineEventProvider">The event provider.</param>
 public ConnectionStateSignaller(HostInformation remote, IGenuineEventProvider iGenuineEventProvider)
 {
     this._remote = remote;
     this._iGenuineEventProvider = iGenuineEventProvider;
     this._currentState          = GenuineEventType.GeneralConnectionIndeterminate;
 }