gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
ThumbSignInExternalAuthenticator.PersonAuthentication クラス
ThumbSignInExternalAuthenticator.PersonAuthentication の継承関係図
Inheritance graph
ThumbSignInExternalAuthenticator.PersonAuthentication 連携図
Collaboration graph

公開メンバ関数

def __init__ (self, currentTimeMillis)
 
def init (self, configurationAttributes)
 
def destroy (self, configurationAttributes)
 
def getApiVersion (self)
 
def isValidAuthenticationMethod (self, usageType, configurationAttributes)
 
def getAlternativeAuthenticationMethod (self, usageType, configurationAttributes)
 
def setRelyingPartyLoginUrl (self, identity)
 
def prepareForStep (self, configurationAttributes, requestParameters, step)
 
def authenticate (self, configurationAttributes, requestParameters, step)
 
def getExtraParametersForStep (self, configurationAttributes, step)
 
def getCountAuthenticationSteps (self, configurationAttributes)
 
def getPageForStep (self, configurationAttributes, step)
 
def logout (self, configurationAttributes, requestParameters)
 

公開変数類

 currentTimeMillis
 

詳解

構築子と解体子

◆ __init__()

def ThumbSignInExternalAuthenticator.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
18  def __init__(self, currentTimeMillis):
19  self.currentTimeMillis = currentTimeMillis
20 

関数詳解

◆ authenticate()

def ThumbSignInExternalAuthenticator.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
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)
184 
185  global ts_host
186  global ts_apiKey
187  global ts_apiSecret
188  global ts_statusPath
189 
190  identity.setWorkingParameter("ts_host", ts_host)
191  identity.setWorkingParameter("ts_statusPath", ts_statusPath)
192 
193  thumbsigninApiController = ThumbsigninApiController()
194 
195  if (step == 1 or step == 3):
196  print "ThumbSignIn. Authenticate for Step %d" % step
197 
198  login_flow = ServerUtil.getFirstValue(requestParameters, "login_flow")
199  print "ThumbSignIn. Value of login_flow parameter is %s" % login_flow
200 
201  #Logic for ThumbSignIn Authentication 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")
205 
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
210 
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
216 
217  logged_in_status = authenticationService.authenticate(thumbSignIn_UserId)
218  print "ThumbSignIn. logged_in status : %r" % (logged_in_status)
219  return logged_in_status
220 
221  #Logic for ThumbSignIn Registration Flow
222  identity.setWorkingParameter("userLoginFlow", "ThumbSignIn_Registration")
223  print "ThumbSignIn. Value of userLoginFlow is %s" % identity.getWorkingParameter("userLoginFlow")
224  credentials = identity.getCredentials()
225 
226  user_name = credentials.getUsername()
227  user_password = credentials.getPassword()
228  print "ThumbSignIn. user_name: " + user_name
229  #print "ThumbSignIn. user_password: " + user_password
230 
231  logged_in = False
232  if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
233  logged_in = authenticationService.authenticate(user_name, user_password)
234 
235  print "ThumbSignIn. Status of LDAP Authentication : %r" % (logged_in)
236 
237  if (not logged_in):
238  # Invoking the authenticate ThumbSignIn API via the Java SDK
239  authenticateResponseJsonStr = thumbsigninApiController.handleThumbSigninRequest("authenticate", ts_apiKey, ts_apiSecret)
240  print "ThumbSignIn. Value of authenticateResponseJsonStr is %s" % authenticateResponseJsonStr
241 
242  authenticateResponseJsonObj = JSONObject(authenticateResponseJsonStr)
243  transactionId = authenticateResponseJsonObj.get("transactionId")
244  authenticationStatusRequest = "authStatus/" + transactionId
245  print "ThumbSignIn. Value of authenticationStatusRequest is %s" % authenticationStatusRequest
246 
247  authorizationHeaderJsonStr = thumbsigninApiController.getAuthorizationHeaderJsonStr(authenticationStatusRequest, ts_apiKey, ts_apiSecret)
248  print "ThumbSignIn. Value of authorizationHeaderJsonStr is %s" % authorizationHeaderJsonStr
249  # {"authHeader":"HmacSHA256 Credential=XXX, SignedHeaders=accept;content-type;x-ts-date, Signature=XXX","XTsDate":"XXX"}
250 
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
256 
257  identity.setWorkingParameter("authenticateResponseJsonStr", authenticateResponseJsonStr)
258  identity.setWorkingParameter("authorizationHeader", authorizationHeader)
259  identity.setWorkingParameter("xTsDate", xTsDate)
260  return False
261 
262  print "ThumbSignIn. Authenticate for step 1 successful"
263  return True
264 
265  elif (step == 2):
266  print "ThumbSignIn. Registration flow (step 2)"
267 
268  if (identity.isSetWorkingParameter("userLoginFlow")):
269  userLoginFlow = identity.getWorkingParameter("userLoginFlow")
270  print "ThumbSignIn. Value of userLoginFlow is %s" % userLoginFlow
271  else:
272  identity.setWorkingParameter("userLoginFlow", "ThumbSignIn_Registration")
273  print "ThumbSignIn. Setting the value of userLoginFlow to %s" % identity.getWorkingParameter("userLoginFlow")
274 
275  user = authenticationService.getAuthenticatedUser()
276  if user == None:
277  print "ThumbSignIn. Registration flow (step 2). Failed to determine user name"
278  return False
279 
280  user_name = user.getUserId()
281  print "ThumbSignIn. Registration flow (step 2). user_name: " + user_name
282 
283  print "ThumbSignIn. Registration flow (step 2) successful"
284  return True
285  else:
286  return False
287 

