180 def authenticate(self, configurationAttributes, requestParameters, step):
181 print "ThumbSignIn. Inside authenticate. Step %d" % step
182 authenticationService = CdiUtil.bean(AuthenticationService)
183 identity = CdiUtil.bean(Identity)
190 identity.setWorkingParameter(
"ts_host", ts_host)
191 identity.setWorkingParameter(
"ts_statusPath", ts_statusPath)
193 thumbsigninApiController = ThumbsigninApiController()
195 if (step == 1
or step == 3):
196 print "ThumbSignIn. Authenticate for Step %d" % step
198 login_flow = ServerUtil.getFirstValue(requestParameters,
"login_flow")
199 print "ThumbSignIn. Value of login_flow parameter is %s" % login_flow
202 if (login_flow ==
"ThumbSignIn_Authentication" or login_flow ==
"ThumbSignIn_RegistrationSucess"):
203 identity.setWorkingParameter(
"userLoginFlow", login_flow)
204 print "ThumbSignIn. Value of userLoginFlow is %s" % identity.getWorkingParameter(
"userLoginFlow")
206 transactionId = ServerUtil.getFirstValue(requestParameters,
"transactionId")
207 print "ThumbSignIn. Value of transactionId is %s" % transactionId
208 getUserRequest =
"getUser/" + transactionId
209 print "ThumbSignIn. Value of getUserRequest is %s" % getUserRequest
211 getUserResponseJsonStr = thumbsigninApiController.handleThumbSigninRequest(getUserRequest, ts_apiKey, ts_apiSecret)
212 print "ThumbSignIn. Value of getUserResponseJsonStr is %s" % getUserResponseJsonStr
213 getUserResponseJsonObj = JSONObject(getUserResponseJsonStr)
214 thumbSignIn_UserId = getUserResponseJsonObj.get(
"userId")
215 print "ThumbSignIn. Value of thumbSignIn_UserId is %s" % thumbSignIn_UserId
217 logged_in_status = authenticationService.authenticate(thumbSignIn_UserId)
218 print "ThumbSignIn. logged_in status : %r" % (logged_in_status)
219 return logged_in_status
222 identity.setWorkingParameter(
"userLoginFlow",
"ThumbSignIn_Registration")
223 print "ThumbSignIn. Value of userLoginFlow is %s" % identity.getWorkingParameter(
"userLoginFlow")
224 credentials = identity.getCredentials()
226 user_name = credentials.getUsername()
227 user_password = credentials.getPassword()
228 print "ThumbSignIn. user_name: " + user_name
232 if (StringHelper.isNotEmptyString(user_name)
and StringHelper.isNotEmptyString(user_password)):
233 logged_in = authenticationService.authenticate(user_name, user_password)
235 print "ThumbSignIn. Status of LDAP Authentication : %r" % (logged_in)
239 authenticateResponseJsonStr = thumbsigninApiController.handleThumbSigninRequest(
"authenticate", ts_apiKey, ts_apiSecret)
240 print "ThumbSignIn. Value of authenticateResponseJsonStr is %s" % authenticateResponseJsonStr
242 authenticateResponseJsonObj = JSONObject(authenticateResponseJsonStr)
243 transactionId = authenticateResponseJsonObj.get(
"transactionId")
244 authenticationStatusRequest =
"authStatus/" + transactionId
245 print "ThumbSignIn. Value of authenticationStatusRequest is %s" % authenticationStatusRequest
247 authorizationHeaderJsonStr = thumbsigninApiController.getAuthorizationHeaderJsonStr(authenticationStatusRequest, ts_apiKey, ts_apiSecret)
248 print "ThumbSignIn. Value of authorizationHeaderJsonStr is %s" % authorizationHeaderJsonStr
251 authorizationHeaderJsonObj = JSONObject(authorizationHeaderJsonStr)
252 authorizationHeader = authorizationHeaderJsonObj.get(
"authHeader")
253 xTsDate = authorizationHeaderJsonObj.get(
"XTsDate")
254 print "ThumbSignIn. Value of authorizationHeader is %s" % authorizationHeader
255 print "ThumbSignIn. Value of xTsDate is %s" % xTsDate
257 identity.setWorkingParameter(
"authenticateResponseJsonStr", authenticateResponseJsonStr)
258 identity.setWorkingParameter(
"authorizationHeader", authorizationHeader)
259 identity.setWorkingParameter(
"xTsDate", xTsDate)
262 print "ThumbSignIn. Authenticate for step 1 successful" 266 print "ThumbSignIn. Registration flow (step 2)" 268 if (identity.isSetWorkingParameter(
"userLoginFlow")):
269 userLoginFlow = identity.getWorkingParameter(
"userLoginFlow")
270 print "ThumbSignIn. Value of userLoginFlow is %s" % userLoginFlow
272 identity.setWorkingParameter(
"userLoginFlow",
"ThumbSignIn_Registration")
273 print "ThumbSignIn. Setting the value of userLoginFlow to %s" % identity.getWorkingParameter(
"userLoginFlow")
275 user = authenticationService.getAuthenticatedUser()
277 print "ThumbSignIn. Registration flow (step 2). Failed to determine user name" 280 user_name = user.getUserId()
281 print "ThumbSignIn. Registration flow (step 2). user_name: " + user_name
283 print "ThumbSignIn. Registration flow (step 2) successful"