Skip to content

Commit 852d398

Browse files
authored
Treat mail session properties as dict (#1416)
1 parent 83f2337 commit 852d398

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py

+12-23
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from oracle.weblogic.deploy.util import WLSDeployArchiveIOException
1212

1313
from wlsdeploy.aliases import model_constants
14+
from wlsdeploy.aliases.alias_constants import PASSWORD_TOKEN
1415
from wlsdeploy.aliases.location_context import LocationContext
1516
from wlsdeploy.aliases.wlst_modes import WlstModes
1617
from wlsdeploy.exception import exception_helper
@@ -21,7 +22,6 @@
2122
from wlsdeploy.tool.discover.discoverer import Discoverer
2223
from wlsdeploy.tool.discover.jms_resources_discoverer import JmsResourcesDiscoverer
2324
from wlsdeploy.util import dictionary_utils
24-
import wlsdeploy.util.unicode_helper as str_helper
2525

2626
_class_name = 'CommonResourcesDiscoverer'
2727
_logger = PlatformLogger(discoverer.get_discover_logger_name())
@@ -553,28 +553,17 @@ def _get_named_resources(self, folder_name):
553553
return model_top_folder_name, result
554554

555555

556-
def _fix_passwords_in_mail_session_properties(dictionary):
556+
def _fix_passwords_in_mail_session_properties(mail_session_dict):
557557
"""
558558
Look for password properties in the mail session properties string, and replace the password with a fix me token.
559-
:param dictionary: containing the discovered mail session attributes
559+
:param mail_session_dict: containing the discovered mail session attributes
560560
"""
561-
match_pattern = "mail\.\w*\.?password"
562-
replacement = '--FIX ME--'
563-
if model_constants.MAIL_SESSION_PROPERTIES in dictionary:
564-
new_properties = ''
565-
string_properties = dictionary[model_constants.MAIL_SESSION_PROPERTIES]
566-
if string_properties:
567-
properties = string_properties
568-
if isinstance(string_properties, basestring):
569-
properties = StringUtils.formatPropertiesFromString(string_properties)
570-
new_properties = OrderedDict()
571-
iterator = properties.stringPropertyNames().iterator()
572-
while iterator.hasNext():
573-
key = iterator.next()
574-
new_key = str_helper.to_string(key).strip()
575-
value = str_helper.to_string(properties.getProperty(key))
576-
tokenized = value.startswith('@@')
577-
if StringUtils.matches(match_pattern, new_key) and not tokenized:
578-
value = replacement
579-
new_properties[new_key] = value
580-
dictionary[model_constants.MAIL_SESSION_PROPERTIES] = new_properties
561+
match_pattern = r'mail\.\w*\.?password'
562+
if model_constants.MAIL_SESSION_PROPERTIES in mail_session_dict:
563+
# alias framework has converted properties to a dictionary by this point
564+
properties_dict = mail_session_dict[model_constants.MAIL_SESSION_PROPERTIES]
565+
for property_name in properties_dict:
566+
property_value = properties_dict[property_name]
567+
is_tokenized = property_value.startswith('@@')
568+
if StringUtils.matches(match_pattern, property_name) and not is_tokenized:
569+
properties_dict[property_name] = PASSWORD_TOKEN

0 commit comments

Comments
 (0)