Exemplo n.º 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);
        }
Exemplo n.º 2
0
 internal ClientRemoteSessionImpl(RemoteRunspacePoolInternal rsPool, ClientRemoteSession.URIDirectionReported uriRedirectionHandler)
 {
     base.RemoteRunspacePoolInternal = rsPool;
     base.Context.RemoteAddress      = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <Uri>(rsPool.ConnectionInfo, "ConnectionUri", null);
     this._cryptoHelper            = new PSRemotingCryptoHelperClient();
     this._cryptoHelper.Session    = this;
     base.Context.ClientCapability = RemoteSessionCapability.CreateClientCapability();
     base.Context.UserCredential   = rsPool.ConnectionInfo.Credential;
     base.Context.ShellName        = WSManConnectionInfo.ExtractPropertyAsWsManConnectionInfo <string>(rsPool.ConnectionInfo, "ShellUri", string.Empty);
     this._mySelf = RemotingDestination.InvalidDestination | RemotingDestination.Client;
     base.SessionDataStructureHandler                              = new ClientRemoteSessionDSHandlerImpl(this, this._cryptoHelper, rsPool.ConnectionInfo, uriRedirectionHandler);
     base.BaseSessionDataStructureHandler                          = base.SessionDataStructureHandler;
     this._waitHandleForConfigurationReceived                      = new ManualResetEvent(false);
     base.SessionDataStructureHandler.NegotiationReceived         += new EventHandler <RemoteSessionNegotiationEventArgs>(this.HandleNegotiationReceived);
     base.SessionDataStructureHandler.ConnectionStateChanged      += new EventHandler <RemoteSessionStateEventArgs>(this.HandleConnectionStateChanged);
     base.SessionDataStructureHandler.EncryptedSessionKeyReceived += new EventHandler <RemoteDataEventArgs <string> >(this.HandleEncryptedSessionKeyReceived);
     base.SessionDataStructureHandler.PublicKeyRequestReceived    += new EventHandler <RemoteDataEventArgs <string> >(this.HandlePublicKeyRequestReceived);
 }