|
6 | 6 | from oracle.weblogic.deploy.util import WLSDeployArchive
|
7 | 7 |
|
8 | 8 | from wlsdeploy.aliases.location_context import LocationContext
|
| 9 | +from wlsdeploy.aliases.model_constants import SECURITY_CONFIGURATION |
9 | 10 | from wlsdeploy.aliases.validation_codes import ValidationCodes
|
10 | 11 | from wlsdeploy.exception import exception_helper
|
11 | 12 | from wlsdeploy.exception.expection_types import ExceptionType
|
@@ -186,9 +187,14 @@ def _create_security_provider_mbeans(self, type_name, model_nodes, base_location
|
186 | 187 | known_providers = self.alias_helper.get_model_subfolder_names(location)
|
187 | 188 | allow_custom = str(self.alias_helper.is_custom_folder_allowed(location))
|
188 | 189 |
|
| 190 | + # For create, delete the existing nodes, and re-add in order found in model in iterative code below |
| 191 | + self._delete_existing_providers(location) |
| 192 | + |
189 | 193 | for model_name in model_nodes:
|
190 | 194 | model_node = model_nodes[model_name]
|
191 | 195 |
|
| 196 | + # Need to create the node first ? |
| 197 | + self.logger.fine('Adding the provider {0} at location {1}', model_name, str(location)) |
192 | 198 | if model_node is None:
|
193 | 199 | # The node is empty so nothing to do... move to the next named node.
|
194 | 200 | continue
|
@@ -383,6 +389,7 @@ def _create_subfolders(self, location, model_nodes):
|
383 | 389 |
|
384 | 390 | for key in model_nodes:
|
385 | 391 | if key in model_subfolder_names:
|
| 392 | + |
386 | 393 | subfolder_nodes = model_nodes[key]
|
387 | 394 | if len(subfolder_nodes) != 0:
|
388 | 395 | sub_location = LocationContext(location).append_location(key)
|
@@ -443,6 +450,50 @@ def _process_flattened_folder(self, location):
|
443 | 450 | self.wlst_helper.create(mbean_name, mbean_type)
|
444 | 451 | return
|
445 | 452 |
|
| 453 | + def _delete_existing_providers(self, location): |
| 454 | + """ |
| 455 | + The security realms providers in the model are processed as merge to the model. Each realm provider |
| 456 | + section must be complete and true to the resulting domain. Any existing provider not found in the |
| 457 | + model will be removed, and any provider in the model but not in the domain will be added. The resulting |
| 458 | + provider list will be ordered as listed in the model. |
| 459 | +
|
| 460 | + For create, the default realm and default providers have been added by the weblogic base template and any |
| 461 | + extension templates. They have default values. These providers will be removed from the domain. During |
| 462 | + the normal iteration through the provider list, the providers, if in the model, will be re-added in model |
| 463 | + order. Any attributes in the model that are not the default value are then applied to the the new provider. |
| 464 | +
|
| 465 | + By deleting all providers and re-adding from the model, we are both merging to the model and ordering the |
| 466 | + providers. In offline wlst, the set<providertype>Providers(<provider_object_list>, which reorders existing |
| 467 | + providers, does not work. Deleting the providers and re-adding also has the added benefit of fixing the 11g |
| 468 | + problem where the providers have no name. They are returned with the name 'Provider'. In the authentication |
| 469 | + provider, there are two default providers, and just setting the name does not work. When we re-add we re-add |
| 470 | + with the correct name. And the DefaultAuthenticationProvider successfully re-adds with the correct default |
| 471 | + identity asserter. |
| 472 | +
|
| 473 | + This release does not support updating the provider list. Because this means that the realms cannot be |
| 474 | + configured accurately, the security configuration is not configured. It is in the original configuration |
| 475 | + applied by the templates. |
| 476 | +
|
| 477 | + :param location: current context of the location pointing at the provider mbean |
| 478 | + """ |
| 479 | + _method_name = '_delete_existing_providers' |
| 480 | + self.logger.entering(str(location), class_name=self.__class_name, method_name=_method_name) |
| 481 | + |
| 482 | + list_path = self.alias_helper.get_wlst_list_path(location) |
| 483 | + existing_folder_names = self._get_existing_folders(list_path) |
| 484 | + wlst_base_provider_type, wlst_name = self.alias_helper.get_wlst_mbean_type_and_name(location) |
| 485 | + if len(existing_folder_names) == 0: |
| 486 | + self.logger.finer('No default providers installed for {0} at {1}', wlst_base_provider_type, list_path) |
| 487 | + else: |
| 488 | + create_path = self.alias_helper.get_wlst_create_path(location) |
| 489 | + self.wlst_helper.cd(create_path) |
| 490 | + for existing_folder_name in existing_folder_names: |
| 491 | + self.wlst_helper.delete(existing_folder_name, wlst_base_provider_type) |
| 492 | + self.logger.finer('Removed default provider {0} from provider {1} at location {2}', |
| 493 | + existing_folder_name, wlst_base_provider_type, create_path) |
| 494 | + self.logger.exiting(class_name=self.__class_name, method_name=_method_name) |
| 495 | + return |
| 496 | + |
446 | 497 | def _get_existing_folders(self, wlst_path):
|
447 | 498 | """
|
448 | 499 | Get the list of existing folders at the specified WLST path.
|
|
0 commit comments