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 Fragmentor(32768, cryptoHelper); this.recvdData = new PriorityReceiveDataCollection(this.fragmentor, this is BaseClientTransportManager); this.onDataAvailableCallback = new ReceiveDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); }
internal ClientRemoteSessionDSHandlerImpl( ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler) { using (ClientRemoteSessionDSHandlerImpl._trace.TraceConstructor((object)this)) { this._session = session != null ? session : throw ClientRemoteSessionDSHandlerImpl._trace.NewArgumentNullException(nameof(session)); this._stateMachine = new ClientRemoteSessionDSHandlerStateMachine(); this._stateMachine.StateChanged += new EventHandler <RemoteSessionStateEventArgs>(this.HandleStateChanged); this._connectionInfo = connectionInfo; this._cryptoHelper = cryptoHelper; this._transportManager = !(this._connectionInfo is NewProcessConnectionInfo) ? (BaseClientSessionTransportManager) new WSManClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (WSManConnectionInfo)this._connectionInfo, cryptoHelper) : (BaseClientSessionTransportManager) new OutOfProcessClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (NewProcessConnectionInfo)this._connectionInfo, cryptoHelper); this._transportManager.DataReceived += new EventHandler <RemoteDataEventArgs>(this.DispatchInputQueueData); this._transportManager.WSManTransportErrorOccured += new EventHandler <TransportErrorOccuredEventArgs>(this.HandleTransportError); this._transportManager.CloseCompleted += new EventHandler <EventArgs>(this.HandleCloseComplete); if (!(connectionInfo is WSManConnectionInfo manConnectionInfo)) { return; } this.uriRedirectionHandler = uriRedirectionHandler; this.maxUriRedirectionCount = manConnectionInfo.MaximumConnectionRedirectionCount; } }
internal DeserializationContext( DeserializationOptions options, PSRemotingCryptoHelper cryptoHelper) { this.options = options; this.cryptoHelper = cryptoHelper; }
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.depth = depth >= 1 ? depth : throw SerializationContext._trace.NewArgumentException("writer", "serialization", "DepthOfOneRequired"); this.options = options; this.cryptoHelper = cryptoHelper; }
/// <summary> /// Create an instance of ClientSessionTransportManager. /// </summary> public override BaseClientSessionTransportManager CreateClientSessionTransportManager( Guid instanceId, string sessionName, PSRemotingCryptoHelper cryptoHelper) { return(new NamedPipeClientSessionTransportMgr( connectionInfo: this, runspaceId: instanceId, cryptoHelper: cryptoHelper)); }
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 OutOfProcessServerTransportManager( OutOfProcessTextWriter stdOutWriter, Guid powershellInstanceId, TypeTable typeTableToUse, int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { this.stdOutWriter = stdOutWriter; this.powershellInstanceId = powershellInstanceId; this.TypeTable = typeTableToUse; }
/// <summary> /// Constructor which initializes fragmentor with FragmentSize. /// </summary> /// <param name="fragmentSize"> /// size of each fragment /// </param> /// <param name="cryptoHelper"></param> internal Fragmentor(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) { Dbg.Assert(fragmentSize > 0, "fragment size cannot be less than 0."); _fragmentSize = fragmentSize; _serializationContext = new SerializationContext( SerializationDepthForRemoting, SerializationOptions.RemotingOptions, cryptoHelper); DeserializationContext = new DeserializationContext( DeserializationOptions.RemotingOptions, cryptoHelper); }
internal NamedPipeClientSessionTransportMgr( NamedPipeInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { if (connectionInfo == null) { throw new PSArgumentException("connectionInfo"); } _connectionInfo = 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 (wsmanConnectionInfo != null) { // only WSMan transport supports redirection // store the uri redirection handler and authmechanism // for uri redirection. _uriRedirectionHandler = uriRedirectionHandler; _maxUriRedirectionCount = wsmanConnectionInfo.MaximumConnectionRedirectionCount; } }
internal WSManClientSessionTransportManager( Guid runspacePoolInstanceId, WSManConnectionInfo connectionInfo, PSRemotingCryptoHelper cryptoHelper) : base(runspacePoolInstanceId, cryptoHelper) { using (BaseClientTransportManager.tracer.TraceConstructor((object)this)) { this.resourceUri = connectionInfo.ShellUri; this.CryptoHelper = cryptoHelper; this.dataToBeSent.Fragmentor = this.Fragmentor; this.ReceivedDataCollection.MaximumReceivedDataSize = new int?(); this.ReceivedDataCollection.MaximumReceivedObjectSize = connectionInfo.MaximumReceivedObjectSize; this.onDataAvailableToSendCallback = new PrioritySendDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); this.Initialize(connectionInfo.ConnectionUri, connectionInfo); } }
internal OutOfProcessClientSessionTransportManager( Guid runspaceId, NewProcessConnectionInfo connectionInfo, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { this.onDataAvailableToSendCallback = new PrioritySendDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback); this.cmdTransportManagers = new Dictionary <Guid, OutOfProcessClientCommandTransportManager>(); this.connectionInfo = connectionInfo; this.dataProcessingCallbacks = new OutOfProcessUtils.DataProcessingDelegates(); this.dataProcessingCallbacks.DataPacketReceived += new OutOfProcessUtils.DataPacketReceived(this.OnDataPacketReceived); this.dataProcessingCallbacks.DataAckPacketReceived += new OutOfProcessUtils.DataAckPacketReceived(this.OnDataAckPacketReceived); this.dataProcessingCallbacks.CommandCreationPacketReceived += new OutOfProcessUtils.CommandCreationPacketReceived(this.OnCommandCreationPacketReceived); this.dataProcessingCallbacks.CommandCreationAckReceived += new OutOfProcessUtils.CommandCreationAckReceived(this.OnCommandCreationAckReceived); this.dataProcessingCallbacks.SignalPacketReceived += new OutOfProcessUtils.SignalPacketReceived(this.OnSignalPacketReceived); this.dataProcessingCallbacks.SignalAckPacketReceived += new OutOfProcessUtils.SignalAckPacketReceived(this.OnSiganlAckPacketReceived); this.dataProcessingCallbacks.ClosePacketReceived += new OutOfProcessUtils.ClosePacketReceived(this.OnClosePacketReceived); this.dataProcessingCallbacks.CloseAckPacketReceived += new OutOfProcessUtils.CloseAckPacketReceived(this.OnCloseAckReceived); this.dataToBeSent.Fragmentor = this.Fragmentor; this.ReceivedDataCollection.MaximumReceivedDataSize = new int?(); this.ReceivedDataCollection.MaximumReceivedObjectSize = new int?(10485760); this.closeTimeOutTimer = new System.Timers.Timer(60000.0); this.closeTimeOutTimer.Elapsed += new ElapsedEventHandler(this.OnCloseTimeOutTimerElapsed); }
internal DeserializationContext(DeserializationOptions options, PSRemotingCryptoHelper cryptoHelper) { this.cimClassSerializationIdCache = new CimClassDeserializationCache <CimClassSerializationId>(); this.options = options; this.cryptoHelper = cryptoHelper; }
protected AbstractServerSessionTransportManager(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper) { }
internal Fragmentor(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) { this._fragmentSize = fragmentSize; this._serializationContext = new SerializationContext(SerializationDepthForRemoting, SerializationOptions.RemotingOptions, cryptoHelper); this._deserializationContext = new System.Management.Automation.DeserializationContext(DeserializationOptions.RemotingOptions, cryptoHelper); }
protected BaseClientSessionTransportManager( Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(runspaceId, cryptoHelper) { }
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(); }
protected AbstractServerTransportManager(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(cryptoHelper) { this.Fragmentor.FragmentSize = fragmentSize; this.onDataAvailable = new SerializedDataStream.OnDataAvailableCallback(this.OnDataAvailable); }
internal Fragmentor(int fragmentSize, PSRemotingCryptoHelper cryptoHelper) { this._fragmentSize = fragmentSize; this._serializationContext = new SerializationContext(1, SerializationOptions.RemotingOptions, cryptoHelper); this._deserializationContext = new DeserializationContext(DeserializationOptions.RemotingOptions, cryptoHelper); }