Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        private static void CheckScriptCallOnRemoteRunspace(RemoteRunspace remoteRunspace)
        {
            RemoteRunspacePoolInternal remoteRunspacePoolInternal = remoteRunspace.RunspacePool.RemoteRunspacePoolInternal;

            if (remoteRunspacePoolInternal != null)
            {
                BaseClientSessionTransportManager transportManager = remoteRunspacePoolInternal.DataStructureHandler.TransportManager;
                if ((transportManager != null) && (transportManager.TypeTable == null))
                {
                    throw PSTraceSource.NewInvalidOperationException("TabCompletionStrings", "CannotDeserializeTabCompletionResult", new object[0]);
                }
            }
        }
 internal ClientRunspacePoolDataStructureHandler(RemoteRunspacePoolInternal clientRunspacePool, TypeTable typeTable)
 {
     this.clientRunspacePoolId = clientRunspacePool.InstanceId;
     this.minRunspaces         = clientRunspacePool.GetMinRunspaces();
     this.maxRunspaces         = clientRunspacePool.GetMaxRunspaces();
     this.host = clientRunspacePool.Host;
     this.applicationArguments        = clientRunspacePool.ApplicationArguments;
     this.remoteSession               = this.CreateClientRemoteSession(clientRunspacePool);
     this.transportManager            = this.remoteSession.SessionDataStructureHandler.TransportManager;
     this.transportManager.TypeTable  = typeTable;
     this.remoteSession.StateChanged += new EventHandler <RemoteSessionStateEventArgs>(this.HandleClientRemoteSessionStateChanged);
     this._reconnecting               = false;
     this.transportManager.RobustConnectionNotification += new EventHandler <ConnectionStatusEventArgs>(this.HandleRobustConnectionNotification);
     this.transportManager.CreateCompleted += new EventHandler <CreateCompleteEventArgs>(this.HandleSessionCreateCompleted);
 }
Exemplo n.º 5
0
        /// <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;
            }
        }
Exemplo n.º 6
0
 internal ClientRunspacePoolDataStructureHandler(
     RemoteRunspacePoolInternal clientRunspacePool,
     TypeTable typeTable)
 {
     using (ClientRunspacePoolDataStructureHandler.tracer.TraceConstructor((object)this))
     {
         this.clientRunspacePoolId = clientRunspacePool.InstanceId;
         this.minRunspaces         = clientRunspacePool.GetMinRunspaces();
         this.maxRunspaces         = clientRunspacePool.GetMaxRunspaces();
         this.host = clientRunspacePool.Host;
         this.applicationArguments        = clientRunspacePool.ApplicationArguments;
         this.remoteSession               = (ClientRemoteSession)this.CreateClientRemoteSession(clientRunspacePool);
         this.transportManager            = this.remoteSession.SessionDataStructureHandler.TransportManager;
         this.transportManager.TypeTable  = typeTable;
         this.remoteSession.StateChanged += new EventHandler <RemoteSessionStateEventArgs>(this.HandleClientRemoteSessionStateChanged);
     }
 }