/// <summary> /// Adds a specified client sink provider into the client sink chain after the formatter. /// </summary> /// <param name="protocolSetup">Protocol setup</param> /// <param name="clientSinkProvider">Client sink provider to be added</param> /// <returns>Protocol setup</returns> public static IServerProtocolSetup AddClientSinkAfterFormatter(this IServerProtocolSetup protocolSetup, IClientChannelSinkProvider clientSinkProvider) { if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } if (clientSinkProvider == null) { throw new ArgumentNullException("clientSinkProvider"); } IClientFormatterSinkProvider formatter = GetClientFormatter(protocolSetup); if (formatter == null) { throw new ApplicationException(LanguageResource.ApplicationException_NoFormatterSpecified); } int index = protocolSetup.ClientSinkChain.IndexOf((IClientChannelSinkProvider)formatter); protocolSetup.ClientSinkChain.Insert(index + 1, clientSinkProvider); return(protocolSetup); }
private void TestVulnerability(string hostName, string serverUrl, IServerProtocolSetup serverSetup, IClientProtocolSetup clientSetup, object payload) { ZyanSettings.DisableUrlRandomization = true; using (var zyanHost = new ZyanComponentHost(hostName, serverSetup)) { zyanHost.RegisterComponent <ISampleServer, SampleServer>(ActivationType.Singleton); var credentials = new Hashtable { { "Login", "hacker" }, { "Password", "secret" }, { string.Empty, payload } }; using (var zyanConnection = new ZyanConnection(serverUrl, clientSetup)) { var proxy = zyanConnection.CreateProxy <ISampleServer>(); AssertEx.Throws <SecurityException>(() => proxy.TestMethod(payload)); } // should throw AssertEx.Throws <SecurityException>(() => { using (new ZyanConnection(serverUrl, clientSetup, credentials, true, true)) { } }); } }
/// <summary> /// Adds a specified server sink provider into the server sink chain before the formatter. /// </summary> /// <param name="protocolSetup">Protocol setup</param> /// <param name="serverSinkProvider">Server sink provider to be added</param> /// <returns>Protocol setup</returns> public static IServerProtocolSetup AddServerSinkBeforeFormatter(this IServerProtocolSetup protocolSetup, IServerChannelSinkProvider serverSinkProvider) { if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } if (serverSinkProvider == null) { throw new ArgumentNullException("serverSinkProvider"); } IServerFormatterSinkProvider formatter = GetServerFormatter(protocolSetup); if (formatter == null) { throw new ApplicationException(LanguageResource.ApplicationException_NoFormatterSpecified); } int index = protocolSetup.ServerSinkChain.IndexOf((IServerChannelSinkProvider)formatter); protocolSetup.ServerSinkChain.Insert(index, serverSinkProvider); return(protocolSetup); }
/// <summary> /// Adds a single channel setting. /// </summary> /// <param name="protocolSetup">Protocol setup</param> /// <param name="name">Name of channel setting (example: "port")</param> /// <param name="value">Value of channel setting (example: 8080)</param> /// <returns></returns> public static IServerProtocolSetup AddChannelSetting(this IServerProtocolSetup protocolSetup, string name, object value) { if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } protocolSetup.ChannelSettings.Add(name, value); return(protocolSetup); }
/// <summary> /// Returns the configured formatter from the server sink chain of a specified client protocol setup. /// </summary> /// <param name="protocolSetup">Protocol setup</param> /// <returns>server formatter sink</returns> public static IServerFormatterSinkProvider GetServerFormatter(this IServerProtocolSetup protocolSetup) { if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } return((from sink in protocolSetup.ServerSinkChain where sink is IServerFormatterSinkProvider select sink as IServerFormatterSinkProvider).FirstOrDefault()); }
/// <summary> /// Konstruktor. /// </summary> /// <param name="name">Name des Komponentenhosts</param> /// <param name="protocolSetup">Protokoll-Einstellungen</param> /// <param name="sessionManager">Sitzungsverwaltung</param> /// <param name="catalog">Komponenten-Katalog</param> public ZyanComponentHost(string name, IServerProtocolSetup protocolSetup, ISessionManager sessionManager, ComponentCatalog catalog) { // Wenn kein Name angegeben wurde ... if (string.IsNullOrEmpty(name)) { // Ausnahme werfen throw new ArgumentException(LanguageResource.ArgumentException_ComponentHostNameMissing, "name"); } // Wenn keine Protokoll-Einstellungen angegeben wurde ... if (protocolSetup == null) { // Ausnahme werfen throw new ArgumentNullException("protocolSetup"); } // Wenn keine Sitzungsverwaltung übergeben wurde ... if (sessionManager == null) { // Ausnahme werfen throw new ArgumentNullException("sessionManager"); } // Wenn kein Komponenten-Katalog angegeben wurde ... if (catalog == null) { // Ausnahme werfen throw new ArgumentNullException("catalog"); } // Werte übernehmen _name = name; _protocolSetup = protocolSetup; _sessionManager = sessionManager; _catalog = catalog; // Komponentenaufrufer erzeugen _invoker = new ZyanDispatcher(this); // Authentifizierungsanbieter übernehmen und verdrahten _authProvider = protocolSetup.AuthenticationProvider; this.Authenticate = _authProvider.Authenticate; // Komponenten Host der Host-Auflistung zufügen _hosts.Add(this); // Beginnen auf Client-Anfragen zu horchen StartListening(); }
/// <summary> /// Adds a specified server sink provider into the server sink chain. /// </summary> /// <param name="protocolSetup">Protocol setup</param> /// <param name="serverSinkProvider">Server sink provider to be added</param> /// <returns>Protocol setup</returns> public static IServerProtocolSetup AddServerSink(this IServerProtocolSetup protocolSetup, IServerChannelSinkProvider serverSinkProvider) { if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } if (serverSinkProvider == null) { throw new ArgumentNullException("serverSinkProvider"); } protocolSetup.ServerSinkChain.Add(serverSinkProvider); return(protocolSetup); }
/// <summary> /// Adds a specified client sink provider into the client sink chain. /// </summary> /// <param name="protocolSetup">Protocol setup</param> /// <param name="clientSinkProvider">Client sink provider to be added</param> /// <returns>Protocol setup</returns> public static IServerProtocolSetup AddClientSink(this IServerProtocolSetup protocolSetup, IClientChannelSinkProvider clientSinkProvider) { if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } if (clientSinkProvider == null) { throw new ArgumentNullException("clientSinkProvider"); } protocolSetup.ClientSinkChain.Add(clientSinkProvider); return(protocolSetup); }
/// <summary> /// Initializes a new instance of the <see cref="ZyanComponentHost" /> class. /// </summary> /// <param name="name">The name of the component host.</param> /// <param name="protocolSetup">The protocol setup.</param> /// <param name="sessionManager">The session manager.</param> /// <param name="catalog">The component catalog.</param> public ZyanComponentHost(string name, IServerProtocolSetup protocolSetup, ISessionManager sessionManager, IComponentCatalog catalog) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException(LanguageResource.ArgumentException_ComponentHostNameMissing, "name"); } if (protocolSetup == null) { throw new ArgumentNullException("protocolSetup"); } if (sessionManager == null) { throw new ArgumentNullException("sessionManager"); } if (catalog == null) { throw new ArgumentNullException("catalog"); } _name = name; _protocolSetup = protocolSetup; _sessionManager = sessionManager; _sessionManager.ClientSessionTerminated += (s, e) => OnClientSessionTerminated(e); _catalog = catalog; _serializationHandling = new SerializationHandlerRepository(); _dispatcher = new ZyanDispatcher(this); // Set up authentication request delegate _authProvider = protocolSetup.AuthenticationProvider; this.Authenticate = _authProvider.Authenticate; // Register standard serialization handlers RegisterStandardSerializationHandlers(); _hosts.Add(this); StartListening(); DiscoverableUrl = _protocolSetup.GetDiscoverableUrl(_name); }
/// <summary> /// Initializes a new instance of the <see cref="ZyanComponentHost" /> class. /// </summary> /// <param name="name">The name of the component host.</param> /// <param name="protocolSetup">The protocol setup.</param> /// <param name="sessionManager">The session manager.</param> public ZyanComponentHost(string name, IServerProtocolSetup protocolSetup, ISessionManager sessionManager) : this(name, protocolSetup, sessionManager, new ComponentCatalog()) { DisposeCatalogWithHost = true; }
/// <summary> /// Initializes a new instance of the <see cref="ZyanComponentHost" /> class. /// </summary> /// <param name="name">The name of the component host.</param> /// <param name="protocolSetup">The protocol setup.</param> /// <param name="catalog">The component catalog.</param> public ZyanComponentHost(string name, IServerProtocolSetup protocolSetup, IComponentCatalog catalog) : this(name, protocolSetup, new InProcSessionManager(), catalog) { }
/// <summary> /// Initializes a new instance of the <see cref="ZyanComponentHost" /> class. /// </summary> /// <param name="name">The name of the component host.</param> /// <param name="protocolSetup">The protocol setup.</param> /// <param name="sessionManager">The session manager.</param> public ZyanComponentHost(string name, IServerProtocolSetup protocolSetup, ISessionManager sessionManager) : this(name, protocolSetup, sessionManager, new ComponentCatalog(true)) { }