mirror of
				https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
				synced 2025-10-30 18:17:59 +00:00 
			
		
		
		
	WIFI-1698: Services - RadSEC certificates
WIFI-1717: Gateway: Handle table state changes for APC_State
This commit is contained in:
		| @@ -103,6 +103,9 @@ import com.telecominfraproject.wlan.status.models.Status; | ||||
| import com.telecominfraproject.wlan.status.models.StatusCode; | ||||
| import com.telecominfraproject.wlan.status.models.StatusDataType; | ||||
| import com.telecominfraproject.wlan.status.network.models.NetworkAdminStatusData; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.ApcElectionEvent; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.RealTimeEventType; | ||||
| import com.telecominfraproject.wlan.systemevent.equipment.realtime.ApcElectionEvent.ApcMode; | ||||
|  | ||||
| import sts.OpensyncStats.Report; | ||||
| import traffic.NetworkMetadata.FlowReport; | ||||
| @@ -2393,7 +2396,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|     public void apcStateDbTableUpdate(Map<String, String> apcStateAttributes, String apId, | ||||
|             RowUpdateOperation rowUpdateOperation) { | ||||
|  | ||||
|         LOG.info("apcStateDbTableUpdate {} operations on AP {} with values {} ", rowUpdateOperation, apId, apcStateAttributes); | ||||
|         LOG.info("apcStateDbTableUpdate {} operations on AP {} with values {} ", rowUpdateOperation, apId, | ||||
|                 apcStateAttributes); | ||||
|  | ||||
|         OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId); | ||||
|  | ||||
| @@ -2418,7 +2422,27 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         ApcElectionEvent electionEvent = new ApcElectionEvent(RealTimeEventType.APC_Election_event, customerId, | ||||
|                 customerId, equipmentId, System.currentTimeMillis()); | ||||
|  | ||||
|         if (rowUpdateOperation.equals(RowUpdateOperation.DELETE)) { | ||||
|             try { | ||||
|                 electionEvent.setApcBackupDesignatedRouterIpAddress( | ||||
|                         InetAddress.getByName(apcStateAttributes.get("backupDesignatedRouterIp"))); | ||||
|             } catch (UnknownHostException e) { | ||||
|                 LOG.error("UnknownHost for backupDesignatedRouterIp", e); | ||||
|             } | ||||
|             try { | ||||
|                 electionEvent.setApcDesignatedRouterIpAddress( | ||||
|                         InetAddress.getByName(apcStateAttributes.get("designatedRouterIp"))); | ||||
|             } catch (UnknownHostException e) { | ||||
|                 LOG.error("UnknownHost for designatedRouterIp", e); | ||||
|             } | ||||
|             electionEvent.setApcMode(ApcMode.valueOf(apcStateAttributes.get("mode"))); | ||||
|             electionEvent.setEnabled(Boolean.valueOf(apcStateAttributes.get("enabled"))); | ||||
|             electionEvent.setLocationId(ce.getLocationId()); | ||||
|  | ||||
|             electionEvent.setRadiusProxyAddress(null); | ||||
|             Status protocolStatus; | ||||
|             EquipmentProtocolStatusData protocolStatusData; | ||||
|             protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL); | ||||
| @@ -2428,10 +2452,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|                 protocolStatusData.setIsApcConnected(false); | ||||
|                 protocolStatusData.setReportedApcAddress(null); | ||||
|                 protocolStatusData.setRadiusProxyAddress(null); | ||||
|  | ||||
|                 protocolStatus.setDetails(protocolStatusData); | ||||
|                 protocolStatus = statusServiceInterface.update(protocolStatus); | ||||
|  | ||||
|                 electionEvent.setLocalIpAddress(protocolStatusData.getReportedIpV4Addr()); | ||||
|                 LOG.info("apcStateDbTableUpdate for {} protocolStatus {}", rowUpdateOperation, protocolStatus); | ||||
|             } | ||||
|         } else { | ||||
| @@ -2442,34 +2466,43 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra | ||||
|                 if (protocolStatus != null) { | ||||
|                     protocolStatusData = (EquipmentProtocolStatusData) protocolStatus.getDetails(); | ||||
|                     protocolStatusData.setLastApcUpdate(System.currentTimeMillis()); | ||||
|                      | ||||
|                     if (apcStateAttributes.containsKey("mode")) { | ||||
|                         String mode = apcStateAttributes.get("mode"); | ||||
|                         if (mode.equals("DR")) { | ||||
|                             String drAddr = apcStateAttributes.get("designatedRouterIp"); | ||||
|                             protocolStatusData.setReportedApcAddress(InetAddress.getByName(drAddr)); | ||||
|                             protocolStatusData.setRadiusProxyAddress(InetAddress.getByName(drAddr)); | ||||
|                             protocolStatusData | ||||
|                                     .setIsApcConnected((drAddr == null || drAddr.equals("0.0.0.0")) ? false : true); | ||||
|                         } else if (mode.equals("BDR")) { | ||||
|                             String bdrAddr = apcStateAttributes.get("backupDesignatedRouterIp"); | ||||
|                             protocolStatusData.setReportedApcAddress(InetAddress.getByName(bdrAddr)); | ||||
|                             protocolStatusData.setRadiusProxyAddress(InetAddress.getByName(bdrAddr)); | ||||
|                             protocolStatusData | ||||
|                                     .setIsApcConnected((bdrAddr == null || bdrAddr.equals("0.0.0.0")) ? false : true); | ||||
|                         } else if (mode.equals("SR")) { | ||||
|                             // TODO: do we set for this scenario? | ||||
|                         } else if (mode.equals("NC")) { | ||||
|                             protocolStatusData.setIsApcConnected(false); | ||||
|                         } | ||||
|                     String mode = apcStateAttributes.get("mode"); | ||||
|                     String drAddr = apcStateAttributes.get("designatedRouterIp"); | ||||
|                     String bdrAddr = apcStateAttributes.get("backupDesignatedRouterIp"); | ||||
|                     if (mode.equals("DR")) { | ||||
|                         protocolStatusData.setReportedApcAddress(InetAddress.getByName(drAddr)); | ||||
|                         protocolStatusData.setRadiusProxyAddress(InetAddress.getByName(drAddr)); | ||||
|                         protocolStatusData | ||||
|                         .setIsApcConnected((drAddr == null || drAddr.equals("0.0.0.0")) ? false : true); | ||||
|                     } else if (mode.equals("BDR")) { | ||||
|                         protocolStatusData.setReportedApcAddress(InetAddress.getByName(bdrAddr)); | ||||
|                         protocolStatusData.setRadiusProxyAddress(InetAddress.getByName(bdrAddr)); | ||||
|                         protocolStatusData | ||||
|                         .setIsApcConnected((bdrAddr == null || bdrAddr.equals("0.0.0.0")) ? false : true); | ||||
|                     } else if (mode.equals("SR")) { | ||||
|                         // TODO: do we set for this scenario? | ||||
|                     } else if (mode.equals("NC")) { | ||||
|                         protocolStatusData.setIsApcConnected(false); | ||||
|                     } | ||||
|                     protocolStatus.setDetails(protocolStatusData); | ||||
|                     protocolStatus = statusServiceInterface.update(protocolStatus); | ||||
|  | ||||
|                     electionEvent.setApcDesignatedRouterIpAddress( | ||||
|                             InetAddress.getByName(drAddr));                        | ||||
|                     electionEvent.setApcBackupDesignatedRouterIpAddress( | ||||
|                             InetAddress.getByName(bdrAddr)); | ||||
|                     electionEvent.setLocalIpAddress(protocolStatusData.getReportedIpV4Addr()); | ||||
|                     electionEvent.setApcMode(ApcMode.valueOf(apcStateAttributes.get("mode"))); | ||||
|                     electionEvent.setEnabled(Boolean.valueOf(apcStateAttributes.get("enabled"))); | ||||
|                     electionEvent.setLocationId(ce.getLocationId()); | ||||
|                     LOG.info("apcStateDbTableUpdate for {} protocolStatus {}", rowUpdateOperation, protocolStatus); | ||||
|                 } | ||||
|             } catch (UnknownHostException e) { | ||||
|                 LOG.error("Unknown host for radius proxy.", e); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         mqttMessageProcessor.publishSystemEventFromTableStateMonitor(electionEvent); | ||||
|          | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -72,6 +72,7 @@ import com.telecominfraproject.wlan.status.models.Status; | ||||
| import com.telecominfraproject.wlan.status.models.StatusCode; | ||||
| import com.telecominfraproject.wlan.status.models.StatusDataType; | ||||
| import com.telecominfraproject.wlan.status.network.models.NetworkAdminStatusData; | ||||
| import com.telecominfraproject.wlan.systemevent.models.SystemEvent; | ||||
|  | ||||
| import sts.OpensyncStats; | ||||
| import sts.OpensyncStats.AssocType; | ||||
| @@ -269,6 +270,10 @@ public class MqttStatsPublisher { | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public void publishSystemEventFromTableStateMonitor(SystemEvent event) { | ||||
|         cloudEventDispatcherInterface.publishEvent(event); | ||||
|     } | ||||
|      | ||||
|     void publishEvents(Report report, int customerId, long equipmentId, String apId, long locationId) { | ||||
|  | ||||
|         realtimeEventPublisher.publishSipCallEvents(customerId, equipmentId, locationId, report.getVideoVoiceReportList()); | ||||
|   | ||||
| @@ -69,14 +69,13 @@ public class OvsdbRadSecConfig extends OvsdbDaoBase { | ||||
|  | ||||
|     private void configureRadiusServers(OvsdbClient ovsdbClient, OpensyncAPConfig apConfig, List<Operation> operations) | ||||
|             throws OvsdbClientException, InterruptedException, ExecutionException, TimeoutException { | ||||
|  | ||||
|         for (RadSecConfiguration rsc : ((ApNetworkConfiguration) apConfig.getApProfile().getDetails()) | ||||
|                 .getRadSecConfigurations()) { | ||||
|             Map<String, Value> updateColumns = new HashMap<>(); | ||||
|             updateColumns.put("server", new Atom<>(rsc.getServer().getHostAddress())); | ||||
|             updateColumns.put("client_cert", new Atom<>(externalFileStoreURL + rsc.getClientCert().getApExportUrl())); | ||||
|             getCertificateUrls(rsc, updateColumns); | ||||
|             updateColumns.put("radius_config_name", new Atom<>(rsc.getName())); | ||||
|             updateColumns.put("client_key", new Atom<>(externalFileStoreURL + rsc.getClientKey().getApExportUrl())); | ||||
|             updateColumns.put("ca_cert", new Atom<>(externalFileStoreURL + rsc.getCaCert().getApExportUrl())); | ||||
|             updateColumns.put("passphrase", new Atom<>(rsc.getPassphrase())); | ||||
|             Row row = new Row(updateColumns); | ||||
|             operations.add(new Insert(radiusConfigDbTable, row)); | ||||
| @@ -92,6 +91,24 @@ public class OvsdbRadSecConfig extends OvsdbDaoBase { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void getCertificateUrls(RadSecConfiguration rsc, Map<String, Value> updateColumns) { | ||||
|         String clientCertFilestoreUrl = externalFileStoreURL + rsc.getClientCert().getApExportUrl(); | ||||
|         String clientKeyFilestoreUrl = externalFileStoreURL + rsc.getClientKey().getApExportUrl(); | ||||
|         String caCertFilestoreUrl = externalFileStoreURL + rsc.getCaCert().getApExportUrl(); | ||||
|         if (!clientCertFilestoreUrl.contains("filestore")) { | ||||
|             clientCertFilestoreUrl = externalFileStoreURL + "/filestore/" + rsc.getClientCert().getApExportUrl(); | ||||
|         } | ||||
|         if (!clientKeyFilestoreUrl.contains("filestore")) { | ||||
|             clientKeyFilestoreUrl = externalFileStoreURL + "/filestore/" + rsc.getClientKey().getApExportUrl(); | ||||
|         } | ||||
|         if (!caCertFilestoreUrl.contains("filestore")) { | ||||
|             caCertFilestoreUrl = externalFileStoreURL + "/filestore/" + rsc.getCaCert().getApExportUrl(); | ||||
|         }            | ||||
|         updateColumns.put("client_cert", new Atom<>(clientCertFilestoreUrl)); | ||||
|         updateColumns.put("client_key", new Atom<>(clientKeyFilestoreUrl)); | ||||
|         updateColumns.put("ca_cert", new Atom<>(caCertFilestoreUrl)); | ||||
|     } | ||||
|  | ||||
|     private void configureRealmForRadiusServers(OvsdbClient ovsdbClient, OpensyncAPConfig apConfig) | ||||
|             throws OvsdbClientException, InterruptedException, ExecutionException, TimeoutException { | ||||
|         List<Operation> operations; | ||||
|   | ||||
| @@ -699,8 +699,21 @@ public class OvsdbSsidConfig extends OvsdbDaoBase { | ||||
|                     captiveMap.put("login_success_text", captiveProfileDetails.getSuccessPageMarkdownText()); | ||||
|                     captiveMap.put("authentication", | ||||
|                             getCaptiveAuthentication(captiveProfileDetails.getAuthenticationType())); | ||||
|                     if (!externalFileStoreURL.endsWith("/filestore/")) { | ||||
|                         externalFileStoreURL = externalFileStoreURL + "/filestore/"; | ||||
|                     if (captiveProfileDetails.getLogoFile() != null) { | ||||
|                         String splashLogoUrl = externalFileStoreURL + captiveProfileDetails.getLogoFile().getApExportUrl(); | ||||
|                         if (!splashLogoUrl.contains("filestore")) { | ||||
|                             splashLogoUrl = externalFileStoreURL + "/filestore/" + captiveProfileDetails.getLogoFile().getApExportUrl(); | ||||
|                         } | ||||
|                         captiveMap.put("splash_page_logo", | ||||
|                                 splashLogoUrl); | ||||
|                     } | ||||
|                     if (captiveProfileDetails.getBackgroundFile() != null) { | ||||
|                         String splashBackgroundUrl = externalFileStoreURL + captiveProfileDetails.getBackgroundFile().getApExportUrl(); | ||||
|                         if (!splashBackgroundUrl.contains("filestore")) { | ||||
|                             splashBackgroundUrl = externalFileStoreURL + "/filestore/" + captiveProfileDetails.getBackgroundFile().getApExportUrl(); | ||||
|                         } | ||||
|                         captiveMap.put("splash_page_background_logo", | ||||
|                                 splashBackgroundUrl); | ||||
|                     } | ||||
|                     if (captiveProfileDetails.getAuthenticationType() | ||||
|                             .equals(CaptivePortalAuthenticationType.username)) { | ||||
| @@ -711,16 +724,13 @@ public class OvsdbSsidConfig extends OvsdbDaoBase { | ||||
|                         mfi.setFileCategory(FileCategory.UsernamePasswordList); | ||||
|                         mfi.setFileType(FileType.TEXT); | ||||
|                         mfi.setApExportUrl(userFilepath.getFileName().toString()); | ||||
|                         captiveMap.put("username_password_file", externalFileStoreURL + mfi.getApExportUrl()); | ||||
|                     } | ||||
|                     if (captiveProfileDetails.getLogoFile() != null) { | ||||
|                         captiveMap.put("splash_page_logo", | ||||
|                                 externalFileStoreURL + captiveProfileDetails.getLogoFile().getApExportUrl()); | ||||
|                     } | ||||
|                     if (captiveProfileDetails.getBackgroundFile() != null) { | ||||
|                         captiveMap.put("splash_page_background_logo", | ||||
|                                 externalFileStoreURL + captiveProfileDetails.getBackgroundFile().getApExportUrl()); | ||||
|                         String usernamePasswordFileUrl = externalFileStoreURL + mfi.getApExportUrl(); | ||||
|                         if (!usernamePasswordFileUrl.contains("filestore")) { | ||||
|                             usernamePasswordFileUrl = externalFileStoreURL + "/filestore/" + mfi.getApExportUrl(); | ||||
|                         } | ||||
|                         captiveMap.put("username_password_file", usernamePasswordFileUrl); | ||||
|                     } | ||||
|  | ||||
|                     LOG.debug("captiveMap {}", captiveMap); | ||||
|                     walledGardenAllowlist.addAll(captiveProfileDetails.getWalledGardenAllowlist()); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mike Hansen
					Mike Hansen