Skip to content

Commit 264dba7

Browse files
Merge pull request #289 from oracle/jira-wdt-265-custom-provider-password
JIRA WDT-265 - Pass byte array property values correctly; encrypt pla…
2 parents d79180e + 3e54cdc commit 264dba7

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

core/src/main/java/oracle/weblogic/deploy/util/CustomBeanUtils.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.lang.reflect.Array;
1111
import java.lang.reflect.InvocationTargetException;
1212
import java.lang.reflect.Method;
13+
import java.nio.charset.StandardCharsets;
1314
import java.util.List;
1415

1516
/**
@@ -25,9 +26,10 @@ private CustomBeanUtils() {
2526
* Invoke the specified set method on the MBean with the provided value, converted to the desired type.
2627
* The conversion and invocation are done together to avoid automatic Jython data conversion.
2728
*
28-
* @param mbean the value to be converted
29+
* @param mbean the MBean containing the value to be set
30+
* @param method the method to be called on the specified MBean
2931
* @param propertyType the class representing the target type
30-
* @param propertyValue the class representing the target type
32+
* @param propertyValue the value to be converted and set
3133
* @throws IllegalAccessException if method invocation fails
3234
* @throws IllegalArgumentException if the data conversion or method invocation fails
3335
* @throws InvocationTargetException if method invocation fails
@@ -168,6 +170,9 @@ private static Object convertSingleValue(Object value, Class<?> dataType) {
168170
} else if(dataType == Character.class) {
169171
result = TypeUtils.convertToCharacter(textValue);
170172

173+
} else if(dataType == byte[].class) {
174+
result = textValue.getBytes(StandardCharsets.UTF_8);
175+
171176
} else {
172177
String message = ExceptionHelper.getMessage("WLSDPLY-12132", dataType);
173178
throw new IllegalArgumentException(message);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, model, model_context, aliases, exception_type=ExceptionType.C
3838
self.model_context = model_context
3939
self.wls_helper = WebLogicHelper(self.logger)
4040
self.attribute_setter = AttributeSetter(self.aliases, self.logger, exception_type)
41-
self.custom_folder_helper = CustomFolderHelper(self.aliases, self.logger, exception_type)
41+
self.custom_folder_helper = CustomFolderHelper(self.aliases, self.logger, self.model_context, exception_type)
4242

4343
# Must be initialized by the subclass since only it has
4444
# the knowledge required to compute the domain name.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ class CustomFolderHelper(object):
2020
These require special handling, since they do not have alias definitions.
2121
"""
2222
__class_name = 'CustomFolderHelper'
23+
__cipher_text_prefixes = ["{AES}", "{AES-256}"]
2324

24-
def __init__(self, aliases, logger, exception_type):
25+
def __init__(self, aliases, logger, model_context, exception_type):
2526
self.logger = logger
27+
self.model_context = model_context
2628
self.exception_type = exception_type
2729
self.alias_helper = AliasHelper(aliases, self.logger, self.exception_type)
2830
self.weblogic_helper = WebLogicHelper(self.logger)
@@ -107,6 +109,13 @@ def update_security_folder(self, location, model_type, model_subtype, model_name
107109
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
108110
raise ex
109111

112+
# if the property requires encryption, and the value is not encrypted,
113+
# encrypt the value with domain encryption.
114+
115+
requires_encrypted = property_descriptor.getValue('encrypted')
116+
if requires_encrypted and not self.is_encrypted(model_value) and isinstance(model_value, str):
117+
model_value = self.weblogic_helper.encrypt(model_value, self.model_context.get_domain_home())
118+
110119
property_type = parameter_types[0]
111120

112121
# convert the model value to the target type and call the setter with the target value.
@@ -121,3 +130,9 @@ def update_security_folder(self, location, model_type, model_subtype, model_name
121130
str(model_value), ex.getLocalizedMessage(), error=ex)
122131
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
123132
raise ex
133+
134+
def is_encrypted(self, text):
135+
for prefix in self.__cipher_text_prefixes:
136+
if text.startswith(prefix):
137+
return True
138+
return False

0 commit comments

Comments
 (0)