diff --git a/src/main/java/org/opensearch/security/tools/democonfig/CertificateGenerator.java b/src/main/java/org/opensearch/security/tools/democonfig/CertificateGenerator.java index 6ad41fefcc..a08ead5483 100644 --- a/src/main/java/org/opensearch/security/tools/democonfig/CertificateGenerator.java +++ b/src/main/java/org/opensearch/security/tools/democonfig/CertificateGenerator.java @@ -19,13 +19,13 @@ /** * This class creates demo certificate files */ -public class CertificateGenerator extends InstallDemoConfiguration { +public class CertificateGenerator extends Installer { /** * Creates demo super-admin, node and root certificates */ public void createDemoCertificates() { - for (DemoCertificate cert : DemoCertificate.values()) { + for (Certificates cert : Certificates.values()) { String filePath = OPENSEARCH_CONF_DIR + File.separator + cert.getFileName(); writeCertificateToFile(filePath, cert.getContent()); } diff --git a/src/main/java/org/opensearch/security/tools/democonfig/DemoCertificate.java b/src/main/java/org/opensearch/security/tools/democonfig/Certificates.java similarity index 99% rename from src/main/java/org/opensearch/security/tools/democonfig/DemoCertificate.java rename to src/main/java/org/opensearch/security/tools/democonfig/Certificates.java index 53fe0e8525..6821147e8c 100644 --- a/src/main/java/org/opensearch/security/tools/democonfig/DemoCertificate.java +++ b/src/main/java/org/opensearch/security/tools/democonfig/Certificates.java @@ -3,7 +3,7 @@ /** * Enum for demo certificates */ -public enum DemoCertificate { +public enum Certificates { ADMIN_CERT( "kirk.pem", "-----BEGIN CERTIFICATE-----\n" @@ -159,7 +159,7 @@ public enum DemoCertificate { private final String fileName; private final String content; - DemoCertificate(String fileName, String content) { + Certificates(String fileName, String content) { this.fileName = fileName; this.content = content; } diff --git a/src/main/java/org/opensearch/security/tools/democonfig/InstallDemoConfiguration.java b/src/main/java/org/opensearch/security/tools/democonfig/Installer.java similarity index 97% rename from src/main/java/org/opensearch/security/tools/democonfig/InstallDemoConfiguration.java rename to src/main/java/org/opensearch/security/tools/democonfig/Installer.java index 24eea3a647..4c7c79a1e5 100644 --- a/src/main/java/org/opensearch/security/tools/democonfig/InstallDemoConfiguration.java +++ b/src/main/java/org/opensearch/security/tools/democonfig/Installer.java @@ -26,7 +26,7 @@ /** * This class installs demo configuration for security plugin */ -public class InstallDemoConfiguration { +public class Installer { static boolean assumeyes = false; static boolean initsecurity = false; @@ -55,11 +55,11 @@ public class InstallDemoConfiguration { + ".opendistro-reports-*, .opensearch-notifications-*, .opensearch-notebooks, .opensearch-observability, .ql-datasources, " + ".opendistro-asynchronous-search-response*, .replication-metadata-store, .opensearch-knn-models, .geospatial-ip2geo-data*"; - static SecurityConfigurator securityConfigurator; + static SecuritySettingsConfigurer securitySettingsConfigurer; static CertificateGenerator certificateGenerator; public static void main(String[] options) { - securityConfigurator = new SecurityConfigurator(); + securitySettingsConfigurer = new SecuritySettingsConfigurer(); certificateGenerator = new CertificateGenerator(); printScriptHeaders(); @@ -67,7 +67,7 @@ public static void main(String[] options) { gatherUserInputs(); initializeVariables(); printVariables(); - securityConfigurator.configureSecurity(); + securitySettingsConfigurer.configureSecuritySettings(); certificateGenerator.createDemoCertificates(); finishScriptExecution(); } @@ -319,7 +319,7 @@ private static void finishScriptExecution() { + FILE_EXTENSION; String securityAdminDemoScriptPath = OPENSEARCH_CONF_DIR + "securityadmin_demo" + FILE_EXTENSION; - securityConfigurator.createSecurityAdminDemoScript(securityAdminScriptPath, securityAdminDemoScriptPath); + securitySettingsConfigurer.createSecurityAdminDemoScript(securityAdminScriptPath, securityAdminDemoScriptPath); // Make securityadmin_demo script executable // not needed for windows diff --git a/src/main/java/org/opensearch/security/tools/democonfig/SecurityConfigurator.java b/src/main/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurer.java similarity index 97% rename from src/main/java/org/opensearch/security/tools/democonfig/SecurityConfigurator.java rename to src/main/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurer.java index 4b3ac3c3be..d7367925e5 100644 --- a/src/main/java/org/opensearch/security/tools/democonfig/SecurityConfigurator.java +++ b/src/main/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurer.java @@ -34,7 +34,7 @@ /** * This class updates the security related configuration, as needed. */ -public class SecurityConfigurator extends InstallDemoConfiguration { +public class SecuritySettingsConfigurer extends Installer { /** * Configures security related changes to the opensearch configuration @@ -42,16 +42,16 @@ public class SecurityConfigurator extends InstallDemoConfiguration { * 2. Sets the custom admin password (Generates one if none is provided) * 3. Write the security config to opensearch.yml */ - public void configureSecurity() { + public void configureSecuritySettings() { checkIfSecurityPluginIsAlreadyConfigured(); - setAdminPassword(); + updateAdminPassword(); writeSecurityConfigToOpenSearchYML(); } /** * Replaces the admin password in internal_users.yml with the custom or generated password */ - private static void setAdminPassword() { + private static void updateAdminPassword() { String ADMIN_PASSWORD = ""; String initialAdminPassword = System.getenv("initialAdminPassword"); String ADMIN_PASSWORD_FILE_PATH = OPENSEARCH_CONF_DIR + "initialAdminPassword.txt"; @@ -291,13 +291,13 @@ void createSecurityAdminDemoScript(String securityAdminScriptPath, String securi + OPENSEARCH_CONF_DIR + "opensearch-security\" -icl -key \"" + OPENSEARCH_CONF_DIR - + DemoCertificate.ADMIN_CERT_KEY.getFileName() + + Certificates.ADMIN_CERT_KEY.getFileName() + "\" -cert \"" + OPENSEARCH_CONF_DIR - + DemoCertificate.ADMIN_CERT.getFileName() + + Certificates.ADMIN_CERT.getFileName() + "\" -cacert \"" + OPENSEARCH_CONF_DIR - + DemoCertificate.ROOT_CA.getFileName() + + Certificates.ROOT_CA.getFileName() + "\" -nhnv"; if (OS.toLowerCase().contains("win")) {