public override int GetHashCode()
 {
     return(AppId.GetHashCode() ^ DllSurrogate.GetSafeHashCode()
            ^ RunAs.GetSafeHashCode() ^ Name.GetSafeHashCode() ^ Flags.GetHashCode() ^
            LaunchPermission.GetSafeHashCode() ^ AccessPermission.GetSafeHashCode() ^
            LocalService.GetSafeHashCode() ^ RotFlags.GetHashCode());
 }
Beispiel #2
0
        public Task <Process> Launch(LaunchOptions options)
        {
            _logger.LogInformation($"Launching app: '{options.FilePath}' using credentials for: '{options.Domain}'");

            StartUpInfo startupInfo = new StartUpInfo();

            startupInfo.cb            = Marshal.SizeOf(startupInfo);
            startupInfo.lpTitle       = null;
            startupInfo.dwFlags       = (int)StartUpInfoFlags.UseCountChars;
            startupInfo.dwYCountChars = 50;

            var workingDirectory = !string.IsNullOrWhiteSpace(options.WorkingDirectory)
                ? options.WorkingDirectory
                : Path.GetDirectoryName(options.FilePath);

            var password = _cipherService.Decrypt(options.Password);

            var process = RunAs.StartProcess(
                userName: options.UserName,
                domain: options.Domain,
                password: password,
                logonFlags: RunAs.LogonFlags.NetworkCredentialsOnly,
                applicationName: null,
                commandLine: options.FilePath,
                creationFlags: RunAs.CreationFlags.NewConsole,
                environment: IntPtr.Zero,
                currentDirectory: workingDirectory,
                startupInfo: ref startupInfo,
                processInfo: out _
                );

            return(Task.FromResult(process));
        }
 public Delete(
     IEnvelope envelope, string name, RunAs runAs, bool deleteCheckpointStream, bool deleteStateStream)
     : base(envelope, runAs)
 {
     _name = name;
     _deleteCheckpointStream = deleteCheckpointStream;
     _deleteStateStream      = deleteStateStream;
 }
 /// <summary>
 /// The constructor takes more than one parameter
 /// as oppose to only one parameter is the bare bone Thread
 /// class. This allow we to perform some additional service
 /// based on the additional parameters, in our case, we will pass
 /// the configuration data that contains the user account information
 /// which is later used to perform the thread's security switch
 /// </summary>
 /// <param name="start">the ThreadStart delegate for the target method</param>
 /// <param name="xml">the configuraiton data contains the user account information</param>
 public SecuritySwitchThread(ThreadStart start, RunAs runAs, CryptographyManager crypto)
 {
     Crypto          = crypto;
     serviceDelegate = start;
     RunAs           = runAs;
     //create a new thread that calls the WrappingMethod
     newT = new Thread(new ThreadStart(WrappingMethod));
 }
 public UpdateQuery(
     IEnvelope envelope, string name, RunAs runAs, string handlerType, string query, bool?emitEnabled)
     : base(envelope, runAs)
 {
     _name        = name;
     _handlerType = handlerType;
     _query       = query;
     _emitEnabled = emitEnabled;
 }
 public StartSlaveProjections(
     IEnvelope envelope, RunAs runAs, string name, SlaveProjectionDefinitions slaveProjections,
     IPublisher resultsPublisher, Guid masterCorrelationId)
     : base(envelope, runAs)
 {
     _name                = name;
     _slaveProjections    = slaveProjections;
     _resultsPublisher    = resultsPublisher;
     _masterCorrelationId = masterCorrelationId;
 }
Beispiel #7
0
 /// <summary>
 /// Evaluates RunAs and parentSecurity(parent RunAs) for whether to inherit settings.
 /// </summary>
 /// <param name="parentSecurityContext">Reference SecurityContext from parent Plan/Action.</param>
 public void IngestParentSecurityContext(SecurityContext parentSecurityContext)
 {
     if (HasRunAs)
     {
         RunAs.InheritSettingsIfAllowed(parentSecurityContext);
     }
     else if (parentSecurityContext != null && parentSecurityContext.IsInheritable)
     {
         RunAs = parentSecurityContext;
     }
 }
 // shortcut for posting ad-hoc JS queries
 public Post(IEnvelope envelope, RunAs runAs, string query, bool enabled)
     : base(envelope, runAs)
 {
     _name = Guid.NewGuid().ToString("D");
     _handlerType = "JS";
     _mode = ProjectionMode.Transient;
     _query = query;
     _enabled = enabled;
     _checkpointsEnabled = false;
     _emitEnabled = false;
 }
 // shortcut for posting ad-hoc JS queries
 public Post(IEnvelope envelope, RunAs runAs, string query, bool enabled)
     : base(envelope, runAs)
 {
     _name               = Guid.NewGuid().ToString("D");
     _handlerType        = "JS";
     _mode               = ProjectionMode.Transient;
     _query              = query;
     _enabled            = enabled;
     _checkpointsEnabled = false;
     _emitEnabled        = false;
 }
 public Post(
     IEnvelope envelope, ProjectionMode mode, string name, RunAs runAs, Type handlerType, string query,
     bool enabled, bool checkpointsEnabled, bool emitEnabled, bool enableRunAs = false)
     : base(envelope, runAs)
 {
     _name = name;
     _handlerType = "native:" + handlerType.Namespace + "." + handlerType.Name;
     _mode = mode;
     _query = query;
     _enabled = enabled;
     _checkpointsEnabled = checkpointsEnabled;
     _emitEnabled = emitEnabled;
     _enableRunAs = enableRunAs;
 }
 public Post(
     IEnvelope envelope, ProjectionMode mode, string name, RunAs runAs, string handlerType, string query,
     bool enabled, bool checkpointsEnabled, bool emitEnabled, bool enableRunAs = false)
     : base(envelope, runAs)
 {
     _name               = name;
     _handlerType        = handlerType;
     _mode               = mode;
     _query              = query;
     _enabled            = enabled;
     _checkpointsEnabled = checkpointsEnabled;
     _emitEnabled        = emitEnabled;
     _enableRunAs        = enableRunAs;
 }
 public StartSlaveProjections(
     IEnvelope envelope,
     RunAs runAs,
     string name,
     SlaveProjectionDefinitions slaveProjections,
     Guid masterWorkerId,
     Guid masterCorrelationId)
     : base(envelope, runAs)
 {
     _name                = name;
     _slaveProjections    = slaveProjections;
     _masterCorrelationId = masterCorrelationId;
     _masterWorkerId      = masterWorkerId;
 }
 public Post(
     IEnvelope envelope, ProjectionMode mode, string name, RunAs runAs, Type handlerType, string query,
     bool enabled, bool checkpointsEnabled, bool emitEnabled, bool trackEmittedStreams, bool enableRunAs = false)
     : base(envelope, runAs)
 {
     _name                = name;
     _handlerType         = "native:" + handlerType.Namespace + "." + handlerType.Name;
     _mode                = mode;
     _query               = query;
     _enabled             = enabled;
     _checkpointsEnabled  = checkpointsEnabled;
     _emitEnabled         = emitEnabled;
     _trackEmittedStreams = trackEmittedStreams;
     _enableRunAs         = enableRunAs;
 }
 public Post(
     IEnvelope envelope, ProjectionMode mode, string name, RunAs runAs, string handlerType, string query,
     bool enabled, bool checkpointsEnabled, bool emitEnabled, bool trackEmittedStreams, bool enableRunAs = false)
     : base(envelope, runAs)
 {
     _name = name;
     _handlerType = handlerType;
     _mode = mode;
     _query = query;
     _enabled = enabled;
     _checkpointsEnabled = checkpointsEnabled;
     _emitEnabled = emitEnabled;
     _trackEmittedStreams = trackEmittedStreams;
     _enableRunAs = enableRunAs;
 }
 public ProjectionPost(
     ProjectionMode mode, RunAs runAs, string name, string handlerType, string query,
     bool enabled, bool checkpointsEnabled, bool emitEnabled, bool enableRunAs,
     bool trackEmittedStreams)
 {
     Mode                = mode;
     RunAs               = runAs;
     Name                = name;
     HandlerType         = handlerType;
     Query               = query;
     Enabled             = enabled;
     CheckpointsEnabled  = checkpointsEnabled;
     EmitEnabled         = emitEnabled;
     EnableRunAs         = enableRunAs;
     TrackEmittedStreams = trackEmittedStreams;
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = RequestTimeout.GetHashCode();
         hashCode = (hashCode * 397) ^ PingTimeout.GetHashCode();
         hashCode = (hashCode * 397) ^ KeepAliveTime;
         hashCode = (hashCode * 397) ^ KeepAliveInterval;
         hashCode = (hashCode * 397) ^ (RunAs?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Pipelined.GetHashCode();
         hashCode = (hashCode * 397) ^ HttpCompression.GetHashCode();
         hashCode = (hashCode * 397) ^ (Headers?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ProxyAddress?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ProxyUsername?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ProxyPassword?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ DisableAutomaticProxyDetection.GetHashCode();
         hashCode = (hashCode * 397) ^ (BasicAuthorizationCredentials?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ConnectionSettings?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MemoryStreamFactory?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Beispiel #17
0
 public ConfigurationSettings RunAsUser()
 {
     this.UserType = RunAs.User;
     return(this);
 }
 public ConfigurationSettings RunAsLocalService()
 {
     this.UserType = RunAs.LocalService;
     return this;
 }
 public StartSlaveProjections(
     IEnvelope envelope,
     RunAs runAs,
     string name,
     SlaveProjectionDefinitions slaveProjections,
     Guid masterWorkerId,
     Guid masterCorrelationId)
     : base(envelope, runAs)
 {
     _name = name;
     _slaveProjections = slaveProjections;
     _masterCorrelationId = masterCorrelationId;
     _masterWorkerId = masterWorkerId;
 }
 public ConfigurationSettings RunAsUser()
 {
     this.UserType = RunAs.User;
     return this;
 }
 internal static void SetUserType(this IConfigurationContext context, RunAs userType)
 {
     context["topshelf.usertype"] = userType;
 }
 public SetRunAs(IEnvelope envelope, string name, RunAs runAs, SetRemove action)
     : base(envelope, runAs)
 {
     _name   = name;
     _action = action;
 }
Beispiel #23
0
 public ConfigurationSettings RunAsLocalService()
 {
     this.UserType = RunAs.LocalService;
     return(this);
 }
 protected ControlMessage(IEnvelope envelope, RunAs runAs)
 {
     _envelope = envelope;
     RunAs = runAs;
 }
 public ConfigurationSettings RunAsLocalSystem()
 {
     this.UserType = RunAs.LocalSystem;
     return this;
 }
 public ConfigurationSettings RunAsNetworkService()
 {
     this.UserType = RunAs.NetworkService;
     return this;
 }
 public GetQuery(IEnvelope envelope, string name, RunAs runAs) :
     base(envelope, runAs)
 {
     _name = name;
 }
 public UpdateConfig(IEnvelope envelope, string name, bool emitEnabled, bool trackEmittedStreams,
                     int checkpointAfterMs,
                     int checkpointHandledThreshold, int checkpointUnhandledBytesThreshold, int pendingEventsThreshold,
                     int maxWriteBatchLength, int maxAllowedWritesInFlight, RunAs runAs) :
     base(envelope, runAs)
 {
     _name                              = name;
     _emitEnabled                       = emitEnabled;
     _trackEmittedStreams               = trackEmittedStreams;
     _checkpointAfterMs                 = checkpointAfterMs;
     _checkpointHandledThreshold        = checkpointHandledThreshold;
     _checkpointUnhandledBytesThreshold = checkpointUnhandledBytesThreshold;
     _pendingEventsThreshold            = pendingEventsThreshold;
     _maxWriteBatchLength               = maxWriteBatchLength;
     _maxAllowedWritesInFlight          = maxAllowedWritesInFlight;
 }
 public PostBatch(
     IEnvelope envelope, RunAs runAs, ProjectionPost[] projections)
     : base(envelope, runAs)
 {
     Projections = projections;
 }
 public GetConfig(IEnvelope envelope, string name, RunAs runAs) :
     base(envelope, runAs)
 {
     _name = name;
 }
Beispiel #31
0
 public ConfigurationSettings RunAsNetworkService()
 {
     this.UserType = RunAs.NetworkService;
     return(this);
 }
Beispiel #32
0
 public ConfigurationSettings RunAsLocalSystem()
 {
     this.UserType = RunAs.LocalSystem;
     return(this);
 }
 public UpdateQuery(
     IEnvelope envelope, string name, RunAs runAs, string handlerType, string query, bool? emitEnabled)
     : base(envelope, runAs)
 {
     _name = name;
     _handlerType = handlerType;
     _query = query;
     _emitEnabled = emitEnabled;
 }
 public Enable(IEnvelope envelope, string name, RunAs runAs)
     : base(envelope, runAs)
 {
     _name = name;
 }
 public Reset(IEnvelope envelope, string name, RunAs runAs)
     : base(envelope, runAs)
 {
     _name = name;
 }
 protected ControlMessage(IEnvelope envelope, RunAs runAs)
 {
     _envelope = envelope;
     RunAs     = runAs;
 }
 public Delete(
     IEnvelope envelope, string name, RunAs runAs, bool deleteCheckpointStream, bool deleteStateStream, bool deleteEmittedStreams)
     : base(envelope, runAs)
 {
     _name = name;
     _deleteCheckpointStream = deleteCheckpointStream;
     _deleteStateStream = deleteStateStream;
     _deleteEmittedStreams = deleteEmittedStreams;
 }
 public Reset(IEnvelope envelope, string name, RunAs runAs)
     : base(envelope, runAs)
 {
     _name = name;
 }
 public GetQuery(IEnvelope envelope, string name, RunAs runAs):
     base(envelope, runAs)
 {
     _name = name;
 }
 public StartSlaveProjections(
     IEnvelope envelope, RunAs runAs, string name, SlaveProjectionDefinitions slaveProjections,
     IPublisher resultsPublisher, Guid masterCorrelationId)
     : base(envelope, runAs)
 {
     _name = name;
     _slaveProjections = slaveProjections;
     _resultsPublisher = resultsPublisher;
     _masterCorrelationId = masterCorrelationId;
 }
 public SetRunAs(IEnvelope envelope, string name, RunAs runAs, SetRemove action)
     : base(envelope, runAs)
 {
     _name = name;
     _action = action;
 }
 public Enable(IEnvelope envelope, string name, RunAs runAs)
     : base(envelope, runAs)
 {
     _name = name;
 }
Beispiel #43
0
 internal static void SetUserType(this IConfigurationContext context, RunAs userType)
 {
     context["topshelf.usertype"] = userType;
 }