/// <summary> /// Gets a helper with a test session. /// </summary> /// <returns>Helper for testing.</returns> /// <remarks>To be used only for testing</remarks> internal static PSRemotingCryptoHelperClient GetTestRemotingCryptHelperClient() { PSRemotingCryptoHelperClient helper = new PSRemotingCryptoHelperClient(); helper.Session = new TestHelperSession(); return(helper); }
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; } }
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); }
/// <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; } }
/// <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); }
/// <summary> /// Gets a helper with a test session /// </summary> /// <returns>helper for testing</returns> /// <remarks>To be used only for testing</remarks> internal static PSRemotingCryptoHelperClient GetTestRemotingCryptHelperClient() { PSRemotingCryptoHelperClient helper = new PSRemotingCryptoHelperClient(); helper.Session = new TestHelperSession(); return helper; }