39 def authenticate(self, configurationAttributes, requestParameters, step):
40 userService = CdiUtil.bean(UserService)
41 authenticationService = CdiUtil.bean(AuthenticationService)
43 identity = CdiUtil.bean(Identity)
44 credentials = identity.getCredentials()
45 user_name = credentials.getUsername()
48 print "Basic (with password update). Authenticate for step 1" 50 user_password = credentials.getPassword()
53 if (StringHelper.isNotEmptyString(user_name)
and StringHelper.isNotEmptyString(user_password)):
54 logged_in = authenticationService.authenticate(user_name, user_password)
61 print "Basic (with password update). Authenticate for step 2" 62 user = authenticationService.getAuthenticatedUser()
64 print "Basic (with password update). Authenticate for step 2. Failed to determine user name" 67 user_name = user.getUserId()
68 find_user_by_uid = userService.getUser(user_name)
70 update_button = requestParameters.get(
"loginForm:updateButton")
72 if ArrayHelper.isEmpty(update_button):
75 new_password_array = requestParameters.get(
"new_password")
76 if ArrayHelper.isEmpty(new_password_array)
or StringHelper.isEmpty(new_password_array[0]):
77 print "Basic (with password update). Authenticate for step 2. New password is empty" 80 new_password = new_password_array[0]
81 find_user_by_uid.setAttribute(
"userPassword", new_password)
82 print "Basic (with password update). Authenticate for step 2. Attempting to set new user '%s' password" % user_name
84 userService.updateUser(find_user_by_uid)
85 print "Basic (with password update). Authenticate for step 2. Password updated successfully"