Skip to content

Commit d267dc0

Browse files
Merge branch 'master' into WDT-221-add-jrf-installed-authentication-provider
2 parents 360ac01 + 5e65256 commit d267dc0

File tree

13 files changed

+325
-257
lines changed

13 files changed

+325
-257
lines changed

core/src/main/antlr4/oracle/weblogic/deploy/yaml/Yaml.g4

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fragment ID_START
280280
fragment ID_CONTINUE
281281
: ID_START
282282
| [0-9]
283-
| [. ()]
283+
| [. ()/]
284284
;
285285

286286
// to support variables in IDs that will need to be quoted because of the curly braces
@@ -292,7 +292,7 @@ fragment QUOTED_ID_START
292292

293293
fragment QUOTED_ID_CONTINUE
294294
: ID_CONTINUE
295-
| [@#\-(){}[\]:]
295+
| [@#\-(){}[\]:/]
296296
;
297297

298298
fragment SQUOTED_STRING_CHARS

core/src/main/python/discover.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ def __connect_to_domain(model_context):
289289
try:
290290
wlst_helper.read_domain(model_context.get_domain_home())
291291
except PyWLSTException, wlst_ex:
292+
wls_version = WebLogicHelper(__logger).get_actual_weblogic_version()
292293
ex = exception_helper.create_discover_exception('WLSDPLY-06002', model_context.get_domain_home(),
293-
wlst_ex.getLocalizedMessage(), error=wlst_ex)
294+
wls_version, wlst_ex.getLocalizedMessage(), error=wlst_ex)
294295
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
295296
raise ex
296297

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class JVMArguments(object):
1818

1919
_class_name = 'JVMArguments'
2020
__client_server_regex = re.compile('-client|-server')
21-
__x_args_size_regex = re.compile('(-X(ms|mx|ss|mn) ?)([0-9]+[kmg]? ?)')
21+
__x_args_size_regex = re.compile('(-X(ms|mx|ss|mn) ?)([0-9]+[kmgKMG]? ?)')
2222
__x_args_value_regex = re.compile('(-X[a-zS]+(/[ap])? ?):([\S]+ ?)')
23-
__x_args_other_regex = re.compile('(-X[a-z]+ ?)(=([0-9]+[kmg]? ?))?')
23+
__x_args_other_regex = re.compile('(-X[a-z]+ ?)(=([0-9]+[kmgKMG]? ?))?')
2424
__xx_args_switch_regex = re.compile('-XX:([+-] ?)([a-zA-Z0-9]+ ?)')
2525
__xx_args_value_regex = re.compile('-XX:([a-zA-Z0-9]+ ?)=([\S]+ ?)')
2626
__sys_props_regex = re.compile('-D([a-zA-Z0-9-_.]+ ?)(=([\S]+ ?))?')
2727

28-
__size_regex = re.compile('([0-9]+ ?)([kmg]? ?)')
28+
__size_regex = re.compile('([0-9]+ ?)([kmgKMG]? ?)')
2929
__k_multiplier = 1024
3030
__m_multiplier = 1024 * 1024
3131
__g_multiplier = 1024 * 1024 * 1024
@@ -588,11 +588,11 @@ def __get_size_multiplier(self, multiplier):
588588
"""
589589
if multiplier is None:
590590
result = 1
591-
elif multiplier == 'k':
591+
elif multiplier in ['k', 'K']:
592592
result = self.__k_multiplier
593-
elif multiplier == 'm':
593+
elif multiplier in ['m', 'M']:
594594
result = self.__m_multiplier
595-
elif multiplier == 'g':
595+
elif multiplier in ['g', 'G']:
596596
result = self.__g_multiplier
597597
else:
598598
result = 0

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

+14-6
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,12 @@ def get_number_of_directories_to_strip(desired_path_type, actual_path_type):
663663

664664
def convert_from_type(data_type, value, preferred=None, delimiter=None):
665665
"""
666-
Convert from wlst type
667-
:param data_type: type of data
668-
:param value: value of data
669-
:param preferred: how it should be represented
670-
:param delimiter: for representation
671-
:return: converted type
666+
Convert WLST value to model representation type
667+
:param data_type: the target data type for the model
668+
:param value: value to be converted
669+
:param preferred: the preferred data type to be represented in the model (optional)
670+
:param delimiter: the delimiter for parsing the WLST representation of the data value (optional)
671+
:return: converted value
672672
"""
673673

674674
_method_name = 'convert_from_type'
@@ -835,6 +835,14 @@ def get_dictionary_mode(alias_dict):
835835

836836

837837
def _jconvert_to_type(data_type, value, delimiter):
838+
"""
839+
Convert WLST value to model representation type.
840+
Assumes that empty values and password data types have been converted elsewhere.
841+
:param data_type: the target data type for the model
842+
:param value: value to be converted
843+
:param delimiter: the delimiter for parsing the WLST representation of the data value (optional)
844+
:return: converted value
845+
"""
838846
_method_name = '_jconvert_to_type'
839847
try:
840848
converted = TypeUtils.convertToType(data_type, value, delimiter)

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

+38-174
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)