Skip to content

Commit 8a071ed

Browse files
committed
Merge branch 'rcudbinfo-store-paths' into 'develop-4.0'
Use absolute or domain-relative truststore and keystore paths in JPS configuration updates See merge request weblogic-cloud/weblogic-deploy-tooling!1661
2 parents 2a3e43b + f870781 commit 8a071ed

File tree

5 files changed

+72
-23
lines changed

5 files changed

+72
-23
lines changed

core/src/main/python/wlsdeploy/tool/create/jps_config_helper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ def fix_jps_config(self):
4646

4747
if self._use_ssl:
4848
tns_admin = self._rcu_db_info.get_tns_admin()
49-
keystore = self._rcu_db_info.get_keystore()
49+
50+
# OPSS wants keystore path relative to domain home, or absolute
51+
keystore = self._rcu_db_info.get_qualified_keystore_path()
5052
keystore_type = self._rcu_db_info.get_keystore_type()
5153
keystore_password = self._rcu_db_info.get_keystore_password()
5254

53-
truststore = self._rcu_db_info.get_truststore()
55+
# OPSS wants truststore path relative to domain home, or absolute
56+
truststore = self._rcu_db_info.get_qualified_truststore_path()
5457
truststore_type = self._rcu_db_info.get_truststore_type()
5558
truststore_password = self._rcu_db_info.get_truststore_password()
5659

core/src/main/python/wlsdeploy/tool/create/rcudbinfo_helper.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
5+
import os
6+
57
from oracle.weblogic.deploy.create.RCURunner import DB2_DB_TYPE
68
from oracle.weblogic.deploy.create.RCURunner import EBR_DB_TYPE
79
from oracle.weblogic.deploy.create.RCURunner import MYSQL_DB_TYPE
@@ -44,7 +46,7 @@
4446

4547
from wlsdeploy.logging.platform_logger import PlatformLogger
4648
from wlsdeploy.util import dictionary_utils
47-
49+
from wlsdeploy.util import string_utils
4850

4951
_class_name = 'rcudbinfo_helper'
5052

@@ -138,6 +140,13 @@ def get_rcu_schema_password(self):
138140
def get_keystore(self):
139141
return self._get_dictionary_path_value(DRIVER_PARAMS_KEYSTORE_PROPERTY)
140142

143+
def get_qualified_keystore_path(self):
144+
"""
145+
Prepend the TNS admin path to keystore if keystore is a relative path and not in archive.
146+
:return: the derived keystore path
147+
"""
148+
return self.__get_qualified_store_path(self.get_keystore())
149+
141150
def get_keystore_type(self):
142151
return self._get_dictionary_element_value(DRIVER_PARAMS_KEYSTORETYPE_PROPERTY)
143152

@@ -148,6 +157,13 @@ def get_keystore_password(self):
148157
def get_truststore(self):
149158
return self._get_dictionary_path_value(DRIVER_PARAMS_TRUSTSTORE_PROPERTY)
150159

160+
def get_qualified_truststore_path(self):
161+
"""
162+
Prepend the TNS admin path to truststore if truststore is a relative path and not in archive.
163+
:return: the derived truststore path
164+
"""
165+
return self.__get_qualified_store_path(self.get_truststore())
166+
151167
def get_truststore_type(self):
152168
return self._get_dictionary_element_value(DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY)
153169

@@ -274,6 +290,17 @@ def is_use_ssl(self):
274290

275291
return result
276292

293+
def __get_qualified_store_path(self, store_value):
294+
return get_qualified_store_path(self.get_tns_admin(), store_value)
295+
296+
297+
# "static" method for validation, etc.
298+
def get_qualified_store_path(tns_admin, store_value):
299+
if not string_utils.is_empty(store_value) and not string_utils.is_empty(tns_admin) and \
300+
not os.path.isabs(store_value) and not WLSDeployArchive.isPathIntoArchive(store_value):
301+
store_value = tns_admin + WLSDeployArchive.ZIP_SEP + store_value
302+
return store_value
303+
277304

