mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-03 12:08:07 +00:00
Add captivePortal sample file
This commit is contained in:
58
opensync-ext-static/src/main/resources/ProfileCaptive.json
Normal file
58
opensync-ext-static/src/main/resources/ProfileCaptive.json
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"model_type": "Profile",
|
||||||
|
"id": 2,
|
||||||
|
"customerId": 2,
|
||||||
|
"profileType": "captive_portal",
|
||||||
|
"name": "Captive-portal",
|
||||||
|
"details": {
|
||||||
|
"model_type": "CaptivePortalConfiguration",
|
||||||
|
"name": "Captive-portal",
|
||||||
|
"browserTitle": "Access the network as Guest",
|
||||||
|
"headerContent": "Captive Portal",
|
||||||
|
"userAcceptancePolicy": "Use this network at your own risk. No warranty of any kind.",
|
||||||
|
"successPageMarkdownText": "Welcome to the network",
|
||||||
|
"redirectURL": "",
|
||||||
|
"externalCaptivePortalURL": null,
|
||||||
|
"sessionTimeoutInMinutes": 60,
|
||||||
|
"logoFile": {
|
||||||
|
"model_type": "ManagedFileInfo",
|
||||||
|
"md5checksum": null,
|
||||||
|
"lastModifiedTimestamp": null,
|
||||||
|
"apExportUrl": "netExpLogo.png",
|
||||||
|
"fileCategory": "CaptivePortalLogo",
|
||||||
|
"fileType": "PNG",
|
||||||
|
"altSlot": false
|
||||||
|
},
|
||||||
|
"backgroundFile": {
|
||||||
|
"model_type": "ManagedFileInfo",
|
||||||
|
"md5checksum": null,
|
||||||
|
"lastModifiedTimestamp": null,
|
||||||
|
"apExportUrl": "netExpBackgroud.jpg",
|
||||||
|
"fileCategory": "CaptivePortalBackground",
|
||||||
|
"fileType": "JPG",
|
||||||
|
"altSlot": false
|
||||||
|
},
|
||||||
|
"walledGardenAllowlist": [
|
||||||
|
"1.2.3.4",
|
||||||
|
"1.2.3.4-2.3.4.5",
|
||||||
|
"connectus.ai"
|
||||||
|
],
|
||||||
|
"usernamePasswordFile": null,
|
||||||
|
"authenticationType": "guest",
|
||||||
|
"radiusAuthMethod": "CHAP",
|
||||||
|
"maxUsersWithSameCredentials": 42,
|
||||||
|
"externalPolicyFile": null,
|
||||||
|
"backgroundPosition": "left_top",
|
||||||
|
"backgroundRepeat": "no_repeat",
|
||||||
|
"radiusServiceName": null,
|
||||||
|
"expiryType": "unlimited",
|
||||||
|
"userList": [],
|
||||||
|
"macAllowList": [],
|
||||||
|
"profileType": "captive_portal"
|
||||||
|
},
|
||||||
|
"createdTimestamp": 1595341820188,
|
||||||
|
"lastModifiedTimestamp": 1595341820188,
|
||||||
|
"childProfileIds": []
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -133,6 +133,9 @@ tip.wlan.firmwareServiceBaseUrl=https://localhost:9092
|
|||||||
tip.wlan.manufacturerServiceBaseUrl=https://localhost:9092
|
tip.wlan.manufacturerServiceBaseUrl=https://localhost:9092
|
||||||
tip.wlan.portalUserServiceBaseUrl=https://localhost:9092
|
tip.wlan.portalUserServiceBaseUrl=https://localhost:9092
|
||||||
|
|
||||||
|
tip.wlan.fileStoreDirectory=/tmp/tip-wlan-filestore
|
||||||
|
tip.wlan.externalFileStoreURL=https://localhost:9096
|
||||||
|
|
||||||
#server.session-timeout= # session timeout in seconds
|
#server.session-timeout= # session timeout in seconds
|
||||||
#server.tomcat.max-threads = 0 # number of threads in protocol handler
|
#server.tomcat.max-threads = 0 # number of threads in protocol handler
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiInetConfigInfo
|
|||||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiRadioConfigInfo;
|
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiRadioConfigInfo;
|
||||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiStatsConfigInfo;
|
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiStatsConfigInfo;
|
||||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiVifConfigInfo;
|
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiVifConfigInfo;
|
||||||
|
import com.telecominfraproject.wlan.profile.captiveportal.models.CaptivePortalConfiguration;
|
||||||
|
import com.telecominfraproject.wlan.profile.captiveportal.models.ManagedFileInfo;
|
||||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||||
import com.telecominfraproject.wlan.profile.radius.models.RadiusProfile;
|
import com.telecominfraproject.wlan.profile.radius.models.RadiusProfile;
|
||||||
import com.telecominfraproject.wlan.profile.radius.models.RadiusServer;
|
import com.telecominfraproject.wlan.profile.radius.models.RadiusServer;
|
||||||
@@ -130,6 +132,12 @@ public class OvsdbDao {
|
|||||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.ovsdb.awlan-node.upgrade_timer:90}")
|
@org.springframework.beans.factory.annotation.Value("${tip.wlan.ovsdb.awlan-node.upgrade_timer:90}")
|
||||||
public long upgradeTimerSeconds;
|
public long upgradeTimerSeconds;
|
||||||
|
|
||||||
|
@org.springframework.beans.factory.annotation.Value("${tip.wlan.fileStoreDirectory:/tmp/tip-wlan-filestore}")
|
||||||
|
private String fileStoreDirectory;
|
||||||
|
@org.springframework.beans.factory.annotation.Value("${tip.wlan.externalFileStoreURL:https://localhost:9096}")
|
||||||
|
private String externalFileStoreURL;
|
||||||
|
public static final String HTTP = "http";
|
||||||
|
|
||||||
public static final String ovsdbName = "Open_vSwitch";
|
public static final String ovsdbName = "Open_vSwitch";
|
||||||
public static final String awlanNodeDbTable = "AWLAN_Node";
|
public static final String awlanNodeDbTable = "AWLAN_Node";
|
||||||
public static final String wifiStatsConfigDbTable = "Wifi_Stats_Config";
|
public static final String wifiStatsConfigDbTable = "Wifi_Stats_Config";
|
||||||
@@ -2577,6 +2585,11 @@ public class OvsdbDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO put into AP captive parameter
|
||||||
|
Map<String, String> captiveMap = new HashMap<>();
|
||||||
|
List<String> walledGardenAllowlist = new ArrayList<>();
|
||||||
|
getCaptiveConfiguration(opensyncApConfig, ssidConfig, captiveMap, walledGardenAllowlist);
|
||||||
|
|
||||||
boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled);
|
boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled);
|
||||||
|
|
||||||
int numberOfInterfaces = 0;
|
int numberOfInterfaces = 0;
|
||||||
@@ -2639,6 +2652,50 @@ public class OvsdbDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getCaptiveConfiguration(OpensyncAPConfig opensyncApConfig, SsidConfiguration ssidConfig,
|
||||||
|
Map<String, String> captiveMap, List<String> walledGardenAllowlist) {
|
||||||
|
if (ssidConfig.getCaptivePortalId() != null && opensyncApConfig.getCaptiveProfiles() != null) {
|
||||||
|
for (Profile profileCaptive : opensyncApConfig.getCaptiveProfiles()) {
|
||||||
|
if (ssidConfig.getCaptivePortalId() == profileCaptive.getId() &&
|
||||||
|
profileCaptive.getDetails() != null) {
|
||||||
|
CaptivePortalConfiguration captiveProfileDetails = ((CaptivePortalConfiguration) profileCaptive.getDetails());
|
||||||
|
captiveMap.put("sessionTimeoutInMinutes", String.valueOf(captiveProfileDetails.getSessionTimeoutInMinutes()));
|
||||||
|
captiveMap.put("redirectURL", captiveProfileDetails.getRedirectURL());
|
||||||
|
captiveMap.put("browserTitle", captiveProfileDetails.getBrowserTitle());
|
||||||
|
captiveMap.put("headerContent", captiveProfileDetails.getHeaderContent());
|
||||||
|
captiveMap.put("userAcceptancePolicy", captiveProfileDetails.getUserAcceptancePolicy());
|
||||||
|
captiveMap.put("successPageMarkdownText", captiveProfileDetails.getSuccessPageMarkdownText());
|
||||||
|
captiveMap.put("externalCaptivePortalURL", captiveProfileDetails.getExternalCaptivePortalURL());
|
||||||
|
captiveMap.put("backgroundPosition", captiveProfileDetails.getBackgroundPosition().toString());
|
||||||
|
captiveMap.put("backgroundRepeat", captiveProfileDetails.getBackgroundRepeat().toString());
|
||||||
|
walledGardenAllowlist.addAll(captiveProfileDetails.getWalledGardenAllowlist());
|
||||||
|
|
||||||
|
captiveMap.put("logoFileURL", getCaptiveFileUrl("logoFileURL", captiveProfileDetails.getLogoFile()));
|
||||||
|
captiveMap.put("backgroundFileURL", getCaptiveFileUrl("backgroundFileURL", captiveProfileDetails.getBackgroundFile()));
|
||||||
|
|
||||||
|
LOG.debug("captiveMap {}", captiveMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCaptiveFileUrl(String fileDesc, ManagedFileInfo fileInfo) {
|
||||||
|
if (fileInfo == null || fileInfo.getApExportUrl() == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (fileInfo.getApExportUrl().startsWith(HTTP)) {
|
||||||
|
return fileInfo.getApExportUrl();
|
||||||
|
}
|
||||||
|
if (externalFileStoreURL == null || fileStoreDirectory == null) {
|
||||||
|
LOG.error("Missing externalFileStoreURL or fileStoreDirectory)");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
LOG.debug("Captive file {}: {}", fileDesc, externalFileStoreURL + fileStoreDirectory + "/" +
|
||||||
|
fileInfo.getApExportUrl());
|
||||||
|
|
||||||
|
return externalFileStoreURL + fileStoreDirectory + "/" + fileInfo.getApExportUrl();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateWifiInetConfig(OvsdbClient ovsdbClient, int vlanId, String ifName, boolean enabled,
|
private void updateWifiInetConfig(OvsdbClient ovsdbClient, int vlanId, String ifName, boolean enabled,
|
||||||
boolean isNAT, String ifType, String gateway, String inet, Map<String, String> dns, String ipAssignScheme,
|
boolean isNAT, String ifType, String gateway, String inet, Map<String, String> dns, String ipAssignScheme,
|
||||||
Uuid vifConfigUuid) {
|
Uuid vifConfigUuid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user