Skip to content

Commit 766f89a

Browse files
committed
Merge branch 'prod-secure-mode' into 'main'
Use secure mode for 14.1.2 if production mode is set and secure mode not specified See merge request weblogic-cloud/weblogic-deploy-tooling!1770
2 parents e9bd72f + b4abdf2 commit 766f89a

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

core/src/main/python/discover.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def __discover(model_context, aliases, credential_injector, helper, extra_tokens
437437
try:
438438
_add_domain_name(base_location, aliases, helper)
439439
_establish_production_mode(aliases, helper)
440-
_establish_secure_mode(aliases, base_location, helper)
440+
_establish_secure_mode(aliases, base_location, helper, model_context)
441441

442442
DomainInfoDiscoverer(model_context, model.get_model_domain_info(), base_location, wlst_mode=__wlst_mode,
443443
aliases=aliases, credential_injector=credential_injector).discover()
@@ -504,16 +504,25 @@ def _establish_production_mode(aliases, helper):
504504
raise de
505505

506506

507-
def _establish_secure_mode(aliases, base_location, helper):
507+
def _establish_secure_mode(aliases, base_location, helper, model_context):
508508
"""
509509
Determine if secure mode is enabled for the domain, and set it in the aliases.
510510
:param aliases: aliases instance for discover
511511
:param base_location: location of root directory in WLST
512512
:param helper: wlst_helper instance
513+
:param model_context: used to check dependency
513514
:raises DiscoverException: if an error occurs during discovery
514515
"""
515516
_method_name = '_establish_secure_mode'
516517
try:
518+
if model_context.get_weblogic_helper().is_secure_mode_implied_by_production_mode():
519+
# for 14.1.2, secure mode defaults to true if production mode is true.
520+
# this may be overridden by the value of SecurityConfiguration/SecureMode/SecureModeEnabled.
521+
helper.cd('/')
522+
secure_mode_enabled = helper.get(model_constants.PRODUCTION_MODE_ENABLED)
523+
else:
524+
secure_mode_enabled = False
525+
517526
secure_mode_location = LocationContext(base_location)
518527
secure_mode_location.append_location(model_constants.SECURITY_CONFIGURATION)
519528

@@ -530,8 +539,10 @@ def _establish_secure_mode(aliases, base_location, helper):
530539
secure_mode_location.add_name_token(aliases.get_name_token(secure_mode_location), secure_mode_token)
531540
helper.cd(aliases.get_wlst_attributes_path(secure_mode_location))
532541
secure_mode_enabled = helper.get(model_constants.SECURE_MODE_ENABLED)
533-
aliases.set_secure_mode(secure_mode_enabled)
534-
helper.cd(aliases.get_wlst_attributes_path(base_location))
542+
543+
aliases.set_secure_mode(secure_mode_enabled)
544+
helper.cd(aliases.get_wlst_attributes_path(base_location))
545+
535546
except PyWLSTException, pe:
536547
de = exception_helper.create_discover_exception('WLSDPLY-06038', pe.getLocalizedMessage())
537548
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)

core/src/main/python/wlsdeploy/util/weblogic_helper.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2025, 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
"""
55
import os
@@ -169,6 +169,13 @@ def is_wrc_domain_extension_supported(self):
169169
"""
170170
return self.is_weblogic_version_or_above('12.2.1.3') and not self.is_weblogic_version_or_above('14.1.2')
171171

172+
def is_secure_mode_implied_by_production_mode(self):
173+
"""
174+
Is secure mode value true by default if production mode is set?
175+
:return: true if version is within the range for this condition. false otherwise
176+
"""
177+
return self.is_weblogic_version_or_above('14.1.2')
178+
172179
def get_jdbc_url_from_rcu_connect_string(self, rcu_connect_string, rcu_database_type='ORACLE'):
173180
"""
174181
Get the JDBC URL from the RCU connect string.

0 commit comments

Comments
 (0)