From 0c164e8c6f693cca5f90c0105e4ada33c5f89590 Mon Sep 17 00:00:00 2001 From: Lynn Shi Date: Tue, 8 Sep 2020 17:04:20 -0400 Subject: [PATCH] WIFI-626: Integration of Captive Portal Profile with AP (embedded portal, 1 SSID) --- .../src/main/resources/ProfileCaptive.json | 6 ++-- .../wlan/opensync/ovsdb/dao/OvsdbDao.java | 30 ++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/opensync-ext-static/src/main/resources/ProfileCaptive.json b/opensync-ext-static/src/main/resources/ProfileCaptive.json index 1367917..8e6e489 100644 --- a/opensync-ext-static/src/main/resources/ProfileCaptive.json +++ b/opensync-ext-static/src/main/resources/ProfileCaptive.json @@ -12,7 +12,7 @@ "headerContent": "Captive Portal", "userAcceptancePolicy": "Use this network at your own risk. No warranty of any kind.", "successPageMarkdownText": "Welcome to the network", - "redirectURL": "", + "redirectURL": "www.google.com", "externalCaptivePortalURL": null, "sessionTimeoutInMinutes": 60, "logoFile": { @@ -35,8 +35,8 @@ }, "walledGardenAllowlist": [ "1.2.3.4", - "1.2.3.4-2.3.4.5", - "connectus.ai" + "1.2.3.6-2.3.4.5", + "netexperience.com" ], "usernamePasswordFile": null, "authenticationType": "guest", diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java index e409288..e6cca81 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java @@ -53,6 +53,7 @@ import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiStatsConfigInf import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiVifConfigInfo; import com.telecominfraproject.wlan.profile.bonjour.models.BonjourGatewayProfile; import com.telecominfraproject.wlan.profile.bonjour.models.BonjourServiceSet; +import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalAuthenticationType; import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalConfiguration; import com.telecominfraproject.wlan.profile.captiveportal.models.ManagedFileInfo; import com.telecominfraproject.wlan.profile.models.Profile; @@ -2342,15 +2343,21 @@ public class OvsdbDao { DatabaseSchema dbSchema = ovsdbClient.getSchema(ovsdbName).join(); TableSchema tableSchema = dbSchema.getTables().get(wifiVifConfigDbTable); if (tableSchema.getColumns().containsKey("captive_portal")) { - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") com.vmware.ovsdb.protocol.operation.notation.Map captivePortalMap = com.vmware.ovsdb.protocol.operation.notation.Map .of(captiveMap); updateColumns.put("captive_portal", captivePortalMap); } if (tableSchema.getColumns().containsKey("captive_allowlist")) { - com.vmware.ovsdb.protocol.operation.notation.Set captiveAllowList = com.vmware.ovsdb.protocol.operation.notation.Set - .of(walledGardenAllowlist); - updateColumns.put("captive_allowlist", captiveAllowList); + if (walledGardenAllowlist != null && !walledGardenAllowlist.isEmpty()) { + Set> atomMacList = new HashSet<>(); + walledGardenAllowlist.stream().forEach(allow -> atomMacList.add(new Atom<>(allow))); + com.vmware.ovsdb.protocol.operation.notation.Set allowListSet = com.vmware.ovsdb.protocol.operation.notation.Set + .of(atomMacList); + updateColumns.put("captive_allowlist", allowListSet); + } else { + updateColumns.put("captive_allowlist", new com.vmware.ovsdb.protocol.operation.notation.Set()); + } } // TODO: when AP support for Bonjour Gateway set values @@ -2927,6 +2934,7 @@ public class OvsdbDao { captiveMap.put("acceptance_policy", captiveProfileDetails.getUserAcceptancePolicy()); captiveMap.put("login_success_text", captiveProfileDetails.getSuccessPageMarkdownText()); + captiveMap.put("authentication", getCaptiveAuthentication(captiveProfileDetails.getAuthenticationType())); // captiveMap.put("externalCaptivePortalURL", // captiveProfileDetails.getExternalCaptivePortalURL()); // captiveMap.put("backgroundPosition", @@ -2945,6 +2953,20 @@ public class OvsdbDao { } } } + + private String getCaptiveAuthentication(CaptivePortalAuthenticationType authentication) { + switch (authentication) { + case guest: + return "None"; + case username: + return "Captive Portal User List"; + case radius: + return "RADIUS"; + default: + LOG.error("Unsupported captive portal authentication {}", authentication); + return "None"; + } + } private void getBonjourGatewayConfiguration(OpensyncAPConfig opensyncApConfig, SsidConfiguration ssidConfig, Map> bonjourServiceMap) {