Skip to content

Commit c28f07b

Browse files
Merge pull request #271 from oracle/jira-wdt-257-skip-adjudicators
WDT-257 - Don't create or update security configuration adjudicators.
2 parents d883fa3 + ee04e27 commit c28f07b

File tree

3 files changed

+258
-218
lines changed

3 files changed

+258
-218
lines changed

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

Lines changed: 38 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
from oracle.weblogic.deploy.util import WLSDeployArchive
7-
from oracle.weblogic.deploy.exception import BundleAwareException
87

98
from wlsdeploy.aliases.location_context import LocationContext
109
from wlsdeploy.aliases.validation_codes import ValidationCodes
@@ -166,97 +165,56 @@ def _create_mbean(self, type_name, model_nodes, base_location, log_created=False
166165
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
167166
return
168167

169-
def _create_security_provider_mbeans(self, type_name, model_nodes, base_location, log_created=False):
168+
def _create_named_subtype_mbeans(self, type_name, model_nodes, base_location, log_created=False):
170169
"""
171-
Create the specified security provider MBean types that support multiple instances but use an
172-
artificial type subfolder in the specified location.
170+
Create the specified type of MBeans that support multiple instances, and require an artificial subtype
171+
layer after each name.
172+
There is no default behavior for this method. Sub-classes (currently only SecurityProviderCreator) will
173+
implement specialized behavior.
173174
:param type_name: the model folder type
174175
:param model_nodes: the model dictionary of the specified model folder type
175176
:param base_location: the base location object to use to create the MBeans
176177
:param log_created: whether or not to log created at INFO level, by default it is logged at the FINE level
177178
:raises: CreateException: if an error occurs
178179
"""
179-
_method_name = '_create_security_provider_mbeans'
180-
181-
self.logger.entering(type_name, str(base_location), log_created,
182-
class_name=self.__class_name, method_name=_method_name)
183-
if not self._is_type_valid(base_location, type_name):
184-
return
185-
186-
location = LocationContext(base_location).append_location(type_name)
187-
self._process_flattened_folder(location)
188-
189-
# For create, delete the existing nodes, and re-add in order found in model in iterative code below
190-
self._delete_existing_providers(location)
191-
192-
if model_nodes is None or len(model_nodes) == 0:
193-
return
194-
195-
token_name = self.alias_helper.get_name_token(location)
196-
create_path = self.alias_helper.get_wlst_create_path(location)
197-
list_path = self.alias_helper.get_wlst_list_path(location)
198-
existing_folder_names = self._get_existing_folders(list_path)
199-
known_providers = self.alias_helper.get_model_subfolder_names(location)
200-
allow_custom = str(self.alias_helper.is_custom_folder_allowed(location))
201-
202-
for model_name in model_nodes:
203-
model_node = model_nodes[model_name]
204-
205-
if model_node is None:
206-
# The node is empty so nothing to do... move to the next named node.
207-
continue
208-
209-
if len(model_node) != 1:
210-
# there should be exactly one type folder under the name folder
211-
ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-12117', type_name, model_name,
212-
len(model_node))
213-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
214-
raise ex
215-
216-
model_type_subfolder_name = list(model_node.keys())[0]
217-
child_nodes = dictionary_utils.get_dictionary_element(model_node, model_type_subfolder_name)
218-
219-
# custom providers require special processing, they are not described in alias framework
220-
if allow_custom and (model_type_subfolder_name not in known_providers):
221-
self.custom_folder_helper.update_security_folder(base_location, type_name, model_type_subfolder_name,
222-
model_name, child_nodes)
223-
continue
180+
return
224181

225-
# for a known provider, process using aliases
226-
prov_location = LocationContext(location)
227-
name = self.wlst_helper.get_quoted_name_for_wlst(model_name)
228-
if token_name is not None:
229-
prov_location.add_name_token(token_name, name)
182+
def _create_subfolders(self, location, model_nodes):
183+
"""
184+
Create the child MBean folders at the specified location.
185+
:param location: the location
186+
:param model_nodes: the model dictionary
187+
:raises: CreateException: if an error occurs
188+
"""
189+
_method_name = '_create_subfolders'
230190

231-
wlst_base_provider_type, wlst_name = self.alias_helper.get_wlst_mbean_type_and_name(prov_location)
191+
self.logger.entering(location.get_folder_path(), class_name=self.__class_name, method_name=_method_name)
192+
model_subfolder_names = self.alias_helper.get_model_subfolder_names(location)
193+
for key in model_nodes:
194+
if key in model_subfolder_names:
195+
subfolder_nodes = model_nodes[key]
196+
# don't check for empty subfolder nodes here, some create methods allow them
232197

