public override async Task <AlertListReply> ListAlerts(Empty request, ServerCallContext context) { AppUser user = await _userManager.GetUserAsync(context.GetHttpContext().User); List <IAlert> alerts = await _alertManager.GetUserAlertsAsync(user); AlertListReply alertListReply = new AlertListReply { }; foreach (IAlert alert in alerts) { System.Type alertType = alert.GetType(); if (alertType == typeof(BruteforceUserAlert)) { BruteforceUserAlert castedAlert = (BruteforceUserAlert)alert; alertListReply.Alerts.Add( new Alert { BruteforceUserAlert = new Alert.Types.BruteforceUserAlert(), Level = Shared.ClientAndWeb.Security.Alert.Types.LevelEnum.Low, Id = alert.Id.ToString(), } ); } } return(alertListReply); }
public override async Task <AlertListReply> ListAlerts(Empty request, ServerCallContext context) { List <IAlert> alerts = await _alertManager.GetSystemAlertsAsync(); AlertListReply reply = new AlertListReply { }; foreach (IAlert alert in alerts) { System.Type alertType = alert.GetType(); Alert replyAlert = new Alert { Id = alert.Id.ToString(), Level = AlertProtobufConverter.ConvertEnum(alert.AlertLevel), IsActionable = alert.IsActionable, }; if (alertType == typeof(LdapUnencryptedConnectionAlert)) { var castedAlert = (LdapUnencryptedConnectionAlert)alert; replyAlert.LdapConnectionAlert = new Alert.Types.UnencryptedLdapConnectionAlert { AppName = castedAlert.LdapAppSettingsId.ToString(), IpAddress = (castedAlert.IpAddress.IsIPv4MappedToIPv6) ? castedAlert.IpAddress.MapToIPv4().ToString() : castedAlert.IpAddress.ToString(), }; } else if (alertType == typeof(BruteforceIpAddressAlert)) { var castedAlert = (BruteforceIpAddressAlert)alert; replyAlert.BruteforceIpAddressAlert = new Alert.Types.BruteforceIpAddressAlert { IpAddress = (castedAlert.IpAddress.IsIPv4MappedToIPv6) ? castedAlert.IpAddress.MapToIPv4().ToString() : castedAlert.IpAddress.ToString(), }; } reply.Alerts.Add(replyAlert); } return(reply); }