Skip to content

Add secure mode default values #1342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 6, 2023
Merged
32 changes: 32 additions & 0 deletions core/src/main/python/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def __discover(model_context, aliases, credential_injector, helper, extra_tokens
try:
_add_domain_name(base_location, aliases, helper)
_establish_production_mode(aliases, helper)
_establish_secure_mode(aliases, base_location, helper)

DomainInfoDiscoverer(model_context, model.get_model_domain_info(), base_location, wlst_mode=__wlst_mode,
aliases=aliases, credential_injector=credential_injector).discover()
Expand Down Expand Up @@ -300,6 +301,37 @@ def _establish_production_mode(aliases, helper):
raise de


def _establish_secure_mode(aliases, base_location, helper):
"""
Determine if secure mode is enabled for the domain, and set it in the aliases.
:param aliases: aliases instance for discover
:param base_location: location of root directory in WLST
:param helper: wlst_helper instance
:raises DiscoverException: if an error occurs during discovery
"""
_method_name = '_establish_secure_mode'
try:
secure_mode_location = LocationContext(base_location)
secure_mode_location.append_location(model_constants.SECURITY_CONFIGURATION)
security_config_path = aliases.get_wlst_list_path(secure_mode_location)
security_config_token = helper.get_singleton_name(security_config_path)
secure_mode_location.add_name_token(aliases.get_name_token(secure_mode_location), security_config_token)

secure_mode_location.append_location(model_constants.SECURE_MODE)
secure_mode_path = aliases.get_wlst_list_path(secure_mode_location)
secure_mode_token = helper.get_singleton_name(secure_mode_path)
if secure_mode_token is not None:
secure_mode_location.add_name_token(aliases.get_name_token(secure_mode_location), secure_mode_token)
helper.cd(aliases.get_wlst_attributes_path(secure_mode_location))
secure_mode_enabled = helper.get(model_constants.SECURE_MODE_ENABLED)
aliases.set_secure_mode(secure_mode_enabled)
helper.cd(aliases.get_wlst_attributes_path(base_location))
except PyWLSTException, pe:
de = exception_helper.create_discover_exception('WLSDPLY-06038', pe.getLocalizedMessage())
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
raise de


def __discover_multi_tenant(model, model_context, base_location, aliases, injector):
"""
Discover the multi-tenant-related parts of the domain, if they exist.
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/python/wlsdeploy/aliases/alias_constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

These constants are internal to the aliases module and should not be used, as they are not part of the public API.
Expand Down Expand Up @@ -28,6 +28,7 @@
PREFERRED_MODEL_TYPE = 'preferred_model_type'
PRODUCTION_DEFAULT = 'production_default'
RESTART_REQUIRED = 'restart_required'
SECURE_DEFAULT = 'secure_default'
SET_MBEAN_TYPE = 'set_mbean_type'
SET_METHOD = 'set_method'
SHORT_NAME = 'short_name'
Expand Down Expand Up @@ -76,7 +77,8 @@
NULL_VALUE_KEY = '__NULL__'
NULL_VALUE_KEY_FIELDS = [
DEFAULT_VALUE,
PRODUCTION_DEFAULT
PRODUCTION_DEFAULT,
SECURE_DEFAULT
]

# attribute wlst_type values
Expand Down
14 changes: 13 additions & 1 deletion core/src/main/python/wlsdeploy/aliases/aliases.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2022, Oracle and/or its affiliates.
Copyright (c) 2017, 2023, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""
from java.lang import String
Expand Down Expand Up @@ -36,6 +36,7 @@
from wlsdeploy.aliases.alias_constants import PROPERTIES
from wlsdeploy.aliases.alias_constants import RESTART_REQUIRED
from wlsdeploy.aliases.alias_constants import RO
from wlsdeploy.aliases.alias_constants import SECURE_DEFAULT
from wlsdeploy.aliases.alias_constants import SET_MBEAN_TYPE
from wlsdeploy.aliases.alias_constants import SET_METHOD
from wlsdeploy.aliases.alias_constants import STRING
Expand Down Expand Up @@ -83,13 +84,20 @@ def __init__(self, model_context, wlst_mode=WlstModes.OFFLINE, wls_version=None,

self._alias_entries = AliasEntries(wlst_mode, self._wls_version)
self._production_mode_enabled = False
self._secure_mode_enabled = False

def set_production_mode(self, production_mode_enabled):
_method_name = 'set_production_mode'
if production_mode_enabled:
self._logger.info('WLSDPLY-19047', class_name=self._class_name, method_name=_method_name)
self._production_mode_enabled = production_mode_enabled

def set_secure_mode(self, secure_mode_enabled):
_method_name = 'set_secure_mode'
if secure_mode_enabled:
self._logger.info('WLSDPLY-19048', class_name=self._class_name, method_name=_method_name)
self._secure_mode_enabled = secure_mode_enabled

###########################################################################
# Model folder navigation-related methods #
###########################################################################
Expand Down Expand Up @@ -1287,6 +1295,10 @@ def _get_default_value_for_execution_mode(self, attribute_info):
:param attribute_info: alias information for an attribute
:return: the correct default value for the execution mode
"""
if self._secure_mode_enabled:
default_value = dictionary_utils.get_element(attribute_info, SECURE_DEFAULT)
if default_value is not None:
return default_value
if self._production_mode_enabled:
default_value = dictionary_utils.get_element(attribute_info, PRODUCTION_DEFAULT)
if default_value is not None:
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/wlsdeploy/aliases/model_constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""

Expand Down Expand Up @@ -263,6 +263,7 @@
SAML2_IDENTITY_ASSERTER = 'SAML2IdentityAsserter'
SCRIPT_ACTION = 'ScriptAction'
SECURE_MODE = 'SecureMode'
SECURE_MODE_ENABLED = 'SecureModeEnabled'
SECURITY = 'Security'
SECURITY_CONFIGURATION = 'SecurityConfiguration'
SECURITY_CONFIGURATION_CD_ENABLED = 'CrossDomainSecurityEnabled'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"copyright": "Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.",
"copyright": "Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates.",
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
"wlst_type": "Cluster${:s}",
"online_bean": "weblogic.management.configuration.ClusterMBean",
Expand Down Expand Up @@ -243,7 +243,7 @@
"ReplicationChannel": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ReplicationChannel", "wlst_path": "WP001", "default_value": "ReplicationChannel", "wlst_type": "string", "restart_required": "true" } ],
"ReplicationTimeoutEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ReplicationTimeoutEnabled", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean", "restart_required": "true" } ],
"ReplicationTimeoutMillis": [ {"version": "[14.1.2,)", "wlst_mode": "both", "wlst_name": "ReplicationTimeoutMillis", "wlst_path": "WP001", "default_value": 0, "derived_default": "${:true}", "wlst_type": "integer" } ],
"SecureReplicationEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SecureReplicationEnabled", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean" } ],
"SecureReplicationEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SecureReplicationEnabled", "wlst_path": "WP001", "default_value": "false", "secure_default": "${__NULL__:true}", "wlst_type": "boolean" } ],
"ServiceActivationRequestResponseTimeout": [ {"version": "[12.2.1,12.2.1.3)", "wlst_mode": "both", "wlst_name": "ServiceActivationRequestResponseTimeout", "wlst_path": "WP001", "default_value": "10000", "wlst_type": "integer", "restart_required": "true" },
{"version": "[12.2.1.3,)", "wlst_mode": "both", "wlst_name": "ServiceActivationRequestResponseTimeout", "wlst_path": "WP001", "default_value": 0, "wlst_type": "integer", "restart_required": "true" } ],
"ServiceAgeThresholdSeconds": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServiceAgeThresholdSeconds", "wlst_path": "WP001", "default_value": 180, "wlst_type": "integer" } ],
Expand Down
Loading