233-
prov_location.append_location(model_type_subfolder_name)
234-
wlst_type = self.alias_helper.get_wlst_mbean_type(prov_location)
198+
sub_location = LocationContext(location).append_location(key)
235199

236-
if wlst_name not in existing_folder_names:
237-
if log_created:
238-
self.logger.info('WLSDPLY-12118', type_name, model_type_subfolder_name, name, create_path,
239-
class_name=self.__class_name, method_name=_method_name)
240-
else:
241-
self.logger.fine('WLSDPLY-12118', type_name, model_type_subfolder_name, name, create_path,
242-
class_name=self.__class_name, method_name=_method_name)
243-
self.wlst_helper.cd(create_path)
244-
self.wlst_helper.create(wlst_name, wlst_type, wlst_base_provider_type)
245-
else:
246-
if log_created:
247-
self.logger.info('WLSDPLY-12119', type_name, model_type_subfolder_name, name, create_path,
248-
class_name=self.__class_name, method_name=_method_name)
200+
if self.alias_helper.requires_artificial_type_subfolder_handling(sub_location):
201+
self.logger.finest('WLSDPLY-12116', key, str(sub_location), subfolder_nodes,
202+
class_name=self.__class_name, method_name=_method_name)
203+
self._create_named_subtype_mbeans(key, subfolder_nodes, location, True)
204+
elif self.alias_helper.supports_multiple_mbean_instances(sub_location):
205+
self.logger.finest('WLSDPLY-12109', key, str(sub_location), subfolder_nodes,
206+
class_name=self.__class_name, method_name=_method_name)
207+
self._create_named_mbeans(key, subfolder_nodes, location)
208+
elif self.alias_helper.is_artificial_type_folder(sub_location):
209+
# these should have been handled inside create_named_subtype_mbeans
210+
ex = exception_helper.create_create_exception('WLSDPLY-12120', str(sub_location),
211+
key, str(location))
212+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
213+
raise ex
249214
else:
250-
self.logger.fine('WLSDPLY-12119', type_name, model_type_subfolder_name, name, create_path,
251-
class_name=self.__class_name, method_name=_method_name)
252-
253-
attribute_path = self.alias_helper.get_wlst_attributes_path(prov_location)
254-
self.wlst_helper.cd(attribute_path)
255-
256-
self.logger.finest('WLSDPLY-12111', self.alias_helper.get_model_folder_path(prov_location),
257-
self.wlst_helper.get_pwd(), class_name=self.__class_name, method_name=_method_name)
258-
self._set_attributes(prov_location, child_nodes)
259-
self._create_subfolders(prov_location, child_nodes)
215+
self.logger.finest('WLSDPLY-12110', key, str(sub_location), subfolder_nodes,
216+
class_name=self.__class_name, method_name=_method_name)
217+
self._create_mbean(key, subfolder_nodes, location)
260218

