|
1 | 1 | """
|
2 |
| -Copyright (c) 2017, 2024, Oracle and/or its affiliates. |
| 2 | +Copyright (c) 2017, 2025, Oracle and/or its affiliates. |
3 | 3 | Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl.
|
4 | 4 | """
|
5 | 5 | import os
|
|
10 | 10 | from weblogic.security.internal import SerializedSystemIni
|
11 | 11 | from weblogic.security.internal.encryption import ClearOrEncryptedService
|
12 | 12 |
|
| 13 | +from wlsdeploy.aliases import alias_utils |
13 | 14 | from wlsdeploy.aliases.location_context import LocationContext
|
14 | 15 | from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD
|
15 | 16 | from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
|
|
36 | 37 | from wlsdeploy.aliases.model_constants import PRODUCTION_MODE_ENABLED
|
37 | 38 | from wlsdeploy.aliases.model_constants import RESOURCE_GROUP
|
38 | 39 | from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE
|
| 40 | +from wlsdeploy.aliases.model_constants import SECURE_MODE |
| 41 | +from wlsdeploy.aliases.model_constants import SECURE_MODE_ENABLED |
39 | 42 | from wlsdeploy.aliases.model_constants import SECURITY
|
40 | 43 | from wlsdeploy.aliases.model_constants import SECURITY_CONFIGURATION
|
41 | 44 | from wlsdeploy.aliases.model_constants import SERVER
|
@@ -551,6 +554,8 @@ def __set_core_domain_params(self):
|
551 | 554 | use_sample_db = str_helper.to_string(use_sample_db)
|
552 | 555 | self.wlst_helper.set_option_if_needed(USE_SAMPLE_DATABASE, use_sample_db)
|
553 | 556 |
|
| 557 | + self.__set_secure_and_production_modes() |
| 558 | + |
554 | 559 | self.__set_domain_name()
|
555 | 560 | self.__set_admin_password()
|
556 | 561 | self.__set_admin_server_name()
|
@@ -946,6 +951,42 @@ def __set_admin_server_name(self):
|
946 | 951 | else:
|
947 | 952 | self._admin_server_name = self.__default_admin_server_name
|
948 | 953 |
|
| 954 | + def __set_secure_and_production_modes(self): |
| 955 | + """ |
| 956 | + Set secure and production mode enabled before initial writeDomain |
| 957 | + """ |
| 958 | + root_location = LocationContext() |
| 959 | + domain_name_token = self.aliases.get_name_token(root_location) |
| 960 | + root_location.add_name_token(domain_name_token, self._domain_name) |
| 961 | + |
| 962 | + production_mode_enabled = dictionary_utils.get_element(self._topology, PRODUCTION_MODE_ENABLED) |
| 963 | + if production_mode_enabled is not None: |
| 964 | + wlst_name = self.aliases.get_wlst_attribute_name(root_location, PRODUCTION_MODE_ENABLED) |
| 965 | + production_mode_enabled = alias_utils.convert_boolean(production_mode_enabled) |
| 966 | + self.wlst_helper.set(wlst_name, production_mode_enabled) |
| 967 | + |
| 968 | + if production_mode_enabled: # check for secure mode specified, may be disabled |
| 969 | + security_config_folder = dictionary_utils.get_dictionary_element(self._topology, SECURITY_CONFIGURATION) |
| 970 | + secure_mode_folder = dictionary_utils.get_dictionary_element(security_config_folder, SECURE_MODE) |
| 971 | + secure_mode_enabled = dictionary_utils.get_element(secure_mode_folder, SECURE_MODE_ENABLED) |
| 972 | + if secure_mode_enabled is not None: |
| 973 | + secure_mode_enabled = alias_utils.convert_boolean(secure_mode_enabled) |
| 974 | + secure_location = LocationContext(root_location) |
| 975 | + secure_location.append_location(SECURITY_CONFIGURATION) |
| 976 | + |
| 977 | + # secure mode doesn't exist in older WLS versions |
| 978 | + code, message = self.aliases.is_valid_model_folder_name(secure_location, SECURE_MODE) |
| 979 | + if code == ValidationCodes.VALID: |
| 980 | + existing_subfolder_names = deployer_utils.get_existing_object_list(secure_location, self.aliases) |
| 981 | + deployer_utils.create_and_cd(secure_location, existing_subfolder_names, self.aliases) |
| 982 | + secure_location.append_location(SECURE_MODE) |
| 983 | + existing_subfolder_names = deployer_utils.get_existing_object_list(secure_location, self.aliases) |
| 984 | + deployer_utils.create_and_cd(secure_location, existing_subfolder_names, self.aliases) |
| 985 | + |
| 986 | + wlst_name = self.aliases.get_wlst_attribute_name(secure_location, SECURE_MODE_ENABLED) |
| 987 | + self.wlst_helper.set(wlst_name, secure_mode_enabled) |
| 988 | + self.wlst_helper.cd('/') |
| 989 | + |
949 | 990 | def __set_domain_attributes(self):
|
950 | 991 | """
|
951 | 992 | Set the Domain attributes
|
@@ -989,7 +1030,7 @@ def __create_boot_dot_properties(self):
|
989 | 1030 | return
|
990 | 1031 |
|
991 | 1032 | if PRODUCTION_MODE_ENABLED in self._topology:
|
992 |
| - if string_utils.to_boolean(self._topology[PRODUCTION_MODE_ENABLED]): |
| 1033 | + if alias_utils.convert_boolean(self._topology[PRODUCTION_MODE_ENABLED]): |
993 | 1034 | return
|
994 | 1035 |
|
995 | 1036 | system_ini = SerializedSystemIni.getEncryptionService(self._domain_home)
|
|
0 commit comments