Example #1
0
        /// <summary>
        /// Creates a new instance of ClientRemoteSessionImpl
        /// </summary>
        /// <param name="rsPool">
        /// The RunspacePool object this session should map to.
        /// </param>
        /// <param name="uriRedirectionHandler">
        /// </param>
        internal ClientRemoteSessionImpl(RemoteRunspacePoolInternal rsPool,
                                         URIDirectionReported uriRedirectionHandler)
        {
            Dbg.Assert(rsPool != null, "RunspacePool cannot be null");
            base.RemoteRunspacePoolInternal = rsPool;
            Context.RemoteAddress           = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <Uri>(rsPool.ConnectionInfo,
                                                                                                             "ConnectionUri", null);
            _cryptoHelper            = new PSRemotingCryptoHelperClient();
            _cryptoHelper.Session    = this;
            Context.ClientCapability = RemoteSessionCapability.CreateClientCapability();
            Context.UserCredential   = rsPool.ConnectionInfo.Credential;

            // shellName validation is not performed on the client side.
            // This is recommended by the WinRS team: for the reason that the rules may change in the future.
            Context.ShellName = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <string>(rsPool.ConnectionInfo,
                                                                                                  "ShellUri", string.Empty);

            MySelf = RemotingDestination.Client;
            //Create session data structure handler for this session
            SessionDataStructureHandler = new ClientRemoteSessionDSHandlerImpl(this,
                                                                               _cryptoHelper,
                                                                               rsPool.ConnectionInfo,
                                                                               uriRedirectionHandler);
            BaseSessionDataStructureHandler     = SessionDataStructureHandler;
            _waitHandleForConfigurationReceived = new ManualResetEvent(false);

            //Register handlers for various ClientSessiondata structure handler events
            SessionDataStructureHandler.NegotiationReceived         += HandleNegotiationReceived;
            SessionDataStructureHandler.ConnectionStateChanged      += HandleConnectionStateChanged;
            SessionDataStructureHandler.EncryptedSessionKeyReceived +=
                new EventHandler <RemoteDataEventArgs <string> >(HandleEncryptedSessionKeyReceived);
            SessionDataStructureHandler.PublicKeyRequestReceived +=
                new EventHandler <RemoteDataEventArgs <string> >(HandlePublicKeyRequestReceived);
        }
Example #2
0
        /// <summary>
        /// Creates a new instance of ClientRemoteSessionImpl
        /// </summary>
        /// <param name="rsPool">
        /// The RunspacePool object this session should map to.
        /// </param>
        /// <param name="uriRedirectionHandler">
        /// </param>
        internal ClientRemoteSessionImpl(RemoteRunspacePoolInternal rsPool,
                                       URIDirectionReported uriRedirectionHandler)
        {
            Dbg.Assert(null != rsPool, "RunspacePool cannot be null");
            base.RemoteRunspacePoolInternal = rsPool;
            Context.RemoteAddress = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo<Uri>(rsPool.ConnectionInfo,
                "ConnectionUri", null);
            _cryptoHelper = new PSRemotingCryptoHelperClient();
            _cryptoHelper.Session = this;
            Context.ClientCapability = RemoteSessionCapability.CreateClientCapability();
            Context.UserCredential = rsPool.ConnectionInfo.Credential;

            // shellName validation is not performed on the client side.
            // This is recommended by the WinRS team: for the reason that the rules may change in the future.
            Context.ShellName = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo<string>(rsPool.ConnectionInfo,
                "ShellUri", string.Empty);

            MySelf = RemotingDestination.Client;
            //Create session data structure handler for this session
            SessionDataStructureHandler = new ClientRemoteSessionDSHandlerImpl(this,
                _cryptoHelper,
                rsPool.ConnectionInfo,
                uriRedirectionHandler);
            BaseSessionDataStructureHandler = SessionDataStructureHandler;
            _waitHandleForConfigurationReceived = new ManualResetEvent(false);

            //Register handlers for various ClientSessiondata structure handler events
            SessionDataStructureHandler.NegotiationReceived += HandleNegotiationReceived;
            SessionDataStructureHandler.ConnectionStateChanged += HandleConnectionStateChanged;
            SessionDataStructureHandler.EncryptedSessionKeyReceived +=
                new EventHandler<RemoteDataEventArgs<string>>(HandleEncryptedSessionKeyReceived);
            SessionDataStructureHandler.PublicKeyRequestReceived +=
                new EventHandler<RemoteDataEventArgs<string>>(HandlePublicKeyRequestReceived);
        }