278305
def create(model_dictionary, model_context, aliases):
279306
"""

core/src/main/python/wlsdeploy/tool/validate/create_content_validator.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from java.lang import Integer
77
from java.util import HashMap
88
from oracle.weblogic.deploy.create import RCURunner
9+
from oracle.weblogic.deploy.util import WLSDeployArchive
910
from oracle.weblogic.deploy.validate import PasswordValidator
1011
from oracle.weblogic.deploy.validate import ValidateException
1112

@@ -43,6 +44,8 @@
4344
from wlsdeploy.aliases.model_constants import USER
4445
from wlsdeploy.exception import exception_helper
4546
from wlsdeploy.logging.platform_logger import PlatformLogger
47+
from wlsdeploy.tool.create import rcudbinfo_helper
48+
from wlsdeploy.tool.util.archive_helper import ArchiveList
4649
from wlsdeploy.tool.validate.content_validator import ContentValidator
4750
from wlsdeploy.util import dictionary_utils
4851

@@ -68,7 +71,7 @@ class CreateDomainContentValidator(ContentValidator):
6871

6972
def __init__(self, model_context, archive_helper, aliases):
7073
ContentValidator.__init__(self, model_context, aliases)
71-
self._archive_helper = archive_helper
74+
self._archive_helper = archive_helper # type: ArchiveList
7275

7376
# Override
7477
def validate_model_content(self, model_dict):
@@ -190,6 +193,17 @@ def __validate_store_property(self, store_property, type_property, pwd_property,
190193
'WLSDPLY-05309', RCU_DB_INFO, pwd_property, type_property, type_value,
191194
class_name=self._class_name, method_name=_method_name)
192195

196+
# check if the qualified path should be in the archive
197+
tns_admin = dictionary_utils.get_element(rcu_info_dict, DRIVER_PARAMS_NET_TNS_ADMIN)
198+
qualified_path = rcudbinfo_helper.get_qualified_store_path(tns_admin, store_value)
199+
if WLSDeployArchive.isPathIntoArchive(qualified_path):
200+
if not self._archive_helper:
201+
self._logger.severe('WLSDPLY-05311', qualified_path, RCU_DB_INFO, store_property,
202+
class_name=self._class_name, method_name=_method_name)
203+
elif not self.__is_path_in_archive_wallet(qualified_path):
204+
self._logger.severe('WLSDPLY-05312', qualified_path, RCU_DB_INFO, store_property,
205+
class_name=self._class_name, method_name=_method_name)
206+
193207
def __has_tns_path(self, rcu_info_dict):
194208
"""
195209
Determine if a path to the tnsnames.ora file can be found.
@@ -363,6 +377,24 @@ def _get_users_dictionary(self, model_dict):
363377
self._logger.exiting(class_name=self._class_name, method_name=_method_name)
364378
return users_folder
365379

380+
def __is_path_in_archive_wallet(self, path):
381+
"""
382+
Check if path is in an archive, or in a zipped wallet in an archive.
383+
:param path: the path to be checked.
384+
:return: True if the path was found, false otherwise
385+
"""
386+
if self._archive_helper.contains_file(path):
387+
return True
388+
389+
last_slash = path.rfind('/')
390+
wallet_path = ''
391+
if last_slash != -1:
392+
wallet_path = path[:last_slash]
393+
file_name = path[last_slash + 1:]
394+
archive, entries = self._archive_helper.get_wallet_entries(wallet_path)
395+
396+
return file_name in entries
397+
366398

367399
def _get_system_password_validator_location():
368400
location = LocationContext()

core/src/main/python/wlsdeploy/tool/validate/domain_info_validator.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ def _validate_single_path_in_archive(self, path, attribute_name, model_folder_pa
129129
"""
130130
Extend this method to allow wallet paths to be in a wallet zip in the archive.
131131
"""
132+
# avoid INFO WLSDPLY-05031 - *Store paths may be relative to oracle.net.tns_admin,
133+
# or in a zipped wallet in the archive.
134+
# these cases are checked using the merged model in create_content_validator.
132135
if attribute_name in WALLET_PATH_ATTRIBUTES:
133-
if self.__is_path_in_zipped_archive_wallet(path):
134-
return
136+
return
135137

136138
ModelValidator._validate_single_path_in_archive(self, path, attribute_name, model_folder_path)
137139

@@ -257,23 +259,6 @@ def _validate_single_server_group_target_limits_value(self, key, value, model_fo
257259
str_helper.to_string(type(value)),
258260
class_name=_class_name, method_name=_method_name)
259261

260-
def __is_path_in_zipped_archive_wallet(self, path):
261-
if not WLSDeployArchive.isPathIntoArchive(path) or not self._archive_helper:
262-
return False
263-
264-
if self._archive_helper.contains_file(path):
265-
# the file is directly in the archive, return for regular validation
266-
return False
267-
268-
last_slash = path.rfind('/')
269-
wallet_path = ''
270-
if last_slash != -1:
271-
wallet_path = path[:last_slash]
272-
file_name = path[last_slash + 1:]
273-
archive, entries = self._archive_helper.get_wallet_entries(wallet_path)
274-
275-
return file_name in entries
276-
277262
def _check_deprecated_field(self, field_name, info_dict, folder_name, new_field_name):
278263
_method_name = '_check_deprecated_field'
279264
if dictionary_utils.get_element(info_dict, field_name):

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ WLSDPLY-05307=For database type {0}, {1} field {2} or {3} must be specified
660660
WLSDPLY-05308=For {0} {1}, {2} field {3} must be specified
661661
WLSDPLY-05309={0} field {1} must be specified for {2} value of {3}
662662
WLSDPLY-05310={0} field {1} must be specified if {2} is specified
663+
WLSDPLY-05311=Prepended path {0} for {1} field {2} is an archive path, and no archive file is specified
664+
WLSDPLY-05312=Prepended path {0} for {1} field {2} is an archive path, and not found in any archive file
663665

664666
# oracle/weblogic/deploy/validate/PasswordValidator.java
665667
WLSDPLY-05400=Password validation failed because the username was not provided

0 commit comments

Comments
 (0)