Skip to content

Commit 360f2d6

Browse files
Fix for User password that was encrypted incorrectly (#915)
1 parent 07cb586 commit 360f2d6

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Copyright (c) 2021, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
5-
import com.bea.common.security.utils.encoders.BASE64Encoder as BASE64Encoder
5+
import com.octetstring.vde.util.PasswordEncryptor as PasswordEncryptor
66
import com.bea.security.xacml.cache.resource.ResourcePolicyIdUtil as ResourcePolicyIdUtil
77
from java.io import File
88
from java.lang import String
9+
import java.util.regex.Pattern as Pattern
910

1011
import oracle.weblogic.deploy.aliases.TypeUtils as TypeUtils
1112

@@ -48,7 +49,6 @@ def __init__(self, model_context, exception_type):
4849
self._logger = PlatformLogger('wlsdeploy.tool.util')
4950
self._weblogic_helper = WebLogicHelper(self._logger)
5051
self._resource_escaper = ResourcePolicyIdUtil.getEscaper()
51-
self._b64_encoder = BASE64Encoder()
5252

5353
def create_default_init_file(self, security_mapping_nodes):
5454
"""
@@ -135,8 +135,7 @@ def _build_user_mapping_hash(self, user_mapping_section, name):
135135
hash_entry[HASH_DESCRIPTION] = description
136136
groups = dictionary_utils.get_element(group_attributes, GROUP_MEMBER_OF)
137137
password = self._get_required_attribute(user_mapping_section, PASSWORD, USER, name)
138-
encrypted = self._weblogic_helper.encrypt(password, self._model_context.get_domain_home())
139-
password_encoded = self._b64_encoder.encodeBuffer(String(encrypted).getBytes("UTF-8"))
138+
password_encoded = self._encode_password(name, password)
140139
hash_entry[HASH_USER_PASSWORD] = password_encoded
141140
group_list = []
142141
group_mappings = list()
@@ -150,6 +149,20 @@ def _build_user_mapping_hash(self, user_mapping_section, name):
150149

151150
return hash_entry
152151

152+
def _encode_password(self, user, password):
153+
pwdPattern = '[\\!a-zA-Z]{1,}'
154+
matches = Pattern.matches(pwdPattern, password)
155+
if len(password) < 8 or matches:
156+
self._logger.warning('WLSDPLY-01902', user)
157+
return None
158+
try:
159+
encryptedPass = PasswordEncryptor.doSSHA256(password)
160+
encryptedPass = "{ssha256}" + encryptedPass
161+
except Exception, e:
162+
self._logger.warning('WLSDPLY-01901', user, e)
163+
return None
164+
return encryptedPass
165+
153166
def _get_required_attribute(self, dictionary, name, mapping_type, mapping_name):
154167
"""
155168
Return the value of the specified attribute from the specified dictionary.

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
@@ -390,6 +390,8 @@ WLSDPLY-01791=Attribute "{0}" is required for {1} credential mapping {2}
390390

391391
# wlsdeploy/tool/util/default_authenticator_helper.py
392392
WLSDPLY-01900=Append to default authenticator initialization file {0}
393+
WLSDPLY-01902=Invalid password for user {0}. Must be at least 8 characters and contain one number.
394+
WLSDPLY-01901=Exception encrypting user {0} password : {1}
393395
###############################################################################
394396
# Encrypt Messages (04000 - 04999) #
395397
###############################################################################

0 commit comments

Comments
 (0)