◆ destroy()

def ThumbSignInExternalAuthenticator.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
41  def destroy(self, configurationAttributes):
42  print "ThumbSignIn. Destroy"
43  return True
44 

◆ getAlternativeAuthenticationMethod()

def ThumbSignInExternalAuthenticator.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
51  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
52  return None
53 

◆ getApiVersion()

def ThumbSignInExternalAuthenticator.PersonAuthentication.getApiVersion (   self)
45  def getApiVersion(self):
46  return 1
47 

◆ getCountAuthenticationSteps()

def ThumbSignInExternalAuthenticator.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
291  def getCountAuthenticationSteps(self, configurationAttributes):
292  print "ThumbSignIn. Inside getCountAuthenticationSteps.."
293  identity = CdiUtil.bean(Identity)
294 
295  userLoginFlow = identity.getWorkingParameter("userLoginFlow")
296  print "ThumbSignIn. Value of userLoginFlow is %s" % userLoginFlow
297  if (userLoginFlow == "ThumbSignIn_Authentication"):
298  print "ThumbSignIn. Total Authentication Steps is: 1"
299  return 1
300  #If the userLoginFlow is registration, then we can handle the ThumbSignIn registration as part of the second step
301  print "ThumbSignIn. Total Authentication Steps is: 3"
302  return 3
303 

◆ getExtraParametersForStep()

def ThumbSignInExternalAuthenticator.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
288  def getExtraParametersForStep(self, configurationAttributes, step):
289  return None
290 

◆ getPageForStep()

def ThumbSignInExternalAuthenticator.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
304  def getPageForStep(self, configurationAttributes, step):
305  print "ThumbSignIn. Inside getPageForStep. Step %d" % step
306  if (step == 2):
307  return "/auth/thumbsignin/tsRegister.xhtml"
308  elif (step == 3):
309  return "/auth/thumbsignin/tsRegistrationSuccess.xhtml"
310  else:
311  return "/auth/thumbsignin/tsLogin.xhtml"
312 

◆ init()

def ThumbSignInExternalAuthenticator.PersonAuthentication.init (   self,
  configurationAttributes 
)
21  def init(self, configurationAttributes):
22  print "ThumbSignIn. Initialization"
23 
24  global ts_host
25  ts_host = configurationAttributes.get("ts_host").getValue2()
26  print "ThumbSignIn. Initialization. Value of ts_host is %s" % ts_host
27 
28  global ts_apiKey
29  ts_apiKey = configurationAttributes.get("ts_apiKey").getValue2()
30  print "ThumbSignIn. Initialization. Value of ts_apiKey is %s" % ts_apiKey
31 
32  global ts_apiSecret
33  ts_apiSecret = configurationAttributes.get("ts_apiSecret").getValue2()
34 
35  global ts_statusPath
36  ts_statusPath = "/ts/secure/txn-status/"
37 
38  print "ThumbSignIn. Initialized successfully"
39  return True
40 