261219
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
262220
return
@@ -382,44 +340,6 @@ def _set_attribute(self, location, model_name, model_value, uses_path_tokens_nam
382340
self.wlst_helper.set(wlst_name, wlst_value, masked=masked)
383341
return
384342

385-
def _create_subfolders(self, location, model_nodes):
386-
"""
387-
Create the child MBean folders at the specified location.
388-
:param location: the location
389-
:param model_nodes: the model dictionary
390-
:raises: CreateException: if an error occurs
391-
"""
392-
_method_name = '_create_subfolders'
393-
394-
self.logger.entering(location.get_folder_path(), class_name=self.__class_name, method_name=_method_name)
395-
model_subfolder_names = self.alias_helper.get_model_subfolder_names(location)
396-
for key in model_nodes:
397-
if key in model_subfolder_names:
398-
subfolder_nodes = model_nodes[key]
399-
sub_location = LocationContext(location).append_location(key)
400-
# both create and update are merge to model so will process a subfolder with an empty node
401-
if self.alias_helper.requires_artificial_type_subfolder_handling(sub_location):
402-
self.logger.finest('WLSDPLY-12116', key, str(sub_location), subfolder_nodes,
403-
class_name=self.__class_name, method_name=_method_name)
404-
self._create_security_provider_mbeans(key, subfolder_nodes, location, True)
405-
elif len(subfolder_nodes) != 0:
406-
if self.alias_helper.supports_multiple_mbean_instances(sub_location):
407-
self.logger.finest('WLSDPLY-12109', key, str(sub_location), subfolder_nodes,
408-
class_name=self.__class_name, method_name=_method_name)
409-
self._create_named_mbeans(key, subfolder_nodes, location)
410-
elif self.alias_helper.is_artificial_type_folder(sub_location):
411-
ex = exception_helper.create_create_exception('WLSDPLY-12120', str(sub_location),
412-
key, str(location))
413-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
414-
raise ex
415-
else:
416-
self.logger.finest('WLSDPLY-12110', key, str(sub_location), subfolder_nodes,
417-
class_name=self.__class_name, method_name=_method_name)
418-
self._create_mbean(key, subfolder_nodes, location)
419-
420-
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
421-
return
422-
423343
def _is_type_valid(self, location, type_name):
424344
"""
425345
Verify that the specified location in valid for the current WLS version.
@@ -457,62 +377,6 @@ def _process_flattened_folder(self, location):
457377
self.wlst_helper.create(mbean_name, mbean_type)
458378
return
459379

460-
def _delete_existing_providers(self, location):
461-
"""
462-
The security realms providers in the model are processed as merge to the model. Each realm provider
463-
section must be complete and true to the resulting domain. Any existing provider not found in the
464-
model will be removed, and any provider in the model but not in the domain will be added. The resulting
465-
provider list will be ordered as listed in the model. If the provider type (i.e. AuthenticationProvider)
466-
is not in the model, it is assumed no configuration or ordering is needed, and the provider is skipped.
467-
If the provider type is in the model, but there is no MBean entry under the provider, then it is
468-
assumed that all providers for that provider type must be removed.
469-
470-
For create, the default realm and default providers have been added by the weblogic base template and any
471-
extension templates. They have default values. These providers will be removed from the domain. During
472-
the normal iteration through the provider list, the providers, if in the model, will be re-added in model
473-
order. Any attributes in the model that are not the default value are then applied to the the new provider.
474-
475-
By deleting all providers and re-adding from the model, we are both merging to the model and ordering the
476-
providers. In offline wlst, the set<providertype>Providers(<provider_object_list>, which reorders existing
477-
providers, does not work. Deleting the providers and re-adding also has the added benefit of fixing the 11g
478-
problem where the providers have no name. They are returned with the name 'Provider'. In the authentication
479-
provider, there are two default providers, and just setting the name does not work. When we re-add we re-add
480-
with the correct name. And the DefaultAuthenticationProvider successfully re-adds with the correct default
481-
identity asserter.
482-
483-
This release also supports updating the security configuration realms in both offline and online mode. This
484-
release requires a complete list of providers as described in the first paragraph.
485-
486-
:param location: current context of the location pointing at the provider mbean
487-
"""
488-
_method_name = '_delete_existing_providers'
489-
self.logger.entering(location.get_folder_path(), class_name=self.__class_name, method_name=_method_name)
490-
491-
list_path = self.alias_helper.get_wlst_list_path(location)
492-
existing_folder_names = self._get_existing_folders(list_path)
493-
wlst_base_provider_type = self.alias_helper.get_wlst_mbean_type(location)
494-
if len(existing_folder_names) == 0:
495-
self.logger.finer('WLSDPLY-12136', wlst_base_provider_type, list_path, class_name=self.__class_name,
496-
method_name=_method_name)
497-
else:
498-
create_path = self.alias_helper.get_wlst_create_path(location)
499-
self.wlst_helper.cd(create_path)
500-
for existing_folder_name in existing_folder_names:
501-
try:
502-
self.logger.info('WLSDPLY-12135', existing_folder_name, wlst_base_provider_type, create_path,
503-
class_name=self.__class_name, method_name=_method_name)
504-
self.wlst_helper.delete(existing_folder_name, wlst_base_provider_type)
505-
except BundleAwareException, bae:
506-
ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-12134', existing_folder_name,
507-
self.wls_helper.get_weblogic_version(),
508-
wlst_base_provider_type, bae.getLocalizedMessage(),
509-
error=bae)
510-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
511-
raise ex
512-
513-
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
514-
return
515-
516380
def _get_existing_folders(self, wlst_path):
517381
"""
518382
Get the list of existing folders at the specified WLST path.

0 commit comments

Comments
 (0)