public IActionResult SMTP(int i) { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.SMTP }); var req = this.HttpContext.Request.Form; SMTPConnection smtpcon = new SMTPConnection(); smtpcon.NickName = req["nickname"]; smtpcon.Smtp = req["smtp"]; smtpcon.Port = Int32.Parse(req["port"]); smtpcon.EmailAddress = req["email"]; smtpcon.Password = req["pwd"]; if (!String.IsNullOrEmpty(solutionConnections.EBSolutionConnections.SMTPConnection.EmailAddress)) { if (String.IsNullOrEmpty(smtpcon.Password) && smtpcon.EmailAddress == solutionConnections.EBSolutionConnections.SMTPConnection.EmailAddress) { smtpcon.Password = solutionConnections.EBSolutionConnections.SMTPConnection.Password; } this.ServiceClient.Post <bool>(new ChangeSMTPConnectionRequest { SMTPConnection = smtpcon, IsNew = false }); } else { this.ServiceClient.Post <bool>(new ChangeSMTPConnectionRequest { SMTPConnection = smtpcon, IsNew = true }); } return(Redirect("/ConnectionManager")); }
// GET: /<controller>/ public IActionResult Index() { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = 0 }); if ((solutionConnections.EBSolutionConnections.FilesDbConnection.IsDefault == true)) { solutionConnections.EBSolutionConnections.FilesDbConnection = new EbFilesDbConnection(); } if ((solutionConnections.EBSolutionConnections.DataDbConnection.IsDefault == true)) { solutionConnections.EBSolutionConnections.DataDbConnection = new EbDataDbConnection(); } if ((solutionConnections.EBSolutionConnections.SMTPConnection == null)) { solutionConnections.EBSolutionConnections.SMTPConnection = new SMTPConnection(); } if (solutionConnections.EBSolutionConnections == null) { solutionConnections.EBSolutionConnections.SMSConnection = new SMSConnection(); } if ((solutionConnections.EBSolutionConnections.ObjectsDbConnection.IsDefault == true)) { solutionConnections.EBSolutionConnections.ObjectsDbConnection = new EbObjectsDbConnection(); } ViewBag.Connections = solutionConnections.EBSolutionConnections; return(View()); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetConnectionsResponse response = new GetConnectionsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Connections", targetDepth)) { var unmarshaller = new ListUnmarshaller <Connection, ConnectionUnmarshaller>(ConnectionUnmarshaller.Instance); response.Connections = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task GetConnectionsResponse_using_System_Text_Json() { GetConnectionsResponse getConnectionsResponse = await HttpClient.GetFromJsonAsync <GetConnectionsResponse>(GetConnectionsRequest.GetRoute()); ValidateGetConnectionsResponse(GetConnectionsRequest, getConnectionsResponse); }
public async Task GetConnectionsResponse_using_Json_Net() { GetConnectionsResponse getConnectionsResponse = await GetJsonAsync <GetConnectionsResponse>(GetConnectionsRequest.GetRoute()); ValidateGetConnectionsResponse(GetConnectionsRequest, getConnectionsResponse); }
public IActionResult SMSAccount(int i) { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.SMS }); var req = this.HttpContext.Request.Form; SMSConnection smscon = new SMSConnection(); smscon.ProviderName = req["provider"]; smscon.NickName = req["nickname"]; smscon.UserName = req["username"]; smscon.From = req["from"]; smscon.Password = req["pwd"]; if (!String.IsNullOrEmpty(solutionConnections.EBSolutionConnections.SMSConnection.UserName)) { if (String.IsNullOrEmpty(smscon.Password) && smscon.UserName == solutionConnections.EBSolutionConnections.SMSConnection.UserName) { smscon.Password = solutionConnections.EBSolutionConnections.SMSConnection.Password; } this.ServiceClient.Post <bool>(new ChangeSMSConnectionRequest { SMSConnection = smscon, IsNew = false }); } else { this.ServiceClient.Post <bool>(new ChangeSMSConnectionRequest { SMSConnection = smscon, IsNew = true }); } return(Redirect("/ConnectionManager")); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonGlueConfig config = new AmazonGlueConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonGlueClient client = new AmazonGlueClient(creds, config); GetConnectionsResponse resp = new GetConnectionsResponse(); do { GetConnectionsRequest req = new GetConnectionsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.GetConnections(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.ConnectionList) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
public IActionResult EditDataDB() { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.EbDATA }); ViewBag.DataDB = solutionConnections.EBSolutionConnections.DataDbConnection; return(View()); }
public IActionResult EditSMTP() { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.SMTP }); ViewBag.SMTP = solutionConnections.EBSolutionConnections.SMTPConnection; return(View()); }
// GET: /<controller>/ public IActionResult Index() { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = 0 }); ViewBag.Connections = solutionConnections.EBSolutionConnections; return(View()); }
public async Task GetConnectionsResponse() { // Arrage await CreateAnInvitation(); // Act GetConnectionsResponse getConnectionsResponse = await Send(GetConnectionsRequest); // Assert ValidateGetConnectionsResponse(GetConnectionsRequest, getConnectionsResponse); }
public IActionResult FilesDb() { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.EbDATA }); if ((solutionConnections.EBSolutionConnections.FilesDbConnection.IsDefault == true)) { solutionConnections.EBSolutionConnections.FilesDbConnection = new EbFilesDbConnection(); } ViewBag.FilesDb = solutionConnections.EBSolutionConnections.FilesDbConnection; return(View()); }
public IActionResult SMSAccount() { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.SMS }); if (solutionConnections.EBSolutionConnections == null) { solutionConnections.EBSolutionConnections.SMSConnection = new SMSConnection(); } ViewBag.SMS = solutionConnections.EBSolutionConnections.SMSConnection; return(View()); }
public async Task ResetWalletResponse_and_reset_wallet() { // Arrage // Add something to the wallet await CreateAnInvitation(); //Act ResetWalletResponse resetWalletResponse = await Send(ResetWalletRequest); // See what is in the wallet GetConnectionsRequest getConnectionsRequest = CreateValidGetConnectionsRequest(); GetConnectionsResponse getConnectionsResponse = await Send(getConnectionsRequest); // Assert Item created isn't there getConnectionsResponse.ConnectionRecords.Count.Should().Be(0); ValidateResetWalletResponse(ResetWalletRequest, resetWalletResponse); }
public static void HandleGetConnectionsResponse(Client client, GetConnectionsResponse packet) { if (client.Value == null || client.Value.FrmCon == null) { return; } client.Value.FrmCon.ClearListviewItems(); // None of the arrays containing the process' information can be null. // The must also be the exact same length because each entry in the five // different arrays represents one process. if (packet.Processes == null || packet.LocalAddresses == null || packet.LocalPorts == null || packet.RemoteAddresses == null || packet.RemotePorts == null || packet.States == null || packet.Processes.Length != packet.LocalAddresses.Length || packet.Processes.Length != packet.LocalPorts.Length || packet.Processes.Length != packet.RemoteAddresses.Length || packet.Processes.Length != packet.RemotePorts.Length || packet.Processes.Length != packet.States.Length) { return; } new Thread(() => { /*if (client.Value != null && client.Value.FrmTm != null) * client.Value.FrmTm.SetProcessesCount(packet.Process.Length);*/ for (int i = 0; i < packet.Processes.Length; i++) { /*if (packet.IDs[i] == 0 || packet.Processes[i] == "System.exe") * continue;*/ if (client.Value == null || client.Value.FrmCon == null) { break; } client.Value.FrmCon.AddConnectionToListview(packet.Processes[i], packet.LocalAddresses[i], packet.LocalPorts[i], packet.RemoteAddresses[i], packet.RemotePorts[i], ((ConnectionStates)packet.States[i]).ToString()); } }).Start(); }
public IActionResult FilesDb(int i) { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.EbFILES }); var req = this.HttpContext.Request.Form; EbFilesDbConnection dbcon = new EbFilesDbConnection(); dbcon.FilesDB_url = req["url"].ToString(); if (solutionConnections.EBSolutionConnections.FilesDbConnection != null) { this.ServiceClient.Post <bool>(new ChangeFilesDBConnectionRequest { FilesDBConnection = dbcon, IsNew = false }); } else { this.ServiceClient.Post <bool>(new ChangeFilesDBConnectionRequest { FilesDBConnection = dbcon, IsNew = true }); } return(Redirect("/ConnectionManager")); }
public IActionResult ObjectsDb(int i) { GetConnectionsResponse solutionConnections = this.ServiceClient.Post <GetConnectionsResponse>(new GetConnectionsRequest { ConnectionType = (int)EbConnectionTypes.EbOBJECTS }); var req = this.HttpContext.Request.Form; EbObjectsDbConnection dbcon = new EbObjectsDbConnection(); dbcon.NickName = req["nickname"]; dbcon.Server = req["server"]; dbcon.Port = Int32.Parse(req["port"]); dbcon.UserName = req["username"]; dbcon.Password = req["pwd"]; if (!String.IsNullOrEmpty(req["Isdef"])) { dbcon.IsDefault = false; } if (solutionConnections.EBSolutionConnections.ObjectsDbConnection != null) { if (String.IsNullOrEmpty(dbcon.Password) && dbcon.UserName == solutionConnections.EBSolutionConnections.SMSConnection.UserName && dbcon.Server == solutionConnections.EBSolutionConnections.DataDbConnection.Server) { dbcon.Password = solutionConnections.EBSolutionConnections.ObjectsDbConnection.Password; } this.ServiceClient.Post <bool>(new ChangeObjectsDBConnectionRequest { ObjectsDBConnection = dbcon, IsNew = false }); } else { this.ServiceClient.Post <bool>(new ChangeObjectsDBConnectionRequest { ObjectsDBConnection = dbcon, IsNew = true }); } return(Redirect("/ConnectionManager")); }
private void Execute(ISender client, GetConnectionsResponse message) { OnReport(message.Connections); }
public async Task DoWorkAsync() { _context.Database.OpenConnection(); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.S3Buckets ON"); ListBucketsResponse listBucketResponse = await _S3Client.ListBucketsAsync(new ListBucketsRequest()); bool sageMakerBucketFound = false, apacheWebLogBucketFound = false, SSHLogBucketFound = false, windowsSecurityLogBucketFound = false, squidProxyLogBucketFound = false; foreach (var bucket in listBucketResponse.Buckets) { if (bucket.BucketName.Equals("master-sagemaker-data")) { sageMakerBucketFound = true; if (_context.S3Buckets.Find(1) == null) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 1, Name = "master-sagemaker-data" }); } } else if (bucket.BucketName.Equals("smartinsights-test-website")) { apacheWebLogBucketFound = true; if (_context.S3Buckets.Find(2) == null) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 2, Name = "smartinsights-test-website" }); } } else if (bucket.BucketName.Equals("smartinsights-ssh-logs")) { SSHLogBucketFound = true; if (_context.S3Buckets.Find(3) == null) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 3, Name = "smartinsights-ssh-logs" }); } } else if (bucket.BucketName.Equals("smartinsights-windows-security-logs")) { windowsSecurityLogBucketFound = true; if (_context.S3Buckets.Find(4) == null) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 4, Name = "smartinsights-windows-security-logs" }); } } else if (bucket.BucketName.Equals("smartinsights-squid-proxy-logs")) { squidProxyLogBucketFound = true; if (_context.S3Buckets.Find(5) == null) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 5, Name = "smartinsights-squid-proxy-logs" }); } } if (sageMakerBucketFound && apacheWebLogBucketFound && SSHLogBucketFound && windowsSecurityLogBucketFound && squidProxyLogBucketFound) { break; } } if (!sageMakerBucketFound && _context.S3Buckets.Find(2) == null) { PutBucketResponse putBucketResponse2 = await _S3Client.PutBucketAsync(new PutBucketRequest { BucketName = "master-sagemaker-data", UseClientRegion = true, CannedACL = S3CannedACL.Private }); PutBucketTaggingResponse putBucketTaggingResponse2 = await _S3Client.PutBucketTaggingAsync(new PutBucketTaggingRequest { BucketName = "master-sagemaker-data", TagSet = new List <Tag> { new Tag { Key = "Project", Value = "OSPJ" } } }); PutPublicAccessBlockResponse putPublicAccessBlockResponse2 = await _S3Client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { BucketName = "master-sagemaker-data", PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicAcls = true, BlockPublicPolicy = true, IgnorePublicAcls = true, RestrictPublicBuckets = true } }); if (putBucketResponse2.HttpStatusCode.Equals(HttpStatusCode.OK) && putPublicAccessBlockResponse2.HttpStatusCode.Equals(HttpStatusCode.OK)) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 1, Name = "master-sagemaker-data" }); } } if (!apacheWebLogBucketFound && _context.S3Buckets.Find(3) == null) { PutBucketResponse putBucketResponse3 = await _S3Client.PutBucketAsync(new PutBucketRequest { BucketName = "smartinsights-test-website", UseClientRegion = true, CannedACL = S3CannedACL.Private }); PutBucketTaggingResponse putBucketTaggingResponse3 = await _S3Client.PutBucketTaggingAsync(new PutBucketTaggingRequest { BucketName = "smartinsights-test-website", TagSet = new List <Tag> { new Tag { Key = "Project", Value = "OSPJ" } } }); PutPublicAccessBlockResponse putPublicAccessBlockResponse3 = await _S3Client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { BucketName = "smartinsights-test-website", PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicAcls = true, BlockPublicPolicy = true, IgnorePublicAcls = true, RestrictPublicBuckets = true } }); if (putBucketResponse3.HttpStatusCode.Equals(HttpStatusCode.OK) && putPublicAccessBlockResponse3.HttpStatusCode.Equals(HttpStatusCode.OK)) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 2, Name = "smartinsights-apache-web-logs" }); } } if (!SSHLogBucketFound && _context.S3Buckets.Find(4) == null) { PutBucketResponse putBucketResponse4 = await _S3Client.PutBucketAsync(new PutBucketRequest { BucketName = "smartinsights-ssh-logs", UseClientRegion = true, CannedACL = S3CannedACL.Private }); PutBucketTaggingResponse putBucketTaggingResponse4 = await _S3Client.PutBucketTaggingAsync(new PutBucketTaggingRequest { BucketName = "smartinsights-ssh-logs", TagSet = new List <Tag> { new Tag { Key = "Project", Value = "OSPJ" } } }); PutPublicAccessBlockResponse putPublicAccessBlockResponse4 = await _S3Client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { BucketName = "smartinsights-ssh-logs", PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicAcls = true, BlockPublicPolicy = true, IgnorePublicAcls = true, RestrictPublicBuckets = true } }); if (putBucketResponse4.HttpStatusCode.Equals(HttpStatusCode.OK) && putPublicAccessBlockResponse4.HttpStatusCode.Equals(HttpStatusCode.OK)) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 3, Name = "smartinsights-ssh-logs" }); } } if (!windowsSecurityLogBucketFound && _context.S3Buckets.Find(5) == null) { PutBucketResponse putBucketResponse5 = await _S3Client.PutBucketAsync(new PutBucketRequest { BucketName = "smartinsights-windows-security-logs", UseClientRegion = true, CannedACL = S3CannedACL.Private }); PutBucketTaggingResponse putBucketTaggingResponse5 = await _S3Client.PutBucketTaggingAsync(new PutBucketTaggingRequest { BucketName = "smartinsights-windows-security-logs", TagSet = new List <Tag> { new Tag { Key = "Project", Value = "OSPJ" } } }); PutPublicAccessBlockResponse putPublicAccessBlockResponse5 = await _S3Client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { BucketName = "smartinsights-windows-security-logs", PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicAcls = true, BlockPublicPolicy = true, IgnorePublicAcls = true, RestrictPublicBuckets = true } }); if (putBucketResponse5.HttpStatusCode.Equals(HttpStatusCode.OK) && putPublicAccessBlockResponse5.HttpStatusCode.Equals(HttpStatusCode.OK)) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 4, Name = "smartinsights-windows-security-logs" }); } } if (!squidProxyLogBucketFound && _context.S3Buckets.Find(6) == null) { PutBucketResponse putBucketResponse6 = await _S3Client.PutBucketAsync(new PutBucketRequest { BucketName = "smartinsights-squid-proxy-logs", UseClientRegion = true, CannedACL = S3CannedACL.Private }); PutBucketTaggingResponse putBucketTaggingResponse6 = await _S3Client.PutBucketTaggingAsync(new PutBucketTaggingRequest { BucketName = "smartinsights-squid-proxy-logs", TagSet = new List <Tag> { new Tag { Key = "Project", Value = "OSPJ" } } }); PutPublicAccessBlockResponse putPublicAccessBlockResponse6 = await _S3Client.PutPublicAccessBlockAsync(new PutPublicAccessBlockRequest { BucketName = "smartinsights-squid-proxy-logs", PublicAccessBlockConfiguration = new PublicAccessBlockConfiguration { BlockPublicAcls = true, BlockPublicPolicy = true, IgnorePublicAcls = true, RestrictPublicBuckets = true } }); if (putBucketResponse6.HttpStatusCode.Equals(HttpStatusCode.OK) && putPublicAccessBlockResponse6.HttpStatusCode.Equals(HttpStatusCode.OK)) { _context.S3Buckets.Add(new Models.S3Bucket { ID = 5, Name = "smartinsights-squid-proxy-logs" }); } } await _context.SaveChangesAsync(); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.S3Buckets OFF"); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.GlueDatabases ON"); try { GetDatabaseResponse getDatabaseResponse = await _GlueClient.GetDatabaseAsync(new GetDatabaseRequest { Name = "master-database" }); if (_context.GlueDatabases.Find(1) == null) { _context.GlueDatabases.Add(new Models.GlueDatabase { ID = 1, Name = "master-database" }); } } catch (EntityNotFoundException) { CreateDatabaseResponse createDatabaseResponse = await _GlueClient.CreateDatabaseAsync(new CreateDatabaseRequest { DatabaseInput = new DatabaseInput { Name = "master-database" } }); if (createDatabaseResponse.HttpStatusCode.Equals(HttpStatusCode.OK)) { _context.GlueDatabases.Add(new Models.GlueDatabase { ID = 1, Name = "master-database" }); } } finally { await _context.SaveChangesAsync(); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.GlueDatabases OFF"); } GetConnectionsResponse getConnectionsResponse = await _GlueClient.GetConnectionsAsync(new GetConnectionsRequest { HidePassword = false }); bool GlueDBConnectionNameMatch = false, GlueDBConnectionParamtetersMatch = false; foreach (Connection c in getConnectionsResponse.ConnectionList) { if (c.Name.Equals(Environment.GetEnvironmentVariable("GLUE_DB-CONNECTION_NAME"))) { GlueDBConnectionNameMatch = true; } c.ConnectionProperties.TryGetValue("JDBC_CONNECTION_URL", out string DBHost); c.ConnectionProperties.TryGetValue("USERNAME", out string DBUserName); c.ConnectionProperties.TryGetValue("PASSWORD", out string DBPassword); if (DBHost.Contains(Environment.GetEnvironmentVariable("RDS_HOSTNAME")) && DBUserName.Equals(Environment.GetEnvironmentVariable("RDS_USERNAME")) && DBPassword.Equals(Environment.GetEnvironmentVariable("RDS_PASSWORD"))) { GlueDBConnectionParamtetersMatch = true; } if (GlueDBConnectionNameMatch && GlueDBConnectionParamtetersMatch) { break; } } if (!GlueDBConnectionParamtetersMatch) { if (GlueDBConnectionNameMatch) { DeleteConnectionResponse deleteConnectionResponse = await _GlueClient.DeleteConnectionAsync(new DeleteConnectionRequest { ConnectionName = Environment.GetEnvironmentVariable("GLUE_DB-CONNECTION_NAME") }); if (deleteConnectionResponse.HttpStatusCode.Equals(HttpStatusCode.OK)) { await _GlueClient.CreateConnectionAsync(new CreateConnectionRequest { ConnectionInput = new ConnectionInput { ConnectionProperties = new Dictionary <string, string>() { { "JDBC_CONNECTION_URL", "jdbc:sqlserver://" + Environment.GetEnvironmentVariable("RDS_HOSTNAME") + ":" + Environment.GetEnvironmentVariable("RDS_PORT") + ";databaseName=" + Environment.GetEnvironmentVariable("GLUE_INGESTION-DB_NAME") }, { "JDBC_ENFORCE_SSL", "false" }, { "USERNAME", Environment.GetEnvironmentVariable("RDS_USERNAME") }, { "PASSWORD", Environment.GetEnvironmentVariable("RDS_PASSWORD") }, }, ConnectionType = ConnectionType.JDBC, Name = Environment.GetEnvironmentVariable("GLUE_DB-CONNECTION_NAME"), PhysicalConnectionRequirements = new PhysicalConnectionRequirements { AvailabilityZone = "ap-southeast-1c", SubnetId = "subnet-0daa6ec8e25a13077", SecurityGroupIdList = new List <string> { "sg-0e1e79f6d49b3ed11" } } } }); } } else { await _GlueClient.CreateConnectionAsync(new CreateConnectionRequest { ConnectionInput = new ConnectionInput { ConnectionProperties = new Dictionary <string, string>() { { "JDBC_CONNECTION_URL", "jdbc:sqlserver://" + Environment.GetEnvironmentVariable("RDS_HOSTNAME") + ":" + Environment.GetEnvironmentVariable("RDS_PORT") + ";databaseName=" + Environment.GetEnvironmentVariable("GLUE_INGESTION-DB_NAME") }, { "JDBC_ENFORCE_SSL", "false" }, { "USERNAME", Environment.GetEnvironmentVariable("RDS_USERNAME") }, { "PASSWORD", Environment.GetEnvironmentVariable("RDS_PASSWORD") }, }, ConnectionType = ConnectionType.JDBC, Name = Environment.GetEnvironmentVariable("GLUE_DB-CONNECTION_NAME"), PhysicalConnectionRequirements = new PhysicalConnectionRequirements { AvailabilityZone = "ap-southeast-1c", SubnetId = "subnet-0daa6ec8e25a13077", SecurityGroupIdList = new List <string> { "sg-0e1e79f6d49b3ed11" } } } }); } } if (!_context.LogInputs.Any()) { _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.LogInputs ON"); _context.LogInputs.Add(new Models.LogInput { ID = 1, Name = "Test Website", FirehoseStreamName = "SmartInsights-Test-Website", ConfigurationJSON = "{\r\n \"cloudwatch.emitMetrics\": false,\r\n \"awsSecretAccessKey\": \"XW2HNGQnW9ygpvPDzQQemY0AhsFlUGwiKnVpZGbO\",\r\n \"firehose.endpoint\": \"firehose.ap-southeast-1.amazonaws.com\",\r\n \"awsAccessKeyId\": \"AKIASXW25GZQH5IABE4P\",\r\n \"flows\": [\r\n {\r\n \"filePattern\": \"/var/www/example.hansen-lim.me/log/access.log\",\r\n \"deliveryStream\": \"SmartInsights-Test-Website\",\r\n \"dataProcessingOptions\": [\r\n {\r\n \"optionName\": \"LOGTOJSON\",\r\n \"logFormat\": \"COMBINEDAPACHELOG\"\r\n }\r\n ]\r\n}", LogInputCategory = Models.LogInputCategory.ApacheWebServer, LinkedUserID = 1, LinkedS3BucketID = _context.S3Buckets.Find(2).ID, LinkedS3Bucket = _context.S3Buckets.Find(2), InitialIngest = true }); _context.LogInputs.Add(new Models.LogInput { ID = 2, Name = "Linux SSH Server Logs", FirehoseStreamName = "SmartInsights-SSH-Login-Logs", ConfigurationJSON = "{\r\n \"cloudwatch.emitMetrics\": false,\r\n \"awsSecretAccessKey\": \"XW2HNGQnW9ygpvPDzQQemY0AhsFlUGwiKnVpZGbO\",\r\n \"firehose.endpoint\": \"firehose.ap-southeast-1.amazonaws.com\",\r\n \"awsAccessKeyId\": \"AKIASXW25GZQH5IABE4P\",\r\n \"flows\": [\r\n {\r\n \"filePattern\": \"/opt/log/www1/secure.log\",\r\n \"deliveryStream\": \"SmartInsights-SSH-Login-Logs\",\r\n \"dataProcessingOptions\": [\r\n {\r\n \"optionName\": \"LOGTOJSON\",\r\n \"logFormat\": \"SYSLOG\",\r\n \"matchPattern\": \"^([\\\\w]+) ([\\\\w]+) ([\\\\d]+) ([\\\\d]+) ([\\\\w:]+) ([\\\\w]+) ([\\\\w]+)\\\\[([\\\\d]+)\\\\]\\\\: ([\\\\w\\\\s.\\\\:=]+)$\",\r\n \"customFieldNames\": [\"weekday\", \"month\", \"day\", \"year\", \"time\", \"host\", \"process\", \"identifer\",\"message\"]\r\n }\r\n ]\r\n}", LogInputCategory = Models.LogInputCategory.SSH, LinkedUserID = 1, LinkedS3BucketID = _context.S3Buckets.Find(3).ID, LinkedS3Bucket = _context.S3Buckets.Find(3), InitialIngest = true }); _context.LogInputs.Add(new Models.LogInput { ID = 3, Name = "Windows Security Events", FirehoseStreamName = "SmartInsights-Windows-Security-Logs", ConfigurationJSON = "{ \r\n \"Sources\":[ \r\n { \r\n \"Id\":\"" + "WinSecurityLog" + "\",\r\n \"SourceType\":\"WindowsEventLogSource\",\r\n \"LogName\":\" " + "Security" + " \"\r\n \"IncludeEventData\" : true\r\n }\r\n ],\r\n \"Sinks\":[ \r\n { \r\n \"Id\":\"WinSecurityKinesisFirehose\",\r\n \"SinkType\":\"KinesisFirehose\",\r\n \"AccessKey\":\"" + "AKIASXW25GZQH5IABE4P" + "\",\r\n \"SecretKey\":\"" + "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" + "\",\r\n \"Region\":\"ap-southeast-1\",\r\n \"StreamName\":\"" + "SmartInsights-Windows-Security-Logs" + "\"\r\n \"Format\": \"json\"\r\n }\r\n ],\r\n \"Pipes\":[ \r\n { \r\n \"Id\":\"WinSecurityPipe\",\r\n \"SourceRef\":\"WinSecurityLog\",\r\n \"SinkRef\":\"WinSecurityKinesisFirehose\"\r\n }\r\n ],\r\n \"SelfUpdate\":0\r\n}", LogInputCategory = Models.LogInputCategory.WindowsEventLogs, LinkedUserID = 1, LinkedS3BucketID = _context.S3Buckets.Find(4).ID, LinkedS3Bucket = _context.S3Buckets.Find(4), InitialIngest = true }); _context.LogInputs.Add(new Models.LogInput { ID = 4, Name = "Squid Proxy Server", FirehoseStreamName = "SmartInsights-Cisco-Squid-Proxy-Logs", ConfigurationJSON = "{\r\n \"cloudwatch.emitMetrics\": false,\r\n \"awsSecretAccessKey\": \"XW2HNGQnW9ygpvPDzQQemY0AhsFlUGwiKnVpZGbO\",\r\n \"firehose.endpoint\": \"firehose.ap-southeast-1.amazonaws.com\",\r\n \"awsAccessKeyId\": \"AKIASXW25GZQH5IABE4P\",\r\n \"flows\": [\r\n {\r\n \"filePattern\": \"/opt/log/cisco_router1/cisco_ironport_web.log\",\r\n \"deliveryStream\": \"SmartInsights-Cisco-Squid-Proxy-Logs\",\r\n \"dataProcessingOptions\": [\r\n {\r\n \"optionName\": \"LOGTOJSON\",\r\n \"logFormat\": \"SYSLOG\",\r\n \"matchPattern\": \"^([\\\\w.]+) (?:[\\\\d]+) ([\\\\d.]+) ([\\\\w]+)\\\\/([\\\\d]+) ([\\\\d]+) ([\\\\w.]+) ([\\\\S]+) ([\\\\S]+) (?:[\\\\w]+)\\\\/([\\\\S]+) ([\\\\S]+) (?:[\\\\S\\\\s]+)$\",\r\n \"customFieldNames\": [\"timestamp\",\"destination_ip_address\",\"action\",\"http_status_code\",\"bytes_in\",\"http_method\",\"requested_url\",\"user\",\"requested_url_domain\",\"content_type\"]\r\n }\r\n ]\r\n }\r\n ]\r\n}", LogInputCategory = Models.LogInputCategory.SquidProxy, LinkedUserID = 1, LinkedS3BucketID = _context.S3Buckets.Find(5).ID, LinkedS3Bucket = _context.S3Buckets.Find(5), InitialIngest = true }); await _context.SaveChangesAsync(); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.LogInputs OFF"); _context.GlueConsolidatedEntities.Add(new Models.GlueConsolidatedEntity { CrawlerName = "Test Website", LinkedLogInputID = _context.LogInputs.Find(1).ID, JobName = "Test Website" }); _context.GlueConsolidatedEntities.Add(new Models.GlueConsolidatedEntity { CrawlerName = "SSH Logs", LinkedLogInputID = _context.LogInputs.Find(2).ID, JobName = "SSH Logs" }); _context.GlueConsolidatedEntities.Add(new Models.GlueConsolidatedEntity { CrawlerName = "Windows Security Logs", LinkedLogInputID = _context.LogInputs.Find(3).ID, JobName = "Windows Security Logs" }); _context.GlueConsolidatedEntities.Add(new Models.GlueConsolidatedEntity { CrawlerName = "Squid Proxy Logs", LinkedLogInputID = _context.LogInputs.Find(4).ID, JobName = "Squid Proxy Logs" }); _context.AlertTriggers.Add(new Models.Trigger { Name = "Logins", AlertTriggerType = Models.AlertTriggerType.IPInsights, CondtionalField = "request", CondtionType = "Equal", Condtion = "GET /staging HTTP/1.1", IPAddressField = "host", UserField = "authuser", CurrentInputDataKey = "Test-Website/Input/ipinsights/data-2020-02-11-03-15-42.csv", CurrentModelFileKey = "Test-Website/Model", CheckpointKey = "Test-Website/Checkpoint", SagemakerStatus = Models.SagemakerStatus.Trained, SagemakerErrorStage = Models.SagemakerErrorStage.None, CurrentModelName = "Test-WebsiteModel-2020-02-11-03-21-38", TrainingJobName = "Test-Website-IPInsights-Training-2020-02-11-03-15-42", TrainingJobARN = "arn:aws:sagemaker:ap-southeast-1:188363912800:training-job/test-website-ipinsights-training-2020-02-11-03-15-42", EndpointConfigurationName = "Test-WebsiteEndpointConfig-2020-02-11-03-21-39", EndpointConfigurationARN = "arn:aws:sagemaker:ap-southeast-1:188363912800:endpoint-config/test-websiteendpointconfig-2020-02-11-03-21-39", InferenceBookmark = 13, TrainingBookmark = 13, LinkedLogInputID = _context.LogInputs.Find(1).ID }); await _context.SaveChangesAsync(); } _context.Database.CloseConnection(); }
public GetConnectionsResponse Post(GetConnectionsRequest req) { GetConnectionsResponse resp = new GetConnectionsResponse(); resp.EBSolutionConnections = new EbSolutionConnections(); if (req.ConnectionType == 0) { EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId)); resp.EBSolutionConnections = dummy; if (resp.EBSolutionConnections.DataDbConnection != null) { resp.EBSolutionConnections.DataDbConnection.Password = "******"; } if (resp.EBSolutionConnections.ObjectsDbConnection != null) { resp.EBSolutionConnections.ObjectsDbConnection.Password = "******"; } if (resp.EBSolutionConnections.SMTPConnection != null) { resp.EBSolutionConnections.SMTPConnection.Password = "******"; } } else if (req.ConnectionType == (int)EbConnectionTypes.SMTP) { EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId)); resp.EBSolutionConnections.SMTPConnection = new SMTPConnection(); resp.EBSolutionConnections.SMTPConnection = dummy.SMTPConnection; if (resp.EBSolutionConnections.SMTPConnection != null) { resp.EBSolutionConnections.SMTPConnection.Password = "******"; } } else if (req.ConnectionType == (int)EbConnectionTypes.EbDATA) { EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId)); resp.EBSolutionConnections.DataDbConnection = new EbDataDbConnection(); resp.EBSolutionConnections.DataDbConnection = dummy.DataDbConnection; if (resp.EBSolutionConnections.DataDbConnection != null) { resp.EBSolutionConnections.DataDbConnection.Password = "******"; } } else if (req.ConnectionType == (int)EbConnectionTypes.SMS) { EbSolutionConnections dummy = this.Redis.Get <EbSolutionConnections>(string.Format("EbSolutionConnections_{0}", req.TenantAccountId)); resp.EBSolutionConnections.SMSConnection = new SMSConnection(); resp.EBSolutionConnections.SMSConnection = dummy.SMSConnection; if (resp.EBSolutionConnections.DataDbConnection != null) { resp.EBSolutionConnections.SMSConnection.Password = "******"; } } return(resp); }
internal static void ValidateGetConnectionsResponse(GetConnectionsRequest aGetConnectionsRequest, GetConnectionsResponse aGetConnectionsResponse) { aGetConnectionsResponse.CorrelationId.Should().Be(aGetConnectionsRequest.CorrelationId); aGetConnectionsResponse.ConnectionRecords.Should().NotBeNull(); aGetConnectionsResponse.ConnectionRecords.Count.Should().Be(1); }