Skip to content

Commit bc1f986

Browse files
committed
JIRA WDT-47 Enable special processing for custom security providers; allow them to pass validate
1 parent 95743c4 commit bc1f986

File tree

6 files changed

+70
-26
lines changed

6 files changed

+70
-26
lines changed

core/src/main/python/wlsdeploy/aliases/aliases.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ def is_artificial_type_folder(self, location):
271271
"""
272272
return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.NONE)
273273

274+
def is_custom_folder_allowed(self, location):
275+
"""
276+
Returns true if the specified location allows custom, user-defined folder types.
277+
This currently corresponds to all MULTIPLE_WITH_TYPE_SUBFOLDER entries.
278+
This will need to be refined if new custom types are added, or additional distinctions are required.
279+
:param location: the location to be checked
280+
:return: True if the location allows custom folder types, False otherwise
281+
:raises: AliasException: if an error occurs while getting the folder for the location
282+
"""
283+
return self._alias_entries.is_location_child_folder_type(location,
284+
ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER)
285+
274286
###########################################################################
275287
# WLST Folder create-related methods #
276288
###########################################################################

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

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55

@@ -12,6 +12,7 @@
1212
from wlsdeploy.logging.platform_logger import PlatformLogger
1313
from wlsdeploy.tool.util.alias_helper import AliasHelper
1414
from wlsdeploy.tool.util.attribute_setter import AttributeSetter
15+
from wlsdeploy.tool.util.custom_folder_helper import CustomFolderHelper
1516
from wlsdeploy.tool.util.wlst_helper import WlstHelper
1617
from wlsdeploy.util import dictionary_utils
1718
from wlsdeploy.util.model import Model
@@ -29,12 +30,15 @@ def __init__(self, model, model_context, aliases, exception_type=ExceptionType.C
2930

3031
self.logger = logger
3132
self.aliases = aliases
33+
self._exception_type = exception_type
3234
self.alias_helper = AliasHelper(self.aliases, self.logger, exception_type)
3335
self.wlst_helper = WlstHelper(self.logger, exception_type)
3436
self.model = Model(model)
3537
self.model_context = model_context
3638
self.wls_helper = WebLogicHelper(self.logger)
3739
self.attribute_setter = AttributeSetter(self.aliases, self.logger, exception_type)
40+
self.custom_folder_helper = CustomFolderHelper(self.aliases, self.logger, exception_type)
41+
3842
# Must be initialized by the subclass since only it has
3943
# the knowledge required to compute the domain name.
4044
self.archive_helper = None
@@ -179,27 +183,39 @@ def _create_security_provider_mbeans(self, type_name, model_nodes, base_location
179183
create_path = self.alias_helper.get_wlst_create_path(location)
180184
list_path = self.alias_helper.get_wlst_list_path(location)
181185
existing_folder_names = self._get_existing_folders(list_path)
186+
known_providers = self.alias_helper.get_model_subfolder_names(location)
187+
allow_custom = str(self.alias_helper.is_custom_folder_allowed(location))
188+
182189
for model_name in model_nodes:
190+
model_node = model_nodes[model_name]
191+
192+
if model_node is None:
193+
# The node is empty so nothing to do... move to the next named node.
194+
continue
195+
196+
if len(model_node) != 1:
197+
# there should be exactly one type folder under the name folder
198+
ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-12117', type_name, model_name,
199+
len(model_node))
200+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
201+
raise ex
202+
203+
# custom providers require special processing, they are not described in alias framework
204+
if allow_custom and (model_name not in known_providers):
205+
self.custom_folder_helper.update_security_folder(location, model_name, model_node)
206+
continue
207+
208+
# for a known provider, process using aliases
183209
prov_location = LocationContext(location)
184210
name = self.wlst_helper.get_quoted_name_for_wlst(model_name)
185211
if token_name is not None:
186212
prov_location.add_name_token(token_name, name)
187213

188214
wlst_base_provider_type, wlst_name = self.alias_helper.get_wlst_mbean_type_and_name(prov_location)
189-
model_node = model_nodes[model_name]
190-
if model_node is not None:
191-
if len(model_node) == 1:
192-
model_type_subfolder_name = list(model_node.keys())[0]
193-
prov_location.append_location(model_type_subfolder_name)
194-
wlst_type = self.alias_helper.get_wlst_mbean_type(prov_location)
195-
else:
196-
ex = exception_helper.create_create_exception('WLSDPLY-12117', type_name,
197-
model_name, len(model_node))
198-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
199-
raise ex
200-
else:
201-
# The node is empty so nothing to do...move to the next named node.
202-
continue
215+
216+
model_type_subfolder_name = list(model_node.keys())[0]
217+
prov_location.append_location(model_type_subfolder_name)
218+
wlst_type = self.alias_helper.get_wlst_mbean_type(prov_location)
203219

204220
if wlst_name not in existing_folder_names:
205221
if log_created:

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55

@@ -35,10 +35,7 @@
3535
from wlsdeploy.aliases.model_constants import SECURITY_CONFIGURATION
3636
from wlsdeploy.tool.create.creator import Creator
3737
from wlsdeploy.tool.deploy import deployer_utils
38-
from wlsdeploy.tool.util.alias_helper import AliasHelper
39-
from wlsdeploy.tool.util.wlst_helper import WlstHelper
4038
from wlsdeploy.util import dictionary_utils
41-
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4239

4340

4441
class SecurityProviderCreator(Creator):
@@ -51,11 +48,6 @@ class SecurityProviderCreator(Creator):
5148
def __init__(self, model_dictionary, model_context, aliases, exception_type, logger):
5249
Creator.__init__(self, model_dictionary, model_context, aliases, exception_type, logger)
5350

54-
self.logger = logger
55-
self.alias_helper = AliasHelper(aliases, self.logger, exception_type)
56-
self.wlst_helper = WlstHelper(self.logger, exception_type)
57-
self.wls_helper = WebLogicHelper(self.logger)
58-
5951
self._topology = self.model.get_model_topology()
6052

6153
#

core/src/main/python/wlsdeploy/tool/util/alias_helper.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
from oracle.weblogic.deploy.aliases import AliasException
@@ -275,6 +275,24 @@ def is_artificial_type_folder(self, location):
275275
raise ex
276276
return result
277277

278+
def is_custom_folder_allowed(self, location):
279+
"""
280+
Returns true if the specified location allows custom, user-defined folder types.
281+
:param location: the location to be checked
282+
:return: True, if the location allows custom folder types, False otherwise
283+
:raises: BundleAwareException of the specified type: if an error occurs
284+
"""
285+
_method_name = 'is_custom_folder_allowed'
286+
287+
try:
288+
result = self.__aliases.is_custom_folder_allowed(location)
289+
except AliasException, ae:
290+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19035', str(location),
291+
ae.getLocalizedMessage(), error=ae)
292+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
293+
raise ex
294+
return result
295+
278296
def get_wlst_mbean_name(self, location):
279297
"""
280298
Get the MBean name to use to create it for the specified location.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import os
@@ -670,6 +670,9 @@ def __process_model_node(self, model_node, validation_location, validation_resul
670670
model_folder_path,
671671
validation_location,
672672
validation_result)
673+
elif self._alias_helper.is_custom_folder_allowed(validation_location):
674+
# custom folders are not validated, just log this and continue
675+
self._logger.info('WLSDPLY-05037', model_folder_path)
673676
else:
674677
# At this point we know that key IS NOT a valid attribute or folder, meaning
675678
# that given the location object, it is NOT:

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ WLSDPLY-05033=Attribute {0} in model location {1} should be a string but was a {
351351
WLSDPLY-05034=The value for attribute {0} in model location {1} should be a string or a list but was a {2}
352352
WLSDPLY-05035=The {0} attribute with value {1} in model location {2}, should be a string but was a {3}
353353
WLSDPLY-05036=Attribute {0} in model location {1}, uses the {2} macro expression for an integer or references to other another server template configuration element. The Oracle documentation for server templates, cites this as being not supported.
354+
WLSDPLY-05037=Custom folder {0} will not be validated
354355

355356

356357
# wlsdeploy/tools/validate/usage_printer.py
@@ -948,6 +949,7 @@ WLSDPLY-12122=The attribute {0} in model location {1} has value {2} that referen
948949
archive file but the archive file was not provided
949950
# The WLSDPLY-12123 resource is used for messages returned from aliases.is_version_valid_location()
950951
WLSDPLY-12123={0}
952+
WLSDPLY-12124=Updating custom security folder {0} at location {1}
951953

952954
# domain_creator.py
953955
WLSDPLY-12200={0} did not find the required {1} section in the model file {2}
@@ -1095,6 +1097,7 @@ WLSDPLY-19032=Failed to get the default value for model attribute {0} at locatio
10951097
WLSDPLY-19033=Failed to determine if location ({0}) is version valid, or not
10961098
WLSDPLY-19034=Failed to get the model attribute list that require a special processing via a method for model \
10971099
folder ({0}) at location ({1}): {2}
1100+
WLSDPLY-19035=Failed to determine if the location ({0}) allows custom folder types: {1}
10981101

10991102
# wlsdeploy/tool/util/wlst_helper.py
11001103
WLSDPLY-19100=Failed to change to the WLST directory {0}: {1}

0 commit comments

Comments
 (0)