◆ isValidAuthenticationMethod()

def ThumbSignInExternalAuthenticator.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
48  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
49  return True
50 

◆ logout()

def ThumbSignInExternalAuthenticator.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
313  def logout(self, configurationAttributes, requestParameters):
314  return True
315 

◆ prepareForStep()

def ThumbSignInExternalAuthenticator.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
89  def prepareForStep(self, configurationAttributes, requestParameters, step):
90  print "ThumbSignIn. Inside prepareForStep. Step %d" % step
91  identity = CdiUtil.bean(Identity)
92  authenticationService = CdiUtil.bean(AuthenticationService)
93 
94  global ts_host
95  global ts_apiKey
96  global ts_apiSecret
97  global ts_statusPath
98 
99  identity.setWorkingParameter("ts_host", ts_host)
100  identity.setWorkingParameter("ts_statusPath", ts_statusPath)
101 
102  self.setRelyingPartyLoginUrl(identity)
103  thumbsigninApiController = ThumbsigninApiController()
104 
105  if (step == 1 or step == 3):
106  print "ThumbSignIn. Prepare for step 1"
107 
108  # Invoking the authenticate ThumbSignIn API via the Java SDK
109  authenticateResponseJsonStr = thumbsigninApiController.handleThumbSigninRequest("authenticate", ts_apiKey, ts_apiSecret)
110  print "ThumbSignIn. Value of authenticateResponseJsonStr is %s" % authenticateResponseJsonStr
111 
112  authenticateResponseJsonObj = JSONObject(authenticateResponseJsonStr)
113  transactionId = authenticateResponseJsonObj.get("transactionId")
114  authenticationStatusRequest = "authStatus/" + transactionId
115  print "ThumbSignIn. Value of authenticationStatusRequest is %s" % authenticationStatusRequest
116 
117  authorizationHeaderJsonStr = thumbsigninApiController.getAuthorizationHeaderJsonStr(authenticationStatusRequest, ts_apiKey, ts_apiSecret)
118  print "ThumbSignIn. Value of authorizationHeaderJsonStr is %s" % authorizationHeaderJsonStr
119  # {"authHeader":"HmacSHA256 Credential=XXX, SignedHeaders=accept;content-type;x-ts-date, Signature=XXX","XTsDate":"XXX"}
120 
121  authorizationHeaderJsonObj = JSONObject(authorizationHeaderJsonStr)
122  authorizationHeader = authorizationHeaderJsonObj.get("authHeader")
123  xTsDate = authorizationHeaderJsonObj.get("XTsDate")
124  print "ThumbSignIn. Value of authorizationHeader is %s" % authorizationHeader
125  print "ThumbSignIn. Value of xTsDate is %s" % xTsDate
126 
127  identity.setWorkingParameter("authenticateResponseJsonStr", authenticateResponseJsonStr)
128  identity.setWorkingParameter("authorizationHeader", authorizationHeader)
129  identity.setWorkingParameter("xTsDate", xTsDate)
130 
131  return True
132 
133  elif (step == 2):
134  print "ThumbSignIn. Prepare for step 2"
135 
136  if (identity.isSetWorkingParameter("userLoginFlow")):
137  userLoginFlow = identity.getWorkingParameter("userLoginFlow")
138  print "ThumbSignIn. Value of userLoginFlow is %s" % userLoginFlow
139 
140  user = authenticationService.getAuthenticatedUser()
141  if (user == None):
142  print "ThumbSignIn. Prepare for step 2. Failed to determine user name"
143  return False
144 
145  user_name = user.getUserId()
146  print "ThumbSignIn. Prepare for step 2. user_name: " + user_name
147  if (user_name == None):
148  return False
149 
150  registerRequestPath = "register/" + user_name
151 
152  # Invoking the register ThumbSignIn API via the Java SDK
153  registerResponseJsonStr = thumbsigninApiController.handleThumbSigninRequest(registerRequestPath, ts_apiKey, ts_apiSecret)
154  print "ThumbSignIn. Value of registerResponseJsonStr is %s" % registerResponseJsonStr
155 
156  registerResponseJsonObj = JSONObject(registerResponseJsonStr)
157  transactionId = registerResponseJsonObj.get("transactionId")
158  registrationStatusRequest = "regStatus/" + transactionId
159  print "ThumbSignIn. Value of registrationStatusRequest is %s" % registrationStatusRequest
160 
161  authorizationHeaderJsonStr = thumbsigninApiController.getAuthorizationHeaderJsonStr(registrationStatusRequest, ts_apiKey, ts_apiSecret)
162  print "ThumbSignIn. Value of authorizationHeaderJsonStr is %s" % authorizationHeaderJsonStr
163  # {"authHeader":"HmacSHA256 Credential=XXX, SignedHeaders=accept;content-type;x-ts-date, Signature=XXX","XTsDate":"XXX"}
164 
165  authorizationHeaderJsonObj = JSONObject(authorizationHeaderJsonStr)
166  authorizationHeader = authorizationHeaderJsonObj.get("authHeader")
167  xTsDate = authorizationHeaderJsonObj.get("XTsDate")
168  print "ThumbSignIn. Value of authorizationHeader is %s" % authorizationHeader
169  print "ThumbSignIn. Value of xTsDate is %s" % xTsDate
170 
171  identity.setWorkingParameter("userId", user_name)
172  identity.setWorkingParameter("registerResponseJsonStr", registerResponseJsonStr)
173  identity.setWorkingParameter("authorizationHeader", authorizationHeader)
174  identity.setWorkingParameter("xTsDate", xTsDate)
175 
176  return True
177  else:
178  return False
179 

◆ setRelyingPartyLoginUrl()

def ThumbSignInExternalAuthenticator.PersonAuthentication.setRelyingPartyLoginUrl (   self,
  identity 
)
54  def setRelyingPartyLoginUrl(self, identity):
55  print "ThumbSignIn. Inside setRelyingPartyLoginUrl..."
56  sessionId = identity.getSessionId()
57  sessionAttribute = sessionId.getSessionAttributes()
58  stateJWTToken = sessionAttribute.get("state")
59 
60  relyingPartyLoginUrl = ""
61  relyingPartyId = ""
62  if (stateJWTToken != None) :
63  stateJWTTokenArray = String(stateJWTToken).split("\\.")
64  stateJWTTokenPayload = stateJWTTokenArray[1]
65  statePayloadStr = String(Base64Util.base64urldecode(stateJWTTokenPayload), "UTF-8")
66  statePayloadJson = JSONObject(statePayloadStr)
67  print "ThumbSignIn. Value of state JWT token Payload is %s" % statePayloadJson
68  additional_claims = statePayloadJson.get("additional_claims")
69  relyingPartyId = additional_claims.get("relyingPartyId")
70  print "ThumbSignIn. Value of relyingPartyId is %s" % relyingPartyId
71  identity.setWorkingParameter("relyingPartyId", relyingPartyId)
72 
73  if (String(relyingPartyId).startsWith("google.com")):
74  #google.com/a/unphishableenterprise.com
75  relyingPartyIdArray = String(relyingPartyId).split("/")
76  googleDomain = relyingPartyIdArray[2]
77  print "ThumbSignIn. Value of googleDomain is %s" % googleDomain
78  relyingPartyLoginUrl = "https://www.google.com/accounts/AccountChooser?hd="+ googleDomain + "%26continue=https://apps.google.com/user/hub"
79  #elif (String(relyingPartyId).startsWith("xyz")):
80  #relyingPartyLoginUrl = "xyz.com"
81  else:
82  #If relyingPartyLoginUrl is empty, Gluu's default login URL will be used
83  relyingPartyLoginUrl = ""
84 
85  print "ThumbSignIn. Value of relyingPartyLoginUrl is %s" % relyingPartyLoginUrl
86  identity.setWorkingParameter("relyingPartyLoginUrl", relyingPartyLoginUrl)
87  return None
88 

メンバ詳解

◆ currentTimeMillis

ThumbSignInExternalAuthenticator.PersonAuthentication.currentTimeMillis

このクラス詳解は次のファイルから抽出されました: