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
 /// <summary>
 /// Release all resources
 /// </summary>
 /// <param name="disposing">if true, release all managed resources</param>
 public void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_waitHandleForConfigurationReceived != null)
         {
             _waitHandleForConfigurationReceived.Dispose();
             _waitHandleForConfigurationReceived = null;
         }
         ((ClientRemoteSessionDSHandlerImpl)SessionDataStructureHandler).Dispose();
         SessionDataStructureHandler = null;
         _cryptoHelper.Dispose();
         _cryptoHelper = null;
     }
 }
Exemplo n.º 3
0
 public void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this._waitHandleForConfigurationReceived != null)
         {
             this._waitHandleForConfigurationReceived.Close();
             this._waitHandleForConfigurationReceived = null;
         }
         ((ClientRemoteSessionDSHandlerImpl)base.SessionDataStructureHandler).Dispose();
         base.SessionDataStructureHandler = null;
         this._cryptoHelper.Dispose();
         this._cryptoHelper = null;
     }
 }
 public void Dispose(bool disposing)
 {
     if (!disposing)
     {
         return;
     }
     if (this._waitHandleForConfigurationReceived != null)
     {
         this._waitHandleForConfigurationReceived.Close();
         this._waitHandleForConfigurationReceived = (ManualResetEvent)null;
     }
     ((ClientRemoteSessionDSHandlerImpl)this.SessionDataStructureHandler).Dispose();
     this.SessionDataStructureHandler = (ClientRemoteSessionDataStructureHandler)null;
     this._cryptoHelper.Dispose();
     this._cryptoHelper = (PSRemotingCryptoHelperClient)null;
 }
Exemplo n.º 5
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);
 }