22Copyright (c) 2021, Oracle Corporation and/or its affiliates.
33Licensed 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
66import com .bea .security .xacml .cache .resource .ResourcePolicyIdUtil as ResourcePolicyIdUtil
77from java .io import File
88from java .lang import String
9+ import java .util .regex .Pattern as Pattern
910
1011import 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.
0 commit comments