Skip to content

Commit 23029b7

Browse files
authored
Merge pull request #282 from oracle/issue-281-security-config-default-realm
Issue #281 - Fix MBean lookup for SecurityConfiguration/DefaultRealm …
2 parents b3768d3 + efdf20c commit 23029b7

File tree

6 files changed

+72
-18
lines changed

6 files changed

+72
-18
lines changed

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ def _create_named_mbeans(self, type_name, model_nodes, base_location, log_create
9696
self.wlst_helper.cd(attribute_path)
9797

9898
child_nodes = dictionary_utils.get_dictionary_element(model_nodes, name)
99-
self.logger.finest('WLSDPLY-12111', self.alias_helper.get_model_folder_path(location),
100-
self.wlst_helper.get_pwd(), class_name=self.__class_name, method_name=_method_name)
101-
self._set_attributes(location, child_nodes)
102-
self._create_subfolders(location, child_nodes)
99+
self._process_child_nodes(location, child_nodes)
103100

104101
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
105102
return
@@ -158,10 +155,7 @@ def _create_mbean(self, type_name, model_nodes, base_location, log_created=False
158155
attribute_path = self.alias_helper.get_wlst_attributes_path(location)
159156
self.wlst_helper.cd(attribute_path)
160157

161-
self.logger.finest('WLSDPLY-12111', self.alias_helper.get_model_folder_path(location),
162-
self.wlst_helper.get_pwd(), class_name=self.__class_name, method_name=_method_name)
163-
self._set_attributes(location, model_nodes)
164-
self._create_subfolders(location, model_nodes)
158+
self._process_child_nodes(location, model_nodes)
165159
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
166160
return
167161

@@ -219,6 +213,22 @@ def _create_subfolders(self, location, model_nodes):
219213
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
220214
return
221215

216+
def _process_child_nodes(self, location, model_nodes):
217+
"""
218+
Process the model nodes at the specified location.
219+
The default behavior is to process attributes, then sub-folders.
220+
Sub-classes may override to reverse this order, or for other special processing.
221+
:param location: the location where the nodes should be applied
222+
:param model_nodes: the model dictionary of the nodes to be applied
223+
:raises: CreateException: if an error occurs
224+
"""
225+
_method_name = '_process_child_nodes'
226+
227+
self.logger.finest('WLSDPLY-12111', self.alias_helper.get_model_folder_path(location),
228+
self.wlst_helper.get_pwd(), class_name=self.__class_name, method_name=_method_name)
229+
self._set_attributes(location, model_nodes)
230+
self._create_subfolders(location, model_nodes)
231+
222232
def _set_attributes(self, location, model_nodes):
223233
"""
224234
Set the attributes for the MBean at the specified location.

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from oracle.weblogic.deploy.exception import BundleAwareException
77

88
from wlsdeploy.aliases.location_context import LocationContext
9+
from wlsdeploy.aliases.model_constants import REALM
910
from wlsdeploy.aliases.model_constants import SECURITY_CONFIGURATION
1011
from wlsdeploy.exception import exception_helper
1112
from wlsdeploy.tool.create.creator import Creator
@@ -186,6 +187,31 @@ def _create_named_subtype_mbeans(self, type_name, model_nodes, base_location, lo
186187
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
187188
return
188189

190+
# Override
191+
def _process_child_nodes(self, location, model_nodes):
192+
"""
193+
Process the model nodes at the specified location.
194+
Override default behavior to process security configuration and realm sub-folders before attributes.
195+
Security configration attribute DefaultRealm needs to get the MBean of the referenced realm.
196+
Realm attribute CertPathBuilder needs to get the MBean of the referenced certificate registry.
197+
:param location: the location where the nodes should be processed
198+
:param model_nodes: the model dictionary of the nodes to be processed
199+
:raises: CreateException: if an error occurs
200+
"""
201+
_method_name = '_process_child_nodes'
202+
203+
model_type, model_name = self.alias_helper.get_model_type_and_name(location)
204+
if model_type in [SECURITY_CONFIGURATION, REALM]:
205+
self.logger.finest('WLSDPLY-12143', self.alias_helper.get_model_folder_path(location),
206+
self.wlst_helper.get_pwd(), class_name=self.__class_name, method_name=_method_name)
207+
208+
self._create_subfolders(location, model_nodes)
209+
self.wlst_helper.cd(self.alias_helper.get_wlst_attributes_path(location))
210+
self._set_attributes(location, model_nodes)
211+
return
212+
213+
Creator._process_child_nodes(self, location, model_nodes)
214+
189215
def _delete_existing_providers(self, location):
190216
"""
191217
The security realms providers in the model are processed as merge to the model. Each realm provider

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

Lines changed: 19 additions & 3 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
from sets import Set
@@ -19,6 +19,7 @@
1919
from wlsdeploy.tool.util.wlst_helper import WlstHelper
2020

2121
from wlsdeploy.aliases.model_constants import CAPACITY
22+
from wlsdeploy.aliases.model_constants import CERT_PATH_PROVIDER
2223
from wlsdeploy.aliases.model_constants import CLUSTER
2324
from wlsdeploy.aliases.model_constants import COHERENCE_CLUSTER_SYSTEM_RESOURCE
2425
from wlsdeploy.aliases.model_constants import CONTEXT_REQUEST_CLASS
@@ -497,7 +498,7 @@ def set_mt_target_mbeans(self, location, key, value, wlst_value):
497498
self.set_attribute(location, key, targets_value, wlst_merge_value=wlst_value, use_raw_value=True)
498499
return
499500

500-
def set_partition_security_realm(self, location, key, value, wlst_value):
501+
def set_security_realm_mbean(self, location, key, value, wlst_value):
501502
"""
502503
Set the security realm MBean.
503504
:param location: the location
@@ -511,6 +512,20 @@ def set_partition_security_realm(self, location, key, value, wlst_value):
511512
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
512513
return
513514

515+
def set_certificate_registry_mbean(self, location, key, value, wlst_value):
516+
"""
517+
Set the certificate registry MBean.
518+
:param location: the location
519+
:param key: the attribute name
520+
:param value: the string value
521+
:param wlst_value: the existing value of the attribute from WLST
522+
:raises BundleAwareException of the specified type: if target is not found
523+
"""
524+
realm_location = self.__get_parent_location(location, REALM)
525+
mbean = self.__find_in_location(realm_location, CERT_PATH_PROVIDER, value, required=True)
526+
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
527+
return
528+
514529
def set_resource_group_template_mbean(self, location, key, value, wlst_value):
515530
"""
516531
Set the resource group template MBean.
@@ -855,7 +870,8 @@ def __find_in_location(self, location, element_type, name, required=False):
855870
return self.__wlst_helper.get_mbean_for_wlst_path(path)
856871

857872
if required:
858-
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19202', element_type, name)
873+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19210', element_type, name,
874+
self.__alias_helper.get_model_folder_path(location))
859875
self.__logger.throwing(class_name=self._class_name, method_name=method_name, error=ex)
860876
raise ex
861877

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/Partition.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"copyright": "Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.",
2+
"copyright": "Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.",
33
"license": "The Universal Permissive License (UPL), Version 1.0",
44
"wlst_type": "Partition${:s}",
55
"version": "[12.2.1,)",
@@ -570,7 +570,7 @@
570570
"PartitionWorkManagerRef": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "PartitionWorkManagerRef", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_partition_work_manager_mbean", "set_mbean_type": "weblogic.management.configuration.PartitionWorkManagerMBean" } ],
571571
"PrimaryIdentityDomain": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "PrimaryIdentityDomain", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string" } ],
572572
"RCMHistoricalDataBufferLimit": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "RCMHistoricalDataBufferLimit", "wlst_path": "WP001", "value": { "default": 250 }, "wlst_type": "integer" } ],
573-
"Realm": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "Realm", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_partition_security_realm", "set_mbean_type": "weblogic.management.security.RealmMBean" } ],
573+
"Realm": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "Realm", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string", "get_method": "LSA", "set_method": "MBEAN.set_security_realm_mbean", "set_mbean_type": "weblogic.management.security.RealmMBean" } ],
574574
"ResourceDeploymentPlan": [ {"version": "[12.2.1,)", "wlst_mode": "online", "wlst_name": "ResourceDeploymentPlan", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string", "access": "RO"} ],
575575
"ResourceDeploymentPlanExternalDescriptors": [ {"version": "[12.2.1,)", "wlst_mode": "online", "wlst_name": "ResourceDeploymentPlanExternalDescriptors", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string", "access": "RO"} ],
576576
"ResourceDeploymentPlanPath": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "ResourceDeploymentPlanPath", "wlst_path": "WP001", "value": { "default": "None" }, "wlst_type": "string", "uses_path_tokens": "true" } ],

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/SecurityConfiguration.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@
969969
},
970970
"wlst_attributes_path": "WP001",
971971
"wlst_paths": {
972-
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/CertPathProvider/%PROVIDER%"
972+
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/CertPathProvider${:s}/%PROVIDER%"
973973
}
974974
},
975975
"WebLogicCertPathProvider": {
@@ -981,14 +981,14 @@
981981
},
982982
"wlst_attributes_path": "WP001",
983983
"wlst_paths": {
984-
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/CertPathProvider/%PROVIDER%"
984+
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/CertPathProvider${:s}/%PROVIDER%"
985985
}
986986
}
987987
},
988988
"attributes" : { },
989989
"wlst_attributes_path": "WP001",
990990
"wlst_paths": {
991-
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/CertPathProvider/%PROVIDER%"
991+
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/CertPathProvider${:s}/%PROVIDER%"
992992
}
993993
},
994994
"CredentialMapper" : {
@@ -1197,7 +1197,7 @@
11971197
"attributes" : {
11981198
"AuthMethods": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AuthMethods", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
11991199
"AutoRestartOnNonDynamicChanges": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "AutoRestartOnNonDynamicChanges", "wlst_path": "WP001", "value": {"default": "false" }, "wlst_type": "boolean" } ],
1200-
"CertPathBuilder": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CertPathBuilder", "wlst_path": "WP001", "value": {"default": "WebLogicCertPathProvider" }, "wlst_type": "string" } ],
1200+
"CertPathBuilder": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CertPathBuilder", "wlst_path": "WP001", "value": {"default": "WebLogicCertPathProvider" }, "wlst_type": "string", "set_method": "MBEAN.set_certificate_registry_mbean", "set_mbean_type": "weblogic.security.providers.pk.CertificateRegistryMBean" } ],
12011201
"CombinedRoleMappingEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CombinedRoleMappingEnabled", "wlst_path": "WP001", "value": {"default": "true" }, "wlst_type": "boolean" } ],
12021202
"CompatibilityObjectName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CompatibilityObjectName", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
12031203
"DelegateMBeanAuthorization": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DelegateMBeanAuthorization", "wlst_path": "WP001", "value": {"default": "false" }, "wlst_type": "boolean" } ],
@@ -1260,7 +1260,7 @@
12601260
"CredentialEncrypted": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CredentialEncrypted", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "password", "get_method": "GET"} ],
12611261
"CredentialGenerated": [ {"version": "[10,)", "wlst_mode": "online", "wlst_name": "CredentialGenerated", "wlst_path": "WP001", "value": {"default": "false" }, "wlst_type": "boolean", "get_method": "GET", "restart_required": "true"} ],
12621262
"CrossDomainSecurityEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "CrossDomainSecurityEnabled", "wlst_path": "WP001", "value": {"default": "false" }, "wlst_type": "boolean" } ],
1263-
"DefaultRealm": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DefaultRealm", "wlst_path": "WP001", "value": {"default": "myrealm" }, "wlst_type": "string", "get_method": "${LSA:GET}", "set_method": "MBEAN.set_server_mbean", "set_mbean_type": "weblogic.management.configuration.SecurityMBean", "restart_required": "true" } ],
1263+
"DefaultRealm": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DefaultRealm", "wlst_path": "WP001", "value": {"default": "myrealm" }, "wlst_type": "string", "get_method": "${LSA:GET}", "set_method": "MBEAN.set_security_realm_mbean", "set_mbean_type": "weblogic.management.configuration.SecurityMBean", "restart_required": "true" } ],
12641264
"DefaultRealmInternal": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "DefaultRealmInternal", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
12651265
"DowngradeUntrustedPrincipals": [ {"version": "[10,12.2.1)", "wlst_mode": "both", "wlst_name": "DowngradeUntrustedPrincipals", "wlst_path": "WP001", "value": {"default": "false" }, "wlst_type": "boolean", "restart_required": "true" } ,
12661266
{"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "DowngradeUntrustedPrincipals", "wlst_path": "WP001", "value": {"default": "false" }, "wlst_type": "boolean" } ],

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ WLSDPLY-12139=Security configuration adjudicator name is {0}
986986
WLSDPLY-12140=Security configuration adjudicator has {0} subtypes
987987
WLSDPLY-12141=Security configuration adjudicator subtype is {0}
988988
WLSDPLY-12142=Security configuration adjudicator has {0} attributes
989+
WLSDPLY-12143=Setting subfolders, then attributes for model location path {0} from WLST path {1}
989990

990991
# domain_creator.py
991992
WLSDPLY-12200={0} did not find the required {1} section in the model file {2}
@@ -1200,6 +1201,7 @@ WLSDPLY-19206=Unable to locate partition work manager {0} for partition {1}
12001201
WLSDPLY-19207=Unable to locate resource manager {0} for partition {1}
12011202
WLSDPLY-19208=Unable to locate log filter {0} for log at location {1}
12021203
WLSDPLY-19209=Assign {0} {1} to {2} {3}
1204+
WLSDPLY-19210={0} {1} not found in location {2}
12031205

12041206
# wlsdeploy/tool/util/archive_helper.py
12051207
WLSDPLY-19300=Failed to open archive file {0}: {1}

0 commit comments

Comments
 (0)