private async void OnLanguageServiceClientConnect( object sender, TcpSocketServerChannel serverChannel) { MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger); ProtocolEndpoint protocolEndpoint = new ProtocolEndpoint( serverChannel, messageDispatcher, this.logger); this.editorSession = CreateSession( this.hostDetails, this.profilePaths, protocolEndpoint, messageDispatcher, this.enableConsoleRepl); this.languageServer = new LanguageServer( this.editorSession, messageDispatcher, protocolEndpoint, this.logger); await this.editorSession.PowerShellContext.ImportCommandsModule( Path.Combine( Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location), @"..\..\Commands")); this.languageServer.Start(); protocolEndpoint.Start(); }
public DebugAdapterClient(ChannelBase clientChannel, ILogger logger) { this.logger = logger; this.messageDispatcher = new MessageDispatcher(logger); this.protocolEndpoint = new ProtocolEndpoint( clientChannel, messageDispatcher, logger); }
/// <summary> /// Initializes an instance of the language client using the /// specified channel for communication. /// </summary> /// <param name="clientChannel">The channel to use for communication with the server.</param> public LanguageClientBase(ChannelBase clientChannel, ILogger logger) { this.logger = logger; this.messageDispatcher = new MessageDispatcher(logger); this.protocolEndpoint = new ProtocolEndpoint( clientChannel, messageDispatcher, logger); }
private void OnDebugServiceClientConnect(object sender, TcpSocketServerChannel serverChannel) { MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger); ProtocolEndpoint protocolEndpoint = new ProtocolEndpoint( serverChannel, messageDispatcher, this.logger); protocolEndpoint.UnhandledException += ProtocolEndpoint_UnhandledException; bool ownsEditorSession = this.editorSession == null; if (ownsEditorSession) { this.editorSession = this.CreateDebugSession( this.hostDetails, profilePaths, protocolEndpoint, messageDispatcher, this.languageServer?.EditorOperations, this.enableConsoleRepl); } this.debugAdapter = new DebugAdapter( this.editorSession, ownsEditorSession, messageDispatcher, protocolEndpoint, this.logger); this.debugAdapter.SessionEnded += (obj, args) => { if (!ownsEditorSession) { this.logger.Write( LogLevel.Normal, "Previous debug session ended, restarting debug service listener..."); this.debugServiceListener.Start(); } else { // Exit the host process this.serverCompletedTask.SetResult(true); } }; this.debugAdapter.Start(); protocolEndpoint.Start(); }
private async void OnLanguageServiceClientConnect( object sender, ChannelBase serverChannel) { MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger); ProtocolEndpoint protocolEndpoint = new ProtocolEndpoint( serverChannel, messageDispatcher, this.logger); protocolEndpoint.UnhandledException += ProtocolEndpoint_UnhandledException; this.editorSession = CreateSession( this.hostDetails, this.profilePaths, protocolEndpoint, messageDispatcher, this.enableConsoleRepl); this.languageServer = new LanguageServer( this.editorSession, messageDispatcher, protocolEndpoint, this.serverCompletedTask, this.logger); await this.editorSession.PowerShellContext.ImportCommandsModule( Path.Combine( Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location), @"..\..\Commands")); this.languageServer.Start(); // TODO: This can be moved to the point after the $psEditor object // gets initialized when that is done earlier than LanguageServer.Initialize foreach (string module in this.additionalModules) { var command = new System.Management.Automation.PSCommand() .AddCommand("Microsoft.PowerShell.Core\\Import-Module") .AddParameter("Name", module); await this.editorSession.PowerShellContext.ExecuteCommand <System.Management.Automation.PSObject>( command, sendOutputToHost : false, sendErrorToHost : true); } protocolEndpoint.Start(); }
private void OnDebugServiceClientConnect(object sender, TcpSocketServerChannel serverChannel) { MessageDispatcher messageDispatcher = new MessageDispatcher(this.logger); ProtocolEndpoint protocolEndpoint = new ProtocolEndpoint( serverChannel, messageDispatcher, this.logger); if (this.enableConsoleRepl) { this.debugAdapter = new DebugAdapter( this.editorSession, false, messageDispatcher, protocolEndpoint, this.logger); } else { EditorSession debugSession = this.CreateDebugSession( this.hostDetails, profilePaths, protocolEndpoint, messageDispatcher, this.languageServer?.EditorOperations, false); this.debugAdapter = new DebugAdapter( debugSession, true, messageDispatcher, protocolEndpoint, this.logger); } this.debugAdapter.SessionEnded += (obj, args) => { this.logger.Write( LogLevel.Normal, "Previous debug session ended, restarting debug service listener..."); this.debugServiceListener.Start(); }; this.debugAdapter.Start(); protocolEndpoint.Start(); }
protected override IdentityProviderSingleSignOnDescriptor BuildDescriptorInternal(IMetadataConfiguration configuration) { var idpConfiguration = configuration as IIdpSSOMetadataConfiguration; if (idpConfiguration == null) { throw new InvalidCastException(string.Format("Expected type: {0} but was: {1}", typeof(IdpSSOMetadataConfiguration).Name, configuration.GetType().Name)); } var descriptor = new IdentityProviderSingleSignOnDescriptor(); descriptor.ProtocolsSupported.Add(new Uri("http://docs.oasis-open.org/wsfed/federation/200706")); foreach (var sso in idpConfiguration.SingleSignOnServices) { var singleSignOnService = new ProtocolEndpoint(new Uri(sso.Binding), new Uri(sso.Location)); descriptor.SingleSignOnServices.Add(singleSignOnService); } return(descriptor); }
public void IdentityProvider_ConstructedFromEntityDescriptor_DoesntScheduleMedataRefresh() { MetadataRefreshScheduler.minInterval = new TimeSpan(0, 0, 0, 0, 1); var ed = new ExtendedEntityDescriptor { ValidUntil = DateTime.UtcNow.AddYears(-1), EntityId = new EntityId("http://localhost:13428/idpMetadata") }; var idpSsoDescriptor = new IdentityProviderSingleSignOnDescriptor(); idpSsoDescriptor.ProtocolsSupported.Add(new Uri("urn:oasis:names:tc:SAML:2.0:protocol")); ed.RoleDescriptors.Add(idpSsoDescriptor); var pe = new ProtocolEndpoint() { Binding = Saml2Binding.HttpRedirectUri, Location = new Uri("http://idp.example.com/sso") }; idpSsoDescriptor.SingleSignOnServices.Add(pe); idpSsoDescriptor.Keys.Add(SignedXmlHelper.TestKeyDescriptor); var subject = new IdentityProvider(ed.EntityId, StubFactory.CreateSPOptions()); subject.ReadMetadata(ed); // Ugly, but have to wait and see that nothing happened. Have tried // some different timeouts but need 100 to ensure fail before bug // is fixed :-( Thread.Sleep(100); // Would be changed if metadata was reloaded. subject.SingleSignOnServiceUrl.Should().Be(pe.Location); }
public OutputReader(ProtocolEndpoint protocolClient) { protocolClient.SetEventHandler( OutputEvent.Type, this.OnOutputEvent); }
static void Main(string[] args) { #if DEBUG bool waitForDebugger = args.Any( arg => string.Equals( arg, "/waitForDebugger", StringComparison.InvariantCultureIgnoreCase)); if (waitForDebugger) { if (Debugger.IsAttached) { Debugger.Break(); } else { Debugger.Launch(); } } #endif string logPath = null; string logPathArgument = args.FirstOrDefault( arg => arg.StartsWith( "/logPath:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(logPathArgument)) { logPath = logPathArgument.Substring(9).Trim('"'); } LogLevel logLevel = LogLevel.Normal; string logLevelArgument = args.FirstOrDefault( arg => arg.StartsWith( "/logLevel:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(logLevelArgument)) { // Attempt to parse the log level Enum.TryParse <LogLevel>( logLevelArgument.Substring(10).Trim('"'), true, out logLevel); } bool runDebugAdapter = args.Any( arg => string.Equals( arg, "/debugAdapter", StringComparison.InvariantCultureIgnoreCase)); // Catch unhandled exceptions for logging purposes AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; ProtocolEndpoint server = null; if (runDebugAdapter) { logPath = logPath ?? "DebugAdapter.log"; server = new DebugAdapter(); } else { logPath = logPath ?? "EditorServices.log"; server = new LanguageServer(); } // Start the logger with the specified log path and level Logger.Initialize(logPath, logLevel); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo( System.Reflection.Assembly.GetExecutingAssembly().Location); Logger.Write( LogLevel.Normal, string.Format( "PowerShell Editor Services Host v{0} starting (pid {1})...", fileVersionInfo.FileVersion, Process.GetCurrentProcess().Id)); // Start the server server.Start().Wait(); Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!"); // Wait for the server to finish server.WaitForExit(); Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host exited normally."); }
static void Main(string[] args) { #if DEBUG bool waitForDebugger = args.Any( arg => string.Equals( arg, "/waitForDebugger", StringComparison.InvariantCultureIgnoreCase)); if (waitForDebugger) { if (Debugger.IsAttached) { Debugger.Break(); } else { Debugger.Launch(); } } #endif string logPath = null; string logPathArgument = args.FirstOrDefault( arg => arg.StartsWith( "/logPath:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(logPathArgument)) { logPath = logPathArgument.Substring(9).Trim('"'); } LogLevel logLevel = LogLevel.Normal; string logLevelArgument = args.FirstOrDefault( arg => arg.StartsWith( "/logLevel:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(logLevelArgument)) { // Attempt to parse the log level Enum.TryParse <LogLevel>( logLevelArgument.Substring(10).Trim('"'), true, out logLevel); } bool runDebugAdapter = args.Any( arg => string.Equals( arg, "/debugAdapter", StringComparison.InvariantCultureIgnoreCase)); string hostProfileId = null; string hostProfileIdArgument = args.FirstOrDefault( arg => arg.StartsWith( "/hostProfileId:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(hostProfileIdArgument)) { hostProfileId = hostProfileIdArgument.Substring(15).Trim('"'); } string hostName = null; string hostNameArgument = args.FirstOrDefault( arg => arg.StartsWith( "/hostName:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(hostNameArgument)) { hostName = hostNameArgument.Substring(10).Trim('"'); } Version hostVersion = null; string hostVersionArgument = args.FirstOrDefault( arg => arg.StartsWith( "/hostVersion:", StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(hostVersionArgument)) { hostVersion = new Version( hostVersionArgument.Substring(13).Trim('"')); } // Create the host details from parameters HostDetails hostDetails = new HostDetails( hostName, hostProfileId, hostVersion); // Catch unhandled exceptions for logging purposes AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Use a default log path filename if one isn't specified logPath = runDebugAdapter ? logPath ?? "DebugAdapter.log" : logPath ?? "EditorServices.log"; // Start the logger with the specified log path and level Logger.Initialize(logPath, logLevel); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo( System.Reflection.Assembly.GetExecutingAssembly().Location); Logger.Write( LogLevel.Normal, string.Format( "PowerShell Editor Services Host v{0} starting (pid {1})...\r\n\r\n" + " Host application details:\r\n\r\n" + " Name: {2}\r\n ProfileId: {3}\r\n Version: {4}", fileVersionInfo.FileVersion, Process.GetCurrentProcess().Id, hostDetails.Name, hostDetails.ProfileId, hostDetails.Version)); // Create the appropriate server type ProtocolEndpoint server = runDebugAdapter ? (ProtocolEndpoint) new DebugAdapter(hostDetails) : (ProtocolEndpoint) new LanguageServer(hostDetails); // Start the server server.Start().Wait(); Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!"); // Wait for the server to finish server.WaitForExit(); Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host exited normally."); }
public OutputReader(ProtocolEndpoint protocolClient) { protocolClient.SetEventHandler( OutputEvent.Type, this.OnOutputEvent); }