58 def authenticate(self, configurationAttributes, requestParameters, step):
59 identity = CdiUtil.bean(Identity)
60 userService = CdiUtil.bean(UserService)
61 authenticationService = CdiUtil.bean(AuthenticationService)
64 credentials = identity.getCredentials()
65 user_name = credentials.getUsername()
66 user_password = credentials.getPassword()
68 if (StringHelper.isNotEmptyString(user_name)
and StringHelper.isNotEmptyString(user_password)):
69 userService = CdiUtil.bean(UserService)
70 logged_in = authenticationService.authenticate(user_name, user_password)
74 find_user_by_uid = authenticationService.getAuthenticatedUser()
75 status_attribute_value = userService.getCustomAttribute(find_user_by_uid,
"mail")
76 user_mail = status_attribute_value.getValue()
77 self.setRequestScopedParameters(identity)
79 isCompromised = self.is_compromised(user_mail,user_password,configurationAttributes)
81 identity.setWorkingParameter(
"pwd_compromised", isCompromised)
82 identity.setWorkingParameter(
"user_name", user_name)
87 print "compromised_password. Authenticate for step 2" 88 form_answer_array = requestParameters.get(
"loginForm:question")
89 if ArrayHelper.isEmpty(form_answer_array):
91 form_answer = form_answer_array[0]
92 if (form_answer == self.secretanswer):
96 authenticationService = CdiUtil.bean(AuthenticationService)
97 print "compromised_password (with password update). Authenticate for step 3" 98 userService = CdiUtil.bean(UserService)
99 update_button = requestParameters.get(
"loginForm:updateButton")
100 new_password_array = requestParameters.get(
"new_password")
101 if ArrayHelper.isEmpty(new_password_array)
or StringHelper.isEmpty(new_password_array[0]):
102 print "compromised_password (with password update). Authenticate for step 3. New password is empty" 104 new_password = new_password_array[0]
106 user = authenticationService.getAuthenticatedUser()
108 print "compromised_password (with password update). Authenticate for step 3. Failed to determine user name" 111 user_name = user.getUserId()
112 print "compromised_password (with password update). Authenticate for step 3. Attempting to set new user '" + user_name +
"' password" 113 find_user_by_uid = userService.getUser(user_name)
114 if (find_user_by_uid ==
None):
115 print "compromised_password (with password update). Authenticate for step 3. Failed to find user" 118 find_user_by_uid.setAttribute(
"userPassword", new_password)
119 userService.updateUser(find_user_by_uid)
120 print "compromised_password (with password update). Authenticate for step 3. Password updated successfully" 121 logged_in = authenticationService.authenticate(user_name)
do if[-f "$CONFIG"]
Definition: oxd-https-extension.init.d:165