public ClientSecurityService(IEnvironmentConnection environmentConnection) { VerifyArgument.IsNotNull("environmentConnection", environmentConnection); _environmentConnection = environmentConnection; EnvironmentConnection.NetworkStateChanged += OnNetworkStateChanged; EnvironmentConnection.PermissionsModified+=EnvironmentConnectionOnPermissionsModified; }
/// <summary> /// Executes the command. /// </summary> /// <param name="connection">The connection.</param> /// <param name="workspaceId">The workspace unique identifier.</param> /// <returns></returns> public async Task <T> ExecuteCommandAsync <T>(IEnvironmentConnection connection, Guid workspaceId) { // build the service request payload ;) var serializer = new Dev2JsonSerializer(); if (connection == null || !connection.IsConnected) { if (connection != null) { var popupController = CustomContainer.Get <IPopupController>(); if (popupController != null && connection.HubConnection.State == ConnectionStateWrapped.Disconnected) { popupController.Show(string.Format("Server: {0} has disconnected.", connection.DisplayName) + Environment.NewLine + "Please reconnect before performing any actions", "Disconnected Server", MessageBoxButton.OK, MessageBoxImage.Information, ""); } } } else { // now bundle it up into a nice string builder ;) if (ServicePayload == null) { ServicePayload = new EsbExecuteRequest(); } ServicePayload.ServiceName = ServiceName; StringBuilder toSend = serializer.SerializeToBuilder(ServicePayload); var payload = await connection.ExecuteCommandAsync(toSend, workspaceId); return(serializer.Deserialize <T>(payload)); } return(default(T)); }
public ClientSecurityService(IEnvironmentConnection environmentConnection) { VerifyArgument.IsNotNull("environmentConnection", environmentConnection); _environmentConnection = environmentConnection; EnvironmentConnection.NetworkStateChanged += OnNetworkStateChanged; EnvironmentConnection.PermissionsModified += EnvironmentConnectionOnPermissionsModified; }
public void EnvironmentTestsInitialize() { var setupEnvironmentConnection = SetupEnvironmentConnection(); _connection = setupEnvironmentConnection; _connection.Connect(Guid.Empty); }
public void Connect(Guid id) { try { _wrappedConnection.Connect(_wrappedConnection.ID); } catch (FallbackException) { Dev2Logger.Log.Info("Falling Back to previous signal r client"); var name = _wrappedConnection.DisplayName; if (AuthenticationType == AuthenticationType.User) { _wrappedConnection = new ServerProxyWithChunking(_wrappedConnection.WebServerUri.ToString(), UserName, Password) { DisplayName = name, }; } else { _wrappedConnection = new ServerProxyWithChunking(_wrappedConnection.WebServerUri) { DisplayName = name }; } SetupPassthroughEvents(); _wrappedConnection.Connect(_wrappedConnection.ID); _wrappedConnection.DisplayName = name; } catch (Exception err) { Dev2Logger.Log.Error(err); throw; } }
protected ProxyBase(ICommunicationControllerFactory communicationControllerFactory, IEnvironmentConnection connection) { VerifyArgument.AreNotNull(new Dictionary <string, object> { { "communicationControllerFactory", communicationControllerFactory }, { "connection", connection } }); CommunicationControllerFactory = communicationControllerFactory; Connection = connection; }
public ServerProxy(Uri serverUri) { _wrappedConnection = new ServerProxyWithoutChunking(serverUri); SetupPassthroughEvents(); }
// ReSharper disable MemberCanBeProtected.Global public ServerProxy(string serverUri, ICredentials credentials, IAsyncWorker worker) // ReSharper restore MemberCanBeProtected.Global { _wrappedConnection = new ServerProxyWithoutChunking(serverUri,credentials,worker); SetupPassthroughEvents(); }
public void EnvironmentConnection_ConnectToAvailableServer_Expected_ConnectionSuccesful() { IEnvironmentConnection conn = CreateConnection(); conn.Connect(Guid.Empty); Assert.IsTrue(conn.IsConnected); conn.Disconnect(); }
public ClientAuthorizationService(ISecurityService securityService, bool isLocalConnection) : base(securityService, isLocalConnection) { if (securityService is ClientSecurityService clientSecurityService) { _environmentConnection = clientSecurityService.EnvironmentConnection; } }
public ClientAuthorizationService(ISecurityService securityService, bool isLocalConnection) : base(securityService, isLocalConnection) { var clientSecurityService = securityService as ClientSecurityService; if(clientSecurityService != null) { _environmentConnection = clientSecurityService.EnvironmentConnection; } }
public void EnsureServerListensOnLocalhost_ExpectedConnectionSuccessful() { var setupEnvironmentConnection = SetupEnvironmentConnection(); IEnvironmentConnection conn = setupEnvironmentConnection; conn.Connect(Guid.Empty); Assert.IsTrue(conn.IsConnected); conn.Disconnect(); }
public ClientAuthorizationService(ISecurityService securityService, bool isLocalConnection) : base(securityService, isLocalConnection) { var clientSecurityService = securityService as ClientSecurityService; if (clientSecurityService != null) { _environmentConnection = clientSecurityService.EnvironmentConnection; } }
//, IWizardEngine wizardEngine void Initialize(Guid id, IEnvironmentConnection environmentConnection, IResourceRepository resourceRepository, IStudioResourceRepository studioResourceRepository) { VerifyArgument.IsNotNull("environmentConnection", environmentConnection); VerifyArgument.IsNotNull("studioResourceRepository", studioResourceRepository); CanStudioExecute = true; _studioRepo = studioResourceRepository; ID = id; // The resource ID Connection = environmentConnection; // MUST subscribe to Guid.Empty as memo.InstanceID is NOT set by server! ResourceRepository = resourceRepository ?? new ResourceRepository(this); }
public bool Equals(IEnvironmentConnection other) { if (other == null) { return(false); } var isEqual = other.ID == ID && other.AuthenticationType == AuthenticationType && other.AppServerUri.Equals(AppServerUri) && other.WebServerUri.Equals(WebServerUri); return(isEqual); }
static void ValidatePayload(IEnvironmentConnection connection, StringBuilder payload, IPopupController popupController) { if ((payload == null || payload.Length == 0) && connection.HubConnection != null && popupController != null && connection.HubConnection.State == ConnectionStateWrapped.Disconnected && Application.Current != null) { Application.Current.Dispatcher.Invoke(() => { popupController.Show(ErrorResource.ServerconnectionDropped + Environment.NewLine + ErrorResource.EnsureConnectionToServerWorking , ErrorResource.ServerDroppedErrorHeading, MessageBoxButton.OK, MessageBoxImage.Information, "", false, false, true, false, false, false); }); } }
public void EnsureServerListensOnPcName_ExpectedConnectionSuccessful() { var setupEnvironmentConnection = SetupEnvironmentConnection(); IEnvironmentConnection conn = setupEnvironmentConnection; conn.Connect(Guid.Empty); var res = conn.IsConnected; conn.Disconnect(); Assert.IsTrue(res); }
public void EnvironmentConnectionWithServerAuthenticationExpectedClientDetailsRecieved() { IEnvironmentConnection conn = CreateConnection(); conn.Connect(Guid.Empty); // The IsConnected property of the EnvironmentConnection references the TCPDispatch Client // Only if the connection to the server is successfully made by the dispatch client will the // IsConnected message return true Assert.IsTrue(conn.IsConnected); conn.Disconnect(); }
public static Uri GetInternalServiceUri(string serviceName, IEnvironmentConnection connection) { if (connection == null || !connection.IsConnected) { return(null); } var relativeUrl = string.Format("/internal/{0}", serviceName); Uri.TryCreate(connection.WebServerUri, relativeUrl, out Uri url); return(url); }
public static Uri GetInternalServiceUri(string serviceName,IEnvironmentConnection connection) { if (connection == null || !connection.IsConnected) { return null; } var relativeUrl = string.Format("/internal/{0}", serviceName); Uri url; Uri.TryCreate(connection.WebServerUri, relativeUrl, out url); return url; }
private Task <bool> TryConnectingToWarewolfServer(IEnvironmentConnection environmentConnection) { try { var connectTask = environmentConnection.ConnectAsync(Guid.Empty); connectTask.Wait(); return(connectTask); } catch (Exception ex) { _logger.Error(ex.Message, _options.ServerEndpoint); return(Task.FromResult(false)); } }
void Initialize(Guid id, IEnvironmentConnection environmentConnection, IResourceRepository resourceRepository) { VerifyArgument.IsNotNull("environmentConnection", environmentConnection); CanStudioExecute = true; EnvironmentID = id; Connection = environmentConnection; ResourceRepository = resourceRepository ?? new ResourceRepository(this); var communicationControllerFactory = new CommunicationControllerFactory(); _proxyLayer = new StudioServerProxy(communicationControllerFactory, Connection); UpdateRepository = new StudioResourceUpdateManager(communicationControllerFactory, Connection); Connection.PermissionsModified += RaisePermissionsModifiedEvent; Connection.NetworkStateChanged += RaiseNetworkStateChangeEvent; Connection.ItemAddedMessageAction += ItemAdded; }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public StudioServerProxy(ICommunicationControllerFactory controllerFactory, IEnvironmentConnection environmentConnection) { if (controllerFactory == null) { throw new ArgumentNullException(nameof(controllerFactory)); } if (environmentConnection == null) { throw new ArgumentNullException(nameof(environmentConnection)); } QueryManagerProxy = new QueryManagerProxy(controllerFactory, environmentConnection); UpdateManagerProxy = new ExplorerUpdateManagerProxy(controllerFactory, environmentConnection); VersionManager = new VersionManagerProxy(controllerFactory, environmentConnection); AdminManagerProxy = new AdminManagerProxy(controllerFactory, environmentConnection); }
public void EnvironmentConnectionReconnectToServerExpecetedClientConnectionSuccessful() { IEnvironmentConnection conn = CreateConnection(); conn.Connect(Guid.Empty); conn.Disconnect(); Thread.Sleep(100); conn.Connect(Guid.Empty); Thread.Sleep(500); bool afterReconnection = conn.IsConnected; Assert.IsTrue(afterReconnection); conn.Disconnect(); }
/// <summary> /// Executes the command. /// </summary> /// <param name="connection">The connection.</param> /// <param name="workspaceId">The workspace unique identifier.</param> /// <returns></returns> public T ExecuteCommand <T>(IEnvironmentConnection connection, Guid workspaceId) { // build the service request payload ;) var serializer = new Dev2JsonSerializer(); if (connection == null || !connection.IsConnected) { if (connection != null) { try { var popupController = CustomContainer.Get <IPopupController>(); if (popupController != null && connection.HubConnection.State == ConnectionStateWrapped.Disconnected) { popupController.Show(string.Format("Server: {0} has disconnected.", connection.DisplayName) + Environment.NewLine + "Please reconnect before performing any actions", "Disconnected Server", MessageBoxButton.OK, MessageBoxImage.Information, ""); } } catch (Exception e) { Dev2Logger.Log.Error("Error popup", e); } } } else { // now bundle it up into a nice string builder ;) if (ServicePayload == null) { ServicePayload = new EsbExecuteRequest(); } ServicePayload.ServiceName = ServiceName; StringBuilder toSend = serializer.SerializeToBuilder(ServicePayload); var payload = connection.ExecuteCommand(toSend, workspaceId); if (payload == null || payload.Length == 0) { var popupController = CustomContainer.Get <IPopupController>(); if (connection.HubConnection != null && popupController != null && connection.HubConnection.State == ConnectionStateWrapped.Disconnected) { popupController.Show("Server connection has dropped during execution of command." + Environment.NewLine + "Please ensure that your server is still and your network connection is working." , "Server dropped", MessageBoxButton.OK, MessageBoxImage.Information, ""); } } return(serializer.Deserialize <T>(payload)); } return(default(T)); }
public void EnvironmentConnection_AddResource_NewResource_Expected_NewResourceAddedToServer() { var xmlString = CreateDataObject("FindResourceService", "*"); IEnvironmentConnection conn = CreateConnection(); conn.Connect(Guid.Empty); if (conn.IsConnected) { var returnData = conn.ExecuteCommand(xmlString, Guid.Empty); Assert.IsTrue(returnData.Contains("Workflow")); } else { Assert.Fail("Unable to create a connection to the server"); } conn.Connect(Guid.Empty); }
public void EnvironmentConnection_FindResources_Expected() { var request = CreateDataObject("FindResourceService", "*"); IEnvironmentConnection conn = CreateConnection(); conn.Connect(Guid.Empty); if (conn.IsConnected) { var returnData = conn.ExecuteCommand(request, Guid.Empty, Guid.Empty); Assert.IsTrue(returnData.Contains("Workflow")); } else { Assert.Fail("Unable to create a connection to the server"); } conn.Connect(Guid.Empty); }
public T ExecuteCompressedCommand <T>(IEnvironmentConnection connection, Guid workspaceId) where T : class { // build the service request payload ;) var serializer = new Dev2JsonSerializer(); if (connection == null) { return(default(T)); } if (!connection.IsConnected && !connection.IsConnecting) { var popupController = CustomContainer.Get <IPopupController>(); popupController?.Show(string.Format(ErrorResource.ServerDisconnected, connection.DisplayName) + Environment.NewLine + ErrorResource.ServerReconnectForActions, ErrorResource.ServerDisconnectedHeader, MessageBoxButton.OK, MessageBoxImage.Information, "", false, false, true, false, false, false); } else { // now bundle it up into a nice string builder ;) if (ServicePayload == null) { ServicePayload = new EsbExecuteRequest(); } ServicePayload.ServiceName = ServiceName; StringBuilder toSend = serializer.SerializeToBuilder(ServicePayload); var payload = connection.ExecuteCommand(toSend, workspaceId); try { if (payload == null || payload.Length == 0) { return(default(T)); } var message = serializer.Deserialize <CompressedExecuteMessage>(payload).GetDecompressedMessage(); return(serializer.Deserialize <T>(message)); } catch (NullReferenceException e) { Dev2Logger.Debug("fallback to non compressed", e); return(serializer.Deserialize <T>(payload)); } } return(default(T)); }
static void IsConnectionValid(IEnvironmentConnection connection, IPopupController popupController) { if (connection != null) { try { if (!connection.IsConnecting) { popupController?.Show(string.Format(ErrorResource.ServerDisconnected, connection.DisplayName) + Environment.NewLine + ErrorResource.ServerReconnectForActions, ErrorResource.ServerDisconnectedHeader, MessageBoxButton.OK, MessageBoxImage.Information, "", false, false, true, false, false, false); } } catch (Exception e) { Dev2Logger.Error("Error popup", e, "Warewolf Error"); } } }
public bool Connect() { try { var serverProxyFactory = new ServerProxyFactory(); _environmentConnection = serverProxyFactory.New(ServerEndpoint); Task <bool> connectTask = TryConnectingToWarewolfServer(_environmentConnection); if (connectTask.Result is false) { //TODO: Add with logging: _logger.Error("Connecting to server: " + _serverEndpoint + "... unsuccessful"); return(false); } return(true); } catch (Exception) { return(false); } }
public T ExecuteCommand <T>(IEnvironmentConnection connection, Guid workspaceId) where T : class { var serializer = new Dev2JsonSerializer(); var popupController = CustomContainer.Get <IPopupController>(); if (connection == null || !connection.IsConnected) { IsConnectionValid(connection, popupController); } else { if (ServicePayload == null) { ServicePayload = new EsbExecuteRequest(); } ServicePayload.ServiceName = ServiceName; var toSend = serializer.SerializeToBuilder(ServicePayload); var payload = connection.ExecuteCommand(toSend, workspaceId); ValidatePayload(connection, payload, popupController); var executeCommand = serializer.Deserialize <T>(payload); if (executeCommand == null) { var execMessage = serializer.Deserialize <ExecuteMessage>(payload); if (execMessage != null) { return(CheckAuthorization <T>(execMessage)); } } else { if (typeof(T) == typeof(ExecuteMessage)) { return(CheckAuthorization <T>(executeCommand as ExecuteMessage)); } return(executeCommand); } } return(default(T)); }
public async Task <T> ExecuteCompressedCommandAsync <T>(IEnvironmentConnection connection, Guid workspaceId) where T : class { // build the service request payload ;) var serializer = new Dev2JsonSerializer(); if (connection == null || !connection.IsConnected) { if (connection != null && !connection.IsConnecting) { var popupController = CustomContainer.Get <IPopupController>(); popupController?.Show(string.Format(ErrorResource.ServerDisconnected, connection.DisplayName) + Environment.NewLine + ErrorResource.ServerReconnectForActions, ErrorResource.ServerDisconnectedHeader, MessageBoxButton.OK, MessageBoxImage.Information, "", false, false, true, false, false, false); } } else { if (ServicePayload == null) { ServicePayload = new EsbExecuteRequest(); } ServicePayload.ServiceName = ServiceName; var toSend = serializer.SerializeToBuilder(ServicePayload); var payload = await connection.ExecuteCommandAsync(toSend, workspaceId).ConfigureAwait(true); try { var message = serializer.Deserialize <CompressedExecuteMessage>(payload).GetDecompressedMessage(); return(serializer.Deserialize <T>(message)); } catch (NullReferenceException e) { Dev2Logger.Debug("fallback to non compressed", e, "Warewolf Debug"); var val = serializer.Deserialize <T>(payload); return(val); } } return(default(T)); }
private Implementation.Config SetupQueueWorkerImplementationConfings(out Mock <IWriter> mockWriter, out Mock <IExecutionLogPublisher> mockExecutionLogPublisher, IEnvironmentConnection environmentConnection, IResourceCatalogProxy resourceCatalogProxy, IWorkerContextFactory workerContextFactory, ITriggersCatalog triggersCatalog, IFilePath filePath, IFileSystemWatcherFactory fileSystemWatcherFactory, IQueueWorkerImplementationFactory queueWorkerImplementationFactory, IEnvironmentWrapper environmentWrapper) { mockWriter = new Mock <IWriter>(); mockExecutionLogPublisher = new Mock <IExecutionLogPublisher>(); var mockExecutionLoggerFactory = new Mock <IExecutionLoggerFactory>(); mockExecutionLoggerFactory.Setup(o => o.New(It.IsAny <ISerializer>(), It.IsAny <IWebSocketPool>())).Returns(mockExecutionLogPublisher.Object); var mockResourceCatalogProxyFactory = new Mock <IResourceCatalogProxyFactory>(); mockResourceCatalogProxyFactory.Setup(o => o.New(environmentConnection)).Returns(resourceCatalogProxy); var mockServerProxyFactory = new Mock <IServerProxyFactory>(); mockServerProxyFactory.Setup(o => o.New(new Uri("https://localhost:3143/"))).Returns(environmentConnection); var mockTriggersCatalogFactory = new Mock <ITriggersCatalogFactory>(); mockTriggersCatalogFactory.Setup(o => o.New()).Returns(triggersCatalog); var implConfig = new Implementation.Config { EnvironmentWrapper = environmentWrapper, ExecutionLoggerFactory = mockExecutionLoggerFactory.Object, FilePath = filePath, FileSystemWatcherFactory = fileSystemWatcherFactory, QueueWorkerImplementationFactory = queueWorkerImplementationFactory, ResourceCatalogProxyFactory = mockResourceCatalogProxyFactory.Object, ServerProxyFactory = mockServerProxyFactory.Object, TriggersCatalogFactory = mockTriggersCatalogFactory.Object, WorkerContextFactory = workerContextFactory, Writer = mockWriter.Object }; return(implConfig); }
// ReSharper disable MemberCanBeProtected.Global public ServerProxy(string serverUri, ICredentials credentials, IAsyncWorker worker) { _wrappedConnection = new ServerProxyWithoutChunking(serverUri,credentials,worker); SetupPassthroughEvents(); }
protected virtual IAuthorizationService CreateAuthorizationService(IEnvironmentConnection environmentConnection) { var isLocalConnection = environmentConnection.WebServerUri != null && !string.IsNullOrEmpty(environmentConnection.WebServerUri.AbsoluteUri) && environmentConnection.WebServerUri.AbsoluteUri.ToLower().Contains(Environment.MachineName.ToLower()); return new ClientAuthorizationService(new ClientSecurityService(environmentConnection), isLocalConnection); }
public EnvironmentModel(Guid id, IEnvironmentConnection environmentConnection, IResourceRepository resourceRepository, IStudioResourceRepository studioResourceRepository) { VerifyArgument.IsNotNull("resourceRepository", resourceRepository); Initialize(id, environmentConnection, resourceRepository, studioResourceRepository); }
public ServerExplorerClientProxy(IEnvironmentConnection connection, ICommunicationControllerFactory communicationControllerFactory) { CommunicationControllerFactory = communicationControllerFactory; _connection = connection; }
public TestClientSecurityService(IEnvironmentConnection environmentConnection) : base(environmentConnection) { }
public ServerExplorerClientProxy(IEnvironmentConnection connection) { CommunicationControllerFactory = new CommunicationControllerFactory(); _connection = connection; }
protected override IAuthorizationService CreateAuthorizationService(IEnvironmentConnection environmentConnection) { _authorizationServiceMock = new Mock<IAuthorizationService>(); return AuthorizationServiceMock.Object; }
public ServerProxy(string webAddress, string userName, string password) { _wrappedConnection = new ServerProxyWithoutChunking(webAddress, userName, password); SetupPassthroughEvents(); }
//, IWizardEngine wizardEngine public EnvironmentModel(Guid id, IEnvironmentConnection environmentConnection, IStudioResourceRepository studioResourceRepository) { Initialize(id, environmentConnection, null, studioResourceRepository); }
public TestEnvironmentModel(IEventAggregator eventPublisher, Guid id, IEnvironmentConnection environmentConnection, IResourceRepository resourceRepository, bool publishEventsOnDispatcherThread = true) : base(id, environmentConnection, resourceRepository, new Mock<IStudioResourceRepository>().Object) { }
//, IWizardEngine wizardEngine public EnvironmentModel(Guid id, IEnvironmentConnection environmentConnection) : this(id, environmentConnection, StudioResourceRepository.Instance) { }
public static string FullyEncodeServerDetails(IEnvironmentConnection allServerDetails) { return HttpUtility.UrlEncode(allServerDetails.DisplayName + " (" + allServerDetails.AppServerUri.ToString().Replace(".", "%2E") + ")"); }
static EnvironmentModel CreateEnvironmentModel(Guid id, IEnvironmentConnection connection) { var repo = new Mock<IResourceRepository>(); return new EnvironmentModel(id, connection, repo.Object, new Mock<IStudioResourceRepository>().Object); }
public ServerExplorerVersionProxy(IEnvironmentConnection connection) { CommunicationControllerFactory = new CommunicationControllerFactory(); _connection = connection; }
public void Connect(Guid id) { try { _wrappedConnection.Connect(_wrappedConnection.ID); } catch( FallbackException) { Dev2Logger.Log.Info("Falling Back to previous signal r client"); var name = _wrappedConnection.DisplayName; if (AuthenticationType == AuthenticationType.User) { _wrappedConnection = new ServerProxyWithChunking(_wrappedConnection.WebServerUri.ToString(),UserName,Password) { DisplayName = name, }; } else { _wrappedConnection = new ServerProxyWithChunking(_wrappedConnection.WebServerUri) { DisplayName = name }; } SetupPassthroughEvents(); _wrappedConnection.Connect(_wrappedConnection.ID); _wrappedConnection.DisplayName = name; } catch (Exception err) { Dev2Logger.Log.Error(err); throw; } }