Finished the implementation of the "Connect through Web server feature".
This commit is contained in:
@@ -58,6 +58,8 @@ string authPolicyEditor = "/usr/share/java/CASA/authtoken/bin/CasaAuthPolicyEdit
|
||||
string iaRealmsFile = "/etc/CASA/authtoken/svc/iaRealms.xml";
|
||||
string iaRealmsEditor = "/usr/share/java/CASA/authtoken/bin/CasaIaRealmsEditor.sh";
|
||||
string trustedServerCertsFolder = "/etc/CASA/authtoken/keys/trustedATSCerts";
|
||||
string tomcatConnectorEditor = "/usr/share/java/CASA/authtoken/bin/CasaTomcatConnectorEditor.sh";
|
||||
string webServerIsAvailableChecker = "/usr/share/java/CASA/authtoken/bin/CasaIsWebServerAvailable.sh";
|
||||
|
||||
/**
|
||||
* Settings Map
|
||||
@@ -190,16 +192,13 @@ global boolean Read() {
|
||||
|
||||
// Set defaults
|
||||
Settings["CONFIG_CASAATS_ENABLE"] = false;
|
||||
Settings["CONFIG_CASAATS_DIRECT_ACCESS"] = true;
|
||||
Settings["CONFIG_CASAATS_DIRECT_ACCESS"] = true;;
|
||||
Settings["CONFIG_CASAATS_WEB_ACCESS"] = false;
|
||||
Settings["CONFIG_CASAATS_RECONFIG_INTERVAL"] = 60;
|
||||
|
||||
if (FileUtils::Exists("/etc/sysconfig/casa-ats")) {
|
||||
Settings["CONFIG_CASAATS_ENABLE"] = tolower((string)SCR::Read(.sysconfig.casa-ats.CONFIG_CASAATS_ENABLE)) == "yes";
|
||||
if ((Settings["CONFIG_CASAATS_ENABLE"]:false) == true) {
|
||||
Settings["CONFIG_CASAATS_DIRECT_ACCESS"] = tolower((string)SCR::Read(.sysconfig.casa-ats.CONFIG_CASAATS_DIRECT_ACCESS)) == "yes";
|
||||
Settings["CONFIG_CASAATS_WEB_ACCESS"] = tolower((string)SCR::Read(.sysconfig.casa-ats.CONFIG_CASAATS_WEB_ACCESS)) == "yes";
|
||||
|
||||
cmd = svcSettingsEditor + " -get ReconfigureInterval -file " + svcSettingsFile;
|
||||
ret = (map) SCR::Execute(.target.bash_output, cmd);
|
||||
integer exit = ret["exit"]:-1;
|
||||
@@ -377,6 +376,57 @@ global boolean Read() {
|
||||
|
||||
Settings["CONFIG_CASAATS_REALMS"] = realms;
|
||||
}
|
||||
|
||||
// Get the Tomcat SSL connector statuses
|
||||
cmd = tomcatConnectorEditor + " -s ssl";
|
||||
ret = (map) SCR::Execute(.target.bash_output, cmd);
|
||||
exit = ret["exit"]:-1;
|
||||
if (exit != 0)
|
||||
y2error("Failed to read ssl connector status");
|
||||
else {
|
||||
string cmd_output = ret["stdout"]:"";
|
||||
list<string> lines = splitstring(cmd_output, "\n");
|
||||
string statusLine = lines[2]:"";
|
||||
if (statusLine == "Connector enabled") {
|
||||
y2milestone("SSL connector enabled");
|
||||
Settings["CONFIG_CASAATS_DIRECT_ACCESS"] = true;
|
||||
}
|
||||
else {
|
||||
y2milestone("SSL connector disabled");
|
||||
Settings["CONFIG_CASAATS_DIRECT_ACCESS"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the Tomcat AJP connector statuses
|
||||
cmd = tomcatConnectorEditor + " -s ajp";
|
||||
ret = (map) SCR::Execute(.target.bash_output, cmd);
|
||||
exit = ret["exit"]:-1;
|
||||
if (exit != 0)
|
||||
y2error("Failed to read ajp connector status");
|
||||
else {
|
||||
string cmd_output = ret["stdout"]:"";
|
||||
list<string> lines = splitstring(cmd_output, "\n");
|
||||
string statusLine = lines[2]:"";
|
||||
if (statusLine == "Connector enabled") {
|
||||
y2milestone("AJP connector enabled");
|
||||
Settings["CONFIG_CASAATS_WEB_ACCESS"] = true;
|
||||
}
|
||||
else {
|
||||
y2milestone("AJP connector disabled");
|
||||
Settings["CONFIG_CASAATS_WEB_ACCESS"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the Web Server status
|
||||
integer status = (integer) SCR::Execute(.target.bash, webServerIsAvailableChecker);
|
||||
if (status == 1) {
|
||||
y2milestone("Web server available");
|
||||
Settings["WEB_SERVER_AVAILABLE"] = true;
|
||||
}
|
||||
else {
|
||||
y2milestone("Web server un-available");
|
||||
Settings["WEB_SERVER_AVAILABLE"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// read firewall settings
|
||||
@@ -523,8 +573,6 @@ global boolean Write() {
|
||||
if(Abort()) return false;
|
||||
Progress::NextStage();
|
||||
SCR::Write(.sysconfig.casa-ats.CONFIG_CASAATS_ENABLE, Settings["CONFIG_CASAATS_ENABLE"]:false ? "yes" : "no");
|
||||
SCR::Write(.sysconfig.casa-ats.CONFIG_CASAATS_DIRECT_ACCESS, Settings["CONFIG_CASAATS_DIRECT_ACCESS"]:true ? "yes" : "no");
|
||||
SCR::Write(.sysconfig.casa-ats.CONFIG_CASAATS_WEB_ACCESS, Settings["CONFIG_CASAATS_WEB_ACCESS"]:false ? "yes" : "no");
|
||||
if (false) Report::Error (_("Cannot sysconfig settings."));
|
||||
sleep(sl);
|
||||
|
||||
@@ -661,6 +709,36 @@ global boolean Write() {
|
||||
// Refresh the server Keystore
|
||||
SCR::Execute(.target.bash, "/usr/share/java/CASA/authtoken/bin/refresh_server_keystore.sh");
|
||||
|
||||
// Adjust the Tomcat connectors
|
||||
//
|
||||
// First disable them both and then re-enable as necessary
|
||||
cmd = tomcatConnectorEditor + " -d ssl";
|
||||
exit = (integer) SCR::Execute(.target.bash, cmd);
|
||||
if (exit != 0)
|
||||
y2error("Failed to disable the SSL connector");
|
||||
else {
|
||||
if ((Settings["CONFIG_CASAATS_DIRECT_ACCESS"]:false) == true) {
|
||||
cmd = tomcatConnectorEditor + " -e ssl";
|
||||
exit = (integer) SCR::Execute(.target.bash, cmd);
|
||||
if (exit != 0)
|
||||
y2error("Failed to enable the SSL connector");
|
||||
}
|
||||
}
|
||||
|
||||
cmd = tomcatConnectorEditor + " -d ajp";
|
||||
exit = (integer) SCR::Execute(.target.bash, cmd);
|
||||
if (exit != 0)
|
||||
y2error("Failed to disable the AJP connector");
|
||||
else {
|
||||
if (Settings["CONFIG_CASAATS_WEB_ACCESS"]:false == true)
|
||||
{
|
||||
cmd = tomcatConnectorEditor + " -e ajp";
|
||||
exit = (integer) SCR::Execute(.target.bash, cmd);
|
||||
if (exit != 0)
|
||||
y2error("Failed to enable the AJP connector");
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust firewall as needed
|
||||
if (Abort()) return false;
|
||||
Progress::NextStage();
|
||||
|
||||
@@ -738,8 +738,8 @@ zero means that the server only reads its configuration during start up.</p>
|
||||
integer items = 0;
|
||||
map<string, map> realms = (map<string, map>) CasaAts::Settings["CONFIG_CASAATS_REALMS"]:$[];
|
||||
list<term> table_items = [];
|
||||
boolean direct_access = CasaAts::Settings["CONFIG_CASAATS_DIRECT_ACCESS"]:true;
|
||||
boolean web_access = false;
|
||||
boolean direct_access = CasaAts::Settings["CONFIG_CASAATS_DIRECT_ACCESS"]:false;
|
||||
boolean web_access = CasaAts::Settings["CONFIG_CASAATS_WEB_ACCESS"]:false;
|
||||
integer reconfig_interval = CasaAts::Settings["CONFIG_CASAATS_RECONFIG_INTERVAL"]:60;
|
||||
|
||||
// Read list of search roots already configured for this realm
|
||||
@@ -752,29 +752,59 @@ zero means that the server only reads its configuration during start up.</p>
|
||||
});
|
||||
|
||||
/* Dialog contents */
|
||||
term contents = `HBox(
|
||||
`HSpacing(5),
|
||||
`VBox(
|
||||
`VStretch(),
|
||||
`Frame(_("Authentication Realms"),
|
||||
`VBox(
|
||||
`Table(`id(`table), `opt(`notify), `header(_("Realm")), []),
|
||||
`HBox(`PushButton(`id(`add), _("Ad&d")),
|
||||
`PushButton(`id(`edit), `opt(`disabled), _("&Edit")),
|
||||
`PushButton(`id(`delete), `opt(`disabled), _("De&lete"))
|
||||
term contents = nil;
|
||||
if (CasaAts::Settings["WEB_SERVER_AVAILABLE"]:false == true)
|
||||
{
|
||||
contents = `HBox(
|
||||
`HSpacing(5),
|
||||
`VBox(
|
||||
`VStretch(),
|
||||
`Frame(_("Authentication Realms"),
|
||||
`VBox(
|
||||
`Table(`id(`table), `opt(`notify), `header(_("Realm")), []),
|
||||
`HBox(`PushButton(`id(`add), _("Ad&d")),
|
||||
`PushButton(`id(`edit), `opt(`disabled), _("&Edit")),
|
||||
`PushButton(`id(`delete), `opt(`disabled), _("De&lete"))
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
`VSpacing(1),
|
||||
`Left(`CheckBox(`id(`direct), `opt(`notify), _("Direc&t Access"))),
|
||||
`VSpacing(1),
|
||||
`Left(`CheckBox(`id(`web), _("&Web Server Access"))),
|
||||
`VSpacing(1),
|
||||
`Left(`TextEntry(`id(`interval), _("Recon&figure Interval"))),
|
||||
`VStretch()
|
||||
),
|
||||
`VSpacing(1),
|
||||
`Left(`CheckBox(`id(`direct), `opt(`notify), _("Direc&t Access"))),
|
||||
`VSpacing(1),
|
||||
`Left(`CheckBox(`id(`web), _("&Web Server Access"))),
|
||||
`VSpacing(1),
|
||||
`Left(`TextEntry(`id(`interval), _("Recon&figure Interval"))),
|
||||
`VStretch()
|
||||
),
|
||||
`HSpacing(5)
|
||||
);
|
||||
`HSpacing(5)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
contents = `HBox(
|
||||
`HSpacing(5),
|
||||
`VBox(
|
||||
`VStretch(),
|
||||
`Frame(_("Authentication Realms"),
|
||||
`VBox(
|
||||
`Table(`id(`table), `opt(`notify), `header(_("Realm")), []),
|
||||
`HBox(`PushButton(`id(`add), _("Ad&d")),
|
||||
`PushButton(`id(`edit), `opt(`disabled), _("&Edit")),
|
||||
`PushButton(`id(`delete), `opt(`disabled), _("De&lete"))
|
||||
)
|
||||
)
|
||||
),
|
||||
`VSpacing(1),
|
||||
`Left(`CheckBox(`id(`direct), `opt(`notify), _("Direc&t Access"))),
|
||||
`VSpacing(1),
|
||||
`Left(`CheckBox(`id(`web), `opt(`disabled), _("&Web Server Access"))),
|
||||
`VSpacing(1),
|
||||
`Left(`TextEntry(`id(`interval), _("Recon&figure Interval"))),
|
||||
`VStretch()
|
||||
),
|
||||
`HSpacing(5)
|
||||
);
|
||||
}
|
||||
|
||||
boolean set_initial_focus = true;
|
||||
any ret = nil;
|
||||
@@ -897,12 +927,6 @@ zero means that the server only reads its configuration during start up.</p>
|
||||
reconfig_interval = CasaAts::Settings["CONFIG_CASAATS_RECONFIG_INTERVAL"]:60;
|
||||
continue;
|
||||
}
|
||||
/* Verify that web server access has not been selected */
|
||||
if (web_access == true) {
|
||||
Report::Error(_("Web server access is not yet supported."));
|
||||
web_access = false;
|
||||
continue;
|
||||
}
|
||||
/* Verify that the server can be accessed */
|
||||
if (direct_access != true && web_access != true) {
|
||||
Report::Error(_("Specify server access type."));
|
||||
@@ -917,6 +941,7 @@ zero means that the server only reads its configuration during start up.</p>
|
||||
// Save the server variables
|
||||
CasaAts::Settings["CONFIG_CASAATS_REALMS"] = realms;
|
||||
CasaAts::Settings["CONFIG_CASAATS_DIRECT_ACCESS"] = direct_access;
|
||||
CasaAts::Settings["CONFIG_CASAATS_WEB_ACCESS"] = web_access;
|
||||
CasaAts::Settings["CONFIG_CASAATS_RECONFIG_INTERVAL"] = reconfig_interval;
|
||||
CasaAts::Settings["CONFIG_CASAATS_REALMS"] = realms;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user