2
2
Copyright (c) 2021, Oracle Corporation and/or its affiliates.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
"""
5
- import com .bea . common . security . utils . encoders . BASE64Encoder as BASE64Encoder
5
+ import com .octetstring . vde . util . PasswordEncryptor as PasswordEncryptor
6
6
import com .bea .security .xacml .cache .resource .ResourcePolicyIdUtil as ResourcePolicyIdUtil
7
7
from java .io import File
8
8
from java .lang import String
9
+ import java .util .regex .Pattern as Pattern
9
10
10
11
import oracle .weblogic .deploy .aliases .TypeUtils as TypeUtils
11
12
@@ -48,7 +49,6 @@ def __init__(self, model_context, exception_type):
48
49
self ._logger = PlatformLogger ('wlsdeploy.tool.util' )
49
50
self ._weblogic_helper = WebLogicHelper (self ._logger )
50
51
self ._resource_escaper = ResourcePolicyIdUtil .getEscaper ()
51
- self ._b64_encoder = BASE64Encoder ()
52
52
53
53
def create_default_init_file (self , security_mapping_nodes ):
54
54
"""
@@ -135,8 +135,7 @@ def _build_user_mapping_hash(self, user_mapping_section, name):
135
135
hash_entry [HASH_DESCRIPTION ] = description
136
136
groups = dictionary_utils .get_element (group_attributes , GROUP_MEMBER_OF )
137
137
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 )
140
139
hash_entry [HASH_USER_PASSWORD ] = password_encoded
141
140
group_list = []
142
141
group_mappings = list ()
@@ -150,6 +149,20 @@ def _build_user_mapping_hash(self, user_mapping_section, name):
150
149
151
150
return hash_entry
152
151
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
+
153
166
def _get_required_attribute (self , dictionary , name , mapping_type , mapping_name ):
154
167
"""
155
168
Return the value of the specified attribute from the specified dictionary.
0 commit comments