internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler) { if (session == null) { throw PSTraceSource.NewArgumentNullException("session"); } this._session = session; this._stateMachine = new ClientRemoteSessionDSHandlerStateMachine(); this._stateMachine.StateChanged += new EventHandler<RemoteSessionStateEventArgs>(this.HandleStateChanged); this._connectionInfo = connectionInfo; this._cryptoHelper = cryptoHelper; if (this._connectionInfo is NewProcessConnectionInfo) { this._transportManager = new OutOfProcessClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (NewProcessConnectionInfo) this._connectionInfo, cryptoHelper); } else { this._transportManager = new WSManClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (WSManConnectionInfo) this._connectionInfo, cryptoHelper, this._session.RemoteRunspacePoolInternal.Name); } this._transportManager.DataReceived += new EventHandler<RemoteDataEventArgs>(this.DispatchInputQueueData); this._transportManager.WSManTransportErrorOccured += new EventHandler<TransportErrorOccuredEventArgs>(this.HandleTransportError); this._transportManager.CloseCompleted += new EventHandler<EventArgs>(this.HandleCloseComplete); this._transportManager.DisconnectCompleted += new EventHandler<EventArgs>(this.HandleDisconnectComplete); this._transportManager.ReconnectCompleted += new EventHandler<EventArgs>(this.HandleReconnectComplete); this._transportManager.RobustConnectionNotification += new EventHandler<ConnectionStatusEventArgs>(this.HandleRobustConnectionNotification); WSManConnectionInfo info = connectionInfo as WSManConnectionInfo; if (info != null) { this.uriRedirectionHandler = uriRedirectionHandler; this.maxUriRedirectionCount = info.MaximumConnectionRedirectionCount; } }
protected BaseTransportManager(PSRemotingCryptoHelper cryptoHelper) { this.cryptoHelper = cryptoHelper; this.fragmentor = new System.Management.Automation.Remoting.Fragmentor(0x8000, cryptoHelper); this.recvdData = new PriorityReceiveDataCollection(this.fragmentor, this is BaseClientTransportManager); this.onDataAvailableCallback = new System.Management.Automation.Remoting.ReceiveDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); }
protected BaseClientCommandTransportManager(ClientRemotePowerShell shell, PSRemotingCryptoHelper cryptoHelper, BaseClientSessionTransportManager sessnTM) : base(sessnTM.RunspacePoolInstanceId, cryptoHelper) { RemoteDataObject obj2; base.Fragmentor.FragmentSize = sessnTM.Fragmentor.FragmentSize; base.Fragmentor.TypeTable = sessnTM.Fragmentor.TypeTable; base.dataToBeSent.Fragmentor = base.Fragmentor; this.powershellInstanceId = shell.PowerShell.InstanceId; this.cmdText = new StringBuilder(); foreach (Command command in shell.PowerShell.Commands.Commands) { this.cmdText.Append(command.CommandText); this.cmdText.Append(" | "); } this.cmdText.Remove(this.cmdText.Length - 3, 3); if (shell.PowerShell.IsGetCommandMetadataSpecialPipeline) { obj2 = RemotingEncoder.GenerateGetCommandMetadata(shell); } else { obj2 = RemotingEncoder.GenerateCreatePowerShell(shell); } this.serializedPipeline = new SerializedDataStream(base.Fragmentor.FragmentSize); base.Fragmentor.Fragment<object>(obj2, this.serializedPipeline); }
protected BaseClientTransportManager(Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(cryptoHelper) { this.syncObject = new object(); this.runspacePoolInstanceId = runspaceId; this.dataToBeSent = new PrioritySendDataCollection(); this.onDataAvailableCallback = new ReceiveDataCollection.OnDataAvailableCallback(this.OnDataAvailableHandler); this.callbackNotificationQueue = new Queue<CallbackNotificationInformation>(); }
internal WSManPluginServerTransportManager( int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { _syncObject = new Object(); _activeCmdTransportManagers = new Dictionary<Guid, WSManPluginServerTransportManager>(); _waitHandle = new ManualResetEvent(false); }
internal SerializationContext(int depth, SerializationOptions options, PSRemotingCryptoHelper cryptoHelper) { this.cimClassSerializationIdCache = new CimClassSerializationCache<CimClassSerializationId>(); if (depth < 1) { throw PSTraceSource.NewArgumentException("writer", "serialization", "DepthOfOneRequired", new object[0]); } this.depth = depth; this.options = options; this.cryptoHelper = cryptoHelper; }
internal WSManClientSessionTransportManager(Guid runspacePoolInstanceId, WSManConnectionInfo connectionInfo, PSRemotingCryptoHelper cryptoHelper, string sessionName) : base(runspacePoolInstanceId, cryptoHelper) { this.startMode = WSManTransportManagerUtils.tmStartModes.None; base.CryptoHelper = cryptoHelper; base.dataToBeSent.Fragmentor = base.Fragmentor; this.sessionName = sessionName; base.ReceivedDataCollection.MaximumReceivedDataSize = null; base.ReceivedDataCollection.MaximumReceivedObjectSize = connectionInfo.MaximumReceivedObjectSize; this.onDataAvailableToSendCallback = new System.Management.Automation.Remoting.PrioritySendDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); this.Initialize(connectionInfo.ConnectionUri, connectionInfo); }
/// <summary> /// Creates an instance of ClientRemoteSessionDSHandlerImpl /// </summary> internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler) { Dbg.Assert(_maxUriRedirectionCount >= 0, "maxUriRedirectionCount cannot be less than 0."); if (session == null) { throw PSTraceSource.NewArgumentNullException("session"); } _session = session; //Create state machine _stateMachine = new ClientRemoteSessionDSHandlerStateMachine(); _stateMachine.StateChanged += HandleStateChanged; _connectionInfo = connectionInfo; // Create transport manager _cryptoHelper = cryptoHelper; _transportManager = _connectionInfo.CreateClientSessionTransportManager( _session.RemoteRunspacePoolInternal.InstanceId, _session.RemoteRunspacePoolInternal.Name, cryptoHelper); _transportManager.DataReceived += DispatchInputQueueData; _transportManager.WSManTransportErrorOccured += HandleTransportError; _transportManager.CloseCompleted += HandleCloseComplete; _transportManager.DisconnectCompleted += HandleDisconnectComplete; _transportManager.ReconnectCompleted += HandleReconnectComplete; _transportManager.RobustConnectionNotification += new EventHandler<ConnectionStatusEventArgs>(HandleRobustConnectionNotification); WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo; if (null != wsmanConnectionInfo) { // only WSMan transport supports redirection // store the uri redirection handler and authmechanism // for uri redirection. _uriRedirectionHandler = uriRedirectionHandler; _maxUriRedirectionCount = wsmanConnectionInfo.MaximumConnectionRedirectionCount; } }
internal OutOfProcessClientSessionTransportManager(Guid runspaceId, NewProcessConnectionInfo connectionInfo, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { this._processCreated = true; this.onDataAvailableToSendCallback = new System.Management.Automation.Remoting.PrioritySendDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); this.cmdTransportManagers = new Dictionary<Guid, OutOfProcessClientCommandTransportManager>(); this.connectionInfo = connectionInfo; this.dataProcessingCallbacks = new OutOfProcessUtils.DataProcessingDelegates(); this.dataProcessingCallbacks.DataPacketReceived = (OutOfProcessUtils.DataPacketReceived) Delegate.Combine(this.dataProcessingCallbacks.DataPacketReceived, new OutOfProcessUtils.DataPacketReceived(this.OnDataPacketReceived)); this.dataProcessingCallbacks.DataAckPacketReceived = (OutOfProcessUtils.DataAckPacketReceived) Delegate.Combine(this.dataProcessingCallbacks.DataAckPacketReceived, new OutOfProcessUtils.DataAckPacketReceived(this.OnDataAckPacketReceived)); this.dataProcessingCallbacks.CommandCreationPacketReceived = (OutOfProcessUtils.CommandCreationPacketReceived) Delegate.Combine(this.dataProcessingCallbacks.CommandCreationPacketReceived, new OutOfProcessUtils.CommandCreationPacketReceived(this.OnCommandCreationPacketReceived)); this.dataProcessingCallbacks.CommandCreationAckReceived = (OutOfProcessUtils.CommandCreationAckReceived) Delegate.Combine(this.dataProcessingCallbacks.CommandCreationAckReceived, new OutOfProcessUtils.CommandCreationAckReceived(this.OnCommandCreationAckReceived)); this.dataProcessingCallbacks.SignalPacketReceived = (OutOfProcessUtils.SignalPacketReceived) Delegate.Combine(this.dataProcessingCallbacks.SignalPacketReceived, new OutOfProcessUtils.SignalPacketReceived(this.OnSignalPacketReceived)); this.dataProcessingCallbacks.SignalAckPacketReceived = (OutOfProcessUtils.SignalAckPacketReceived) Delegate.Combine(this.dataProcessingCallbacks.SignalAckPacketReceived, new OutOfProcessUtils.SignalAckPacketReceived(this.OnSiganlAckPacketReceived)); this.dataProcessingCallbacks.ClosePacketReceived = (OutOfProcessUtils.ClosePacketReceived) Delegate.Combine(this.dataProcessingCallbacks.ClosePacketReceived, new OutOfProcessUtils.ClosePacketReceived(this.OnClosePacketReceived)); this.dataProcessingCallbacks.CloseAckPacketReceived = (OutOfProcessUtils.CloseAckPacketReceived) Delegate.Combine(this.dataProcessingCallbacks.CloseAckPacketReceived, new OutOfProcessUtils.CloseAckPacketReceived(this.OnCloseAckReceived)); base.dataToBeSent.Fragmentor = base.Fragmentor; base.ReceivedDataCollection.MaximumReceivedDataSize = null; base.ReceivedDataCollection.MaximumReceivedObjectSize = 0xa00000; this.closeTimeOutTimer = new Timer(60000.0); this.closeTimeOutTimer.Elapsed += new ElapsedEventHandler(this.OnCloseTimeOutTimerElapsed); this._tracer = PowerShellTraceSourceFactory.GetTraceSource(); }
internal OutOfProcessServerTransportManager(OutOfProcessTextWriter stdOutWriter, OutOfProcessTextWriter stdErrWriter, Guid powershellInstanceId, TypeTable typeTableToUse, int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { _stdOutWriter = stdOutWriter; _stdErrWriter = stdErrWriter; _powershellInstanceId = powershellInstanceId; this.TypeTable = typeTableToUse; this.WSManTransportErrorOccured += HandleWSManTransportError; }
internal ContainerNamedPipeClientSessionTransportManager( ContainerConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(connectionInfo, runspaceId, cryptoHelper, _threadName) { if (connectionInfo == null) { throw new PSArgumentNullException("connectionInfo"); } _connectionInfo = connectionInfo; }
internal NamedPipeClientSessionTransportManagerBase( RunspaceConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper, string threadName) : base(runspaceId, cryptoHelper) { if (connectionInfo == null) { throw new PSArgumentNullException("connectionInfo"); } _connectionInfo = connectionInfo; _threadName = threadName; Fragmentor.FragmentSize = RemoteSessionNamedPipeServer.NamedPipeBufferSizeForRemoting; }
internal SSHClientSessionTransportManager( SSHConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { if (connectionInfo == null) { throw new PSArgumentException("connectionInfo"); } _connectionInfo = connectionInfo; }
protected AbstractServerSessionTransportManager(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { }
internal DeserializationContext(DeserializationOptions options, PSRemotingCryptoHelper cryptoHelper) { this.cimClassSerializationIdCache = new CimClassDeserializationCache<CimClassSerializationId>(); this.options = options; this.cryptoHelper = cryptoHelper; }
internal OutOfProcessServerTransportManager(OutOfProcessTextWriter stdOutWriter, Guid powershellInstanceId, TypeTable typeTableToUse, int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { this.stdOutWriter = stdOutWriter; this.powershellInstanceId = powershellInstanceId; base.TypeTable = typeTableToUse; }
internal OutOfProcessClientSessionTransportManagerBase( Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { _onDataAvailableToSendCallback = new PrioritySendDataCollection.OnDataAvailableCallback(OnDataAvailableCallback); _cmdTransportManagers = new Dictionary<Guid, OutOfProcessClientCommandTransportManager>(); _dataProcessingCallbacks = new OutOfProcessUtils.DataProcessingDelegates(); _dataProcessingCallbacks.DataPacketReceived += new OutOfProcessUtils.DataPacketReceived(OnDataPacketReceived); _dataProcessingCallbacks.DataAckPacketReceived += new OutOfProcessUtils.DataAckPacketReceived(OnDataAckPacketReceived); _dataProcessingCallbacks.CommandCreationPacketReceived += new OutOfProcessUtils.CommandCreationPacketReceived(OnCommandCreationPacketReceived); _dataProcessingCallbacks.CommandCreationAckReceived += new OutOfProcessUtils.CommandCreationAckReceived(OnCommandCreationAckReceived); _dataProcessingCallbacks.SignalPacketReceived += new OutOfProcessUtils.SignalPacketReceived(OnSignalPacketReceived); _dataProcessingCallbacks.SignalAckPacketReceived += new OutOfProcessUtils.SignalAckPacketReceived(OnSiganlAckPacketReceived); _dataProcessingCallbacks.ClosePacketReceived += new OutOfProcessUtils.ClosePacketReceived(OnClosePacketReceived); _dataProcessingCallbacks.CloseAckPacketReceived += new OutOfProcessUtils.CloseAckPacketReceived(OnCloseAckReceived); dataToBeSent.Fragmentor = base.Fragmentor; // session transport manager can receive unlimited data..however each object is limited // by maxRecvdObjectSize. this is to allow clients to use a session for an unlimited time.. // also the messages that can be sent to a session are limited and very controlled. // However a command transport manager can be restricted to receive only a fixed amount of data // controlled by maxRecvdDataSizeCommand..This is because commands can accept any number of input // objects. ReceivedDataCollection.MaximumReceivedDataSize = null; ReceivedDataCollection.MaximumReceivedObjectSize = BaseTransportManager.MaximumReceivedObjectSize; // timers initialization _closeTimeOutTimer = new Timer(OnCloseTimeOutTimerElapsed, null, Timeout.Infinite, Timeout.Infinite); _tracer = PowerShellTraceSourceFactory.GetTraceSource(); }
internal OutOfProcessClientSessionTransportManager(Guid runspaceId, NewProcessConnectionInfo connectionInfo, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { _connectionInfo = connectionInfo; }
internal HyperVSocketClientSessionTransportManagerBase( Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { }
/// <summary> /// Constructor. This will create a new PrioritySendDataCollection which should be used to /// send data to the server. /// </summary> /// <param name="runspacePoolInstanceId"> /// This is used for logging trace/operational crimson messages. Having this id in the logs /// helps a user to map which transport is created for which runspace. /// </param> /// <param name="connectionInfo"> /// Connection info to use while connecting to the remote machine. /// </param> /// <param name="cryptoHelper">crypto helper</param> /// <param name="sessionName">session friendly name</param> /// <exception cref="PSInvalidOperationException"> /// 1. Create Session failed with a non-zero error code. /// </exception> internal WSManClientSessionTransportManager(Guid runspacePoolInstanceId, WSManConnectionInfo connectionInfo, PSRemotingCryptoHelper cryptoHelper, string sessionName) : base(runspacePoolInstanceId, cryptoHelper) { // Initialize WSMan instance WSManAPIData = new WSManAPIDataCommon(); if (WSManAPIData.WSManAPIHandle == IntPtr.Zero) { throw new PSRemotingTransportException( StringUtil.Format(RemotingErrorIdStrings.WSManInitFailed, WSManAPIData.ErrorCode)); } Dbg.Assert(null != connectionInfo, "connectionInfo cannot be null"); CryptoHelper = cryptoHelper; dataToBeSent.Fragmentor = base.Fragmentor; _sessionName = sessionName; // session transport manager can receive unlimited data..however each object is limited // by maxRecvdObjectSize. this is to allow clients to use a session for an unlimited time.. // also the messages that can be sent to a session are limited and very controlled. // However a command transport manager can be restricted to receive only a fixed amount of data // controlled by maxRecvdDataSizeCommand..This is because commands can accept any number of input // objects. ReceivedDataCollection.MaximumReceivedDataSize = null; ReceivedDataCollection.MaximumReceivedObjectSize = connectionInfo.MaximumReceivedObjectSize; _onDataAvailableToSendCallback = new PrioritySendDataCollection.OnDataAvailableCallback(OnDataAvailableCallback); Initialize(connectionInfo.ConnectionUri, connectionInfo); }
internal ContainerHyperVSocketClientSessionTransportManager( ContainerConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper, Guid targetGuid) : base(runspaceId, cryptoHelper) { if (connectionInfo == null) { throw new PSArgumentNullException("connectionInfo"); } _connectionInfo = connectionInfo; _targetGuid = targetGuid; }
internal VMHyperVSocketClientSessionTransportManager( VMConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper, Guid vmGuid, string configurationName) : base(runspaceId, cryptoHelper) { if (connectionInfo == null) { throw new PSArgumentNullException("connectionInfo"); } _connectionInfo = connectionInfo; _vmGuid = vmGuid; _configurationName = configurationName; if (connectionInfo.Credential == null) { _networkCredential = CredentialCache.DefaultNetworkCredentials; } else { _networkCredential = connectionInfo.Credential.GetNetworkCredential(); } }
protected BaseClientSessionTransportManager(Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { }