@@ -326,7 +326,8 @@ def __init__(self):
326326 self .templates_dir = os .path .join (self .flex_setup_dir , 'templates' )
327327 self .admin_ui_config_properties_path = os .path .join (self .templates_dir , 'auiConfiguration.json' )
328328 self .adimin_ui_bin_url = 'https://jenkins.gluu.org/npm/admin_ui/main/built/admin-ui-main-built.tar.gz'
329- self .policy_store_path = os .path .join (self .templates_dir , 'policy-store.json' )
329+ self .policy_store_cjar_url = 'https://github.com/GluuFederation/GluuFlexAdminUIPolicyStore/releases/download/v0.0.0/admin_ui_2_0.cjar'
330+ self .policy_store_cjar_path = os .path .join (self .templates_dir , 'policy-store.cjar' )
330331 self .schema_file = os .path .join (self .flex_setup_dir , 'flex_schema.json' )
331332 self .java_security_fn = os .path .join (self .templates_dir , 'java.security' )
332333 self .config_api_base_dir = os .path .join (config_api_installer .jetty_base , config_api_installer .service_name )
@@ -375,9 +376,7 @@ def download_files(self, force=False):
375376 'https://raw.githubusercontent.com/JanssenProject/jans/{}/jans-config-api/plugins/admin-ui-plugin/config/log4j2-adminui.xml' .format (
376377 app_versions ['JANS_BRANCH' ]), self .log4j2_adminui_path ),
377378 (self .adimin_ui_bin_url , os .path .join (Config .dist_jans_dir , os .path .basename (self .adimin_ui_bin_url ))),
378- ('https://raw.githubusercontent.com/GluuFederation/GluuFlexAdminUIPolicyStore/refs/heads/main/2fb50e468d9dfefa142d1fce4fa9747efbd3a0f08de5.json' ,
379- self .policy_store_path
380- ),
379+ (self .policy_store_cjar_url , self .policy_store_cjar_path ),
381380 ]
382381
383382 if argsp .update_admin_ui :
@@ -587,20 +586,34 @@ def install_gluu_admin_ui(self):
587586
588587 #cedarling integration
589588 admin_ui_config_dir = os .path .join (config_api_installer .custom_config_dir , 'adminUI' )
590- if os .path .exists (self .policy_store_path ):
591- # before rendering template we need to 'replace your-openid-provider.server' with current hostname
592- policy_store_content = self .readFile (self .policy_store_path )
593- policy_store_content = policy_store_content .replace ('your-openid-provider.server' , Config .hostname )
594- self .writeFile (self .policy_store_path , policy_store_content )
595-
596- try :
597- with open (self .policy_store_path ) as f :
598- json .load (f ) # Validates JSON format
599- config_api_installer .renderTemplateInOut (self .policy_store_path , self .templates_dir , admin_ui_config_dir )
600- except json .JSONDecodeError as e :
601- print (f"Warning: Downloaded policy store is not valid JSON: { e } " )
602-
603- config_api_installer .chown (admin_ui_config_dir , Config .jetty_user , Config .jetty_group )
589+ config_api_installer .createDirs (admin_ui_config_dir )
590+ if os .path .exists (self .policy_store_cjar_path ):
591+ target_entry = 'trusted-issuers/GluuFlexAdminUI.json'
592+ tmp_cjar = os .path .join (tempfile .gettempdir (), os .urandom (8 ).hex () + '.cjar' )
593+
594+ with zipfile .ZipFile (self .policy_store_cjar_path , 'r' ) as zin , \
595+ zipfile .ZipFile (tmp_cjar , 'w' , allowZip64 = True ) as zout :
596+ for item in zin .infolist ():
597+ data = zin .read (item .filename )
598+ if item .filename == target_entry :
599+ trusted_issuers = json .loads (data .decode ('utf-8' ))
600+ trusted_issuers ['configuration_endpoint' ] = (
601+ trusted_issuers ['configuration_endpoint' ]
602+ .replace ('your-openid-provider.server' , Config .hostname )
603+ )
604+ data = json .dumps (trusted_issuers , indent = 2 ).encode ('utf-8' )
605+ new_info = zipfile .ZipInfo (item .filename , date_time = item .date_time )
606+ new_info .compress_type = item .compress_type
607+ new_info .external_attr = item .external_attr
608+ zout .writestr (new_info , data )
609+ else :
610+ zout .writestr (item , data ) # preserves ZipInfo metadata + data
611+
612+ shutil .move (tmp_cjar , self .policy_store_cjar_path )
613+ config_api_installer .copyFile (self .policy_store_cjar_path , admin_ui_config_dir , backup = False )
614+
615+ config_api_installer .chown (admin_ui_config_dir , Config .jetty_user , Config .jetty_group , recursive = True )
616+
604617 resource_scopes_mapping_lidf_fn = os .path .join (self .templates_dir , 'adminUIResourceScopesMapping.ldif' )
605618
606619 self .dbUtils .import_ldif ([resource_scopes_mapping_lidf_fn ])
0 commit comments