From 60cb36c1f46ac7ef383072a5ad753dc4ef6320b3 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 16 May 2022 14:43:59 +0300 Subject: [PATCH] feat: jans-linux-setup load pure java sample custom script (#1335) --- .../jans_setup/setup_app/installers/jans.py | 4 ++++ .../jans_setup/setup_app/test_data_loader.py | 15 +++++++++------ .../jans_setup/setup_app/utils/crypto64.py | 2 +- .../jans_setup/setup_app/utils/db_utils.py | 1 + .../{discovery.py => discovery-python.py} | 0 .../jans_setup/templates/scripts.ldif | 14 ++++++++++++++ 6 files changed, 29 insertions(+), 7 deletions(-) rename jans-linux-setup/jans_setup/static/extension/discovery/{discovery.py => discovery-python.py} (100%) diff --git a/jans-linux-setup/jans_setup/setup_app/installers/jans.py b/jans-linux-setup/jans_setup/setup_app/installers/jans.py index d8c8df7e506..c15916b3a75 100644 --- a/jans-linux-setup/jans_setup/setup_app/installers/jans.py +++ b/jans-linux-setup/jans_setup/setup_app/installers/jans.py @@ -76,6 +76,10 @@ def __repr__(self): txt += 'Install Scim Server'.ljust(30) + repr(Config.install_scim_server).rjust(35) + (' *' if 'install_scim_server' in Config.addPostSetupService else '') + "\n" txt += 'Install Eleven Server'.ljust(30) + repr(Config.installEleven).rjust(35) + (' *' if 'installEleven' in Config.addPostSetupService else '') + "\n" #txt += 'Install Oxd '.ljust(30) + repr(Config.installOxd).rjust(35) + (' *' if 'installOxd' in Config.addPostSetupService else '') + "\n" + + if base.argsp.t: + txt += 'Load Test Data '.ljust(30) + repr( base.argsp.t).rjust(35) + "\n" + return txt except Exception as e: diff --git a/jans-linux-setup/jans_setup/setup_app/test_data_loader.py b/jans-linux-setup/jans_setup/setup_app/test_data_loader.py index 67485f2c393..63ca05b4d42 100644 --- a/jans-linux-setup/jans_setup/setup_app/test_data_loader.py +++ b/jans-linux-setup/jans_setup/setup_app/test_data_loader.py @@ -62,6 +62,14 @@ def create_test_client_keystore(self): self.copyFile(client_keystore_fn, os.path.join(Config.output_dir, 'test/jans-auth/server')) self.copyFile(keys_json_fn, os.path.join(Config.output_dir, 'test/jans-auth/server')) + + def enable_cusom_scripts(self): + self.logIt("Enabling custom scripts") + custom_scripts = ('2DAF-F995', '2DAF-F996', '4BBE-C6A8', 'A51E-76DA', '0300-BA90') + for inum in custom_scripts: + self.dbUtils.enable_script(inum) + + def load_test_data(self): Config.pbar.progress(self.service_name, "Loading Test Data", False) self.logIt("Re-binding database") @@ -265,14 +273,9 @@ def load_test_data(self): oxAuthConfDynamic_changes.update(datajs) self.logIt("oxAuthConfDynamic was updated with auto test ciba patch") - custom_scripts = ('2DAF-F995', '2DAF-F996', '4BBE-C6A8', 'A51E-76DA') - self.dbUtils.set_oxAuthConfDynamic(oxAuthConfDynamic_changes) - - # Enable custom scripts - for inum in custom_scripts: - self.dbUtils.enable_script(inum) + self.enable_cusom_scripts() if self.dbUtils.moddb == static.BackendTypes.LDAP: # Update LDAP schema diff --git a/jans-linux-setup/jans_setup/setup_app/utils/crypto64.py b/jans-linux-setup/jans_setup/setup_app/utils/crypto64.py index 530d12b5711..e4b054c5450 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/crypto64.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/crypto64.py @@ -103,7 +103,7 @@ def prepare_base64_extension_scripts(self, extensions=[]): self.logIt("Preparing scripts") extension_path = Path(Config.extensionFolder) for ep in extension_path.glob("**/*"): - if ep.is_file() and ep.suffix in ['.py']: + if ep.is_file() and ep.suffix.lower() in ['.py', '.java']: extension_type = ep.parent.name.lower() extension_name = ep.stem.lower() extension_script_name = '{}_{}'.format(extension_type, extension_name) diff --git a/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py b/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py index 25070ba1d5f..d9f9d4b1ad9 100644 --- a/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py +++ b/jans-linux-setup/jans_setup/setup_app/utils/db_utils.py @@ -241,6 +241,7 @@ def set_oxAuthConfDynamic(self, entries): def enable_script(self, inum): + base.logIt("Enabling script {}".format(inum)) if self.moddb == BackendTypes.LDAP: ldap_operation_result = self.ldap_conn.modify( 'inum={},ou=scripts,o=jans'.format(inum), diff --git a/jans-linux-setup/jans_setup/static/extension/discovery/discovery.py b/jans-linux-setup/jans_setup/static/extension/discovery/discovery-python.py similarity index 100% rename from jans-linux-setup/jans_setup/static/extension/discovery/discovery.py rename to jans-linux-setup/jans_setup/static/extension/discovery/discovery-python.py diff --git a/jans-linux-setup/jans_setup/templates/scripts.ldif b/jans-linux-setup/jans_setup/templates/scripts.ldif index eb8ede16839..e3f6efc1386 100644 --- a/jans-linux-setup/jans_setup/templates/scripts.ldif +++ b/jans-linux-setup/jans_setup/templates/scripts.ldif @@ -516,3 +516,17 @@ jansRevision: 1 jansProgLng: python jansScrTyp: config_api_auth jansScr::%(config_api_config_api_interception)s + +dn: inum=0300-BA90,ou=scripts,o=jans +objectClass: jansCustomScr +objectClass: top +description: Java Custom Sample Script +displayName: discovery_java_params +inum: 0300-BA90 +jansEnabled: FALSE +jansLevel: 1 +jansModuleProperty: {"value1":"location_type","value2":"ldap","description":""} +jansProgLng: java +jansRevision: 11 +jansScr::%(discovery_discovery)s +jansScrTyp: discovery