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

公開メンバ関数

def __init__ (self, currentTimeMillis)
 
def init (self, configurationAttributes)
 
def destroy (self, authConfiguration)
 
def getApiVersion (self)
 
def isValidAuthenticationMethod (self, usageType, configurationAttributes)
 
def getAlternativeAuthenticationMethod (self, usageType, configurationAttributes)
 
def authenticate (self, configurationAttributes, requestParameters, step)
 
def prepareForStep (self, configurationAttributes, requestParameters, step)
 
def getExtraParametersForStep (self, configurationAttributes, step)
 
def getCountAuthenticationSteps (self, configurationAttributes)
 
def getPageForStep (self, configurationAttributes, step)
 
def logout (self, configurationAttributes, requestParameters)
 
def loadClientSecrets (self, clientSecretsFile)
 
def getClientConfiguration (self, configurationAttributes, requestParameters)
 
def getCurrentClientSecrets (self, currentClientSecrets, configurationAttributes, requestParameters)
 
def getCurrentAttributesMapping (self, currentAttributesMapping, configurationAttributes, requestParameters)
 
def prepareAttributesMapping (self, remoteAttributesList, localAttributesList)
 
def getTokensByCode (self, currentClientSecrets, configurationAttributes, code)
 
def getUserInfo (self, currentClientSecrets, configurationAttributes, accessToken)
 
def extensionPostLogin (self, configurationAttributes, user)
 

公開変数類

 currentTimeMillis
 
 clientSecrets
 
 attributesMapping
 
 extensionModule
 

詳解

構築子と解体子

◆ __init__()

def GooglePlusExternalAuthenticator.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
21  def __init__(self, currentTimeMillis):
22  self.currentTimeMillis = currentTimeMillis
23 

関数詳解

◆ authenticate()

def GooglePlusExternalAuthenticator.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
85  def authenticate(self, configurationAttributes, requestParameters, step):
86  identity = CdiUtil.bean(Identity)
87  userService = CdiUtil.bean(UserService)
88  authenticationService = CdiUtil.bean(AuthenticationService)
89 
90  mapUserDeployment = False
91  enrollUserDeployment = False
92  if (configurationAttributes.containsKey("gplus_deployment_type")):
93  deploymentType = StringHelper.toLowerCase(configurationAttributes.get("gplus_deployment_type").getValue2())
94 
95  if (StringHelper.equalsIgnoreCase(deploymentType, "map")):
96  mapUserDeployment = True
97  if (StringHelper.equalsIgnoreCase(deploymentType, "enroll")):
98  enrollUserDeployment = True
99 
100  if (step == 1):
101  print "Google+ Authenticate for step 1"
102 
103  gplusAuthCodeArray = requestParameters.get("gplus_auth_code")
104  gplusAuthCode = gplusAuthCodeArray[0]
105 
106  # Check if user uses basic method to log in
107  useBasicAuth = False
108  if (StringHelper.isEmptyString(gplusAuthCode)):
109  useBasicAuth = True
110 
111  # Use basic method to log in
112  if (useBasicAuth):
113  print "Google+ Authenticate for step 1. Basic authentication"
114 
115  identity.setWorkingParameter("gplus_count_login_steps", 1)
116 
117  credentials = identity.getCredentials()
118 
119  userName = credentials.getUsername()
120  userPassword = credentials.getPassword()
121 
122  loggedIn = False
123  if (StringHelper.isNotEmptyString(userName) and StringHelper.isNotEmptyString(userPassword)):
124  userService = CdiUtil.bean(UserService)
125  loggedIn = authenticationService.authenticate(userName, userPassword)
126 
127  if (not loggedIn):
128  return False
129 
130  return True
131 
132  # Use Google+ method to log in
133  print "Google+ Authenticate for step 1. gplusAuthCode:", gplusAuthCode
134 
135  currentClientSecrets = self.getCurrentClientSecrets(self.clientSecrets, configurationAttributes, requestParameters)
136  if (currentClientSecrets == None):
137  print "Google+ Authenticate for step 1. Client secrets configuration is invalid"
138  return False
139 
140  print "Google+ Authenticate for step 1. Attempting to gets tokens"
141  tokenResponse = self.getTokensByCode(self.clientSecrets, configurationAttributes, gplusAuthCode)
142  if ((tokenResponse == None) or (tokenResponse.getIdToken() == None) or (tokenResponse.getAccessToken() == None)):
143  print "Google+ Authenticate for step 1. Failed to get tokens"
144  return False
145  else:
146  print "Google+ Authenticate for step 1. Successfully gets tokens"
147 
148  jwt = Jwt.parse(tokenResponse.getIdToken())
149  # TODO: Validate ID Token Signature
150 
151  gplusUserUid = jwt.getClaims().getClaimAsString(JwtClaimName.SUBJECT_IDENTIFIER)
152  print "Google+ Authenticate for step 1. Found Google user ID in the ID token: '%s'" % gplusUserUid
153 
154  if (mapUserDeployment):
155  # Use mapping to local IDP user
156  print "Google+ Authenticate for step 1. Attempting to find user by oxExternalUid: 'gplus:%s'" % gplusUserUid
157 
158  # Check if there is user with specified gplusUserUid
159  foundUser = userService.getUserByAttribute("oxExternalUid", "gplus:" + gplusUserUid)
160 
161  if (foundUser == None):
162  print "Google+ Authenticate for step 1. Failed to find user"
163  print "Google+ Authenticate for step 1. Setting count steps to 2"
164  identity.setWorkingParameter("gplus_count_login_steps", 2)
165  identity.setWorkingParameter("gplus_user_uid", gplusUserUid)
166  return True
167 
168  foundUserName = foundUser.getUserId()
169  print "Google+ Authenticate for step 1. foundUserName: '%s'" % foundUserName
170 
171  userAuthenticated = authenticationService.authenticate(foundUserName)
172  if (userAuthenticated == False):
173  print "Google+ Authenticate for step 1. Failed to authenticate user"
174  return False
175 
176  print "Google+ Authenticate for step 1. Setting count steps to 1"
177  identity.setWorkingParameter("gplus_count_login_steps", 1)
178 
179  postLoginResult = self.extensionPostLogin(configurationAttributes, foundUser)
180  print "Google+ Authenticate for step 1. postLoginResult: '%s'" % postLoginResult
181 
182  return postLoginResult
183  elif (enrollUserDeployment):
184  # Use auto enrollment to local IDP
185  print "Google+ Authenticate for step 1. Attempting to find user by oxExternalUid: 'gplus:%s'" % gplusUserUid
186 
187  # Check if there is user with specified gplusUserUid
188  foundUser = userService.getUserByAttribute("oxExternalUid", "gplus:" + gplusUserUid)
189 
190  if (foundUser == None):
191  # Auto user enrollemnt
192  print "Google+ Authenticate for step 1. There is no user in LDAP. Adding user to local LDAP"
193 
194  print "Google+ Authenticate for step 1. Attempting to gets user info"
195  userInfoResponse = self.getUserInfo(currentClientSecrets, configurationAttributes, tokenResponse.getAccessToken())
196  if ((userInfoResponse == None) or (userInfoResponse.getClaims().size() == 0)):
197  print "Google+ Authenticate for step 1. Failed to get user info"
198  return False
199  else:
200  print "Google+ Authenticate for step 1. Successfully gets user info"
201 
202  gplusResponseAttributes = userInfoResponse.getClaims()
203 
204  # Convert Google+ user claims to lover case
205  gplusResponseNormalizedAttributes = HashMap()
206  for gplusResponseAttributeEntry in gplusResponseAttributes.entrySet():
207  gplusResponseNormalizedAttributes.put(
208  StringHelper.toLowerCase(gplusResponseAttributeEntry.getKey()), gplusResponseAttributeEntry.getValue())
209 
210  currentAttributesMapping = self.getCurrentAttributesMapping(self.attributesMapping, configurationAttributes, requestParameters)
211  print "Google+ Authenticate for step 1. Using next attributes mapping '%s'" % currentAttributesMapping
212 
213  newUser = User()
214  for attributesMappingEntry in currentAttributesMapping.entrySet():
215  remoteAttribute = attributesMappingEntry.getKey()
216  localAttribute = attributesMappingEntry.getValue()
217 
218  localAttributeValue = gplusResponseNormalizedAttributes.get(remoteAttribute)
219  if (localAttribute != None):
220  newUser.setAttribute(localAttribute, localAttributeValue)
221 
222  if (newUser.getAttribute("sn") == None):
223  newUser.setAttribute("sn", gplusUserUid)
224 
225  if (newUser.getAttribute("cn") == None):
226  newUser.setAttribute("cn", gplusUserUid)
227 
228  # Add mail to oxTrustEmail so that the user's
229  # email is available through the SCIM interface
230  # too.
231  if (newUser.getAttribute("oxTrustEmail") is None and
232  newUser.getAttribute("mail") is not None):
233  oxTrustEmail = {
234  "value": newUser.getAttribute("mail"),
235  "display": newUser.getAttribute("mail"),
236  "primary": True,
237  "operation": None,
238  "reference": None,
239  "type": "other"
240  }
241  newUser.setAttribute("oxTrustEmail", json.dumps(oxTrustEmail))
242 
243  newUser.setAttribute("oxExternalUid", "gplus:" + gplusUserUid)
244  print "Google+ Authenticate for step 1. Attempting to add user '%s' with next attributes '%s'" % (gplusUserUid, newUser.getCustomAttributes())
245 
246  foundUser = userService.addUser(newUser, True)
247  print "Google+ Authenticate for step 1. Added new user with UID: '%s'" % foundUser.getUserId()
248 
249  foundUserName = foundUser.getUserId()
250  print "Google+ Authenticate for step 1. foundUserName: '%s'" % foundUserName
251 
252  userAuthenticated = authenticationService.authenticate(foundUserName)
253  if (userAuthenticated == False):
254  print "Google+ Authenticate for step 1. Failed to authenticate user"
255  return False
256 
257  print "Google+ Authenticate for step 1. Setting count steps to 1"
258  identity.setWorkingParameter("gplus_count_login_steps", 1)
259 
260  print "Google+ Authenticate for step 1. Attempting to run extension postLogin"
261  postLoginResult = self.extensionPostLogin(configurationAttributes, foundUser)
262  print "Google+ Authenticate for step 1. postLoginResult: '%s'" % postLoginResult
263 
264  return postLoginResult
265  else:
266  # Check if there is user with specified gplusUserUid
267  print "Google+ Authenticate for step 1. Attempting to find user by uid: '%s'" % gplusUserUid
268 
269  foundUser = userService.getUser(gplusUserUid)
270  if (foundUser == None):
271  print "Google+ Authenticate for step 1. Failed to find user"
272  return False
273 
274  foundUserName = foundUser.getUserId()
275  print "Google+ Authenticate for step 1. foundUserName: '%s'" % foundUserName
276 
277  userAuthenticated = authenticationService.authenticate(foundUserName)
278  if (userAuthenticated == False):
279  print "Google+ Authenticate for step 1. Failed to authenticate user"
280  return False
281 
282  print "Google+ Authenticate for step 1. Setting count steps to 1"
283  identity.setWorkingParameter("gplus_count_login_steps", 1)
284 
285  postLoginResult = self.extensionPostLogin(configurationAttributes, foundUser)
286  print "Google+ Authenticate for step 1. postLoginResult: '%s'" % postLoginResult
287 
288  return postLoginResult
289  elif (step == 2):
290  print "Google+ Authenticate for step 2"
291 
292  sessionAttributes = identity.getSessionId().getSessionAttributes()
293  if (sessionAttributes == None) or not sessionAttributes.containsKey("gplus_user_uid"):
294  print "Google+ Authenticate for step 2. gplus_user_uid is empty"
295  return False
296 
297  gplusUserUid = sessionAttributes.get("gplus_user_uid")
298  passed_step1 = StringHelper.isNotEmptyString(gplusUserUid)
299  if (not passed_step1):
300  return False
301 
302  identity = CdiUtil.bean(Identity)
303  credentials = identity.getCredentials()
304 
305  userName = credentials.getUsername()
306  userPassword = credentials.getPassword()
307 
308  loggedIn = False
309  if (StringHelper.isNotEmptyString(userName) and StringHelper.isNotEmptyString(userPassword)):
310  loggedIn = authenticationService.authenticate(userName, userPassword)
311 
312  if (not loggedIn):
313  return False
314 
315  # Check if there is user which has gplusUserUid
316  # Avoid mapping Google account to more than one IDP account
317  foundUser = userService.getUserByAttribute("oxExternalUid", "gplus:" + gplusUserUid)
318 
319  if (foundUser == None):
320  # Add gplusUserUid to user one id UIDs
321  foundUser = userService.addUserAttribute(userName, "oxExternalUid", "gplus:" + gplusUserUid)
322  if (foundUser == None):
323  print "Google+ Authenticate for step 2. Failed to update current user"
324  return False
325 
326  postLoginResult = self.extensionPostLogin(configurationAttributes, foundUser)
327  print "Google+ Authenticate for step 2. postLoginResult: '%s'" % postLoginResult
328 
329  return postLoginResult
330  else:
331  foundUserName = foundUser.getUserId()
332  print "Google+ Authenticate for step 2. foundUserName: '%s'" % foundUserName
333 
334  if StringHelper.equals(userName, foundUserName):
335  postLoginResult = self.extensionPostLogin(configurationAttributes, foundUser)
336  print "Google+ Authenticate for step 2. postLoginResult: '%s'" % postLoginResult
337 
338  return postLoginResult
339 
340  return False
341  else:
342  return False
343 

◆ destroy()

def GooglePlusExternalAuthenticator.PersonAuthentication.destroy (   self,
  authConfiguration 
)
72  def destroy(self, authConfiguration):
73  print "Google+ Destroy"
74  print "Google+ Destroyed successfully"
75 

◆ extensionPostLogin()

def GooglePlusExternalAuthenticator.PersonAuthentication.extensionPostLogin (   self,
  configurationAttributes,
  user 
)
531  def extensionPostLogin(self, configurationAttributes, user):
532  if (self.extensionModule != None):
533  try:
534  postLoginResult = self.extensionModule.postLogin(configurationAttributes, user)
535  print "Google+ PostLogin result: '%s'" % postLoginResult
536 
537  return postLoginResult
538  except Exception, ex:
539  print "Google+ PostLogin. Failed to execute postLogin method"
540  print "Google+ PostLogin. Unexpected error:", ex
541  return False
542  except java.lang.Throwable, ex:
543  print "Google+ PostLogin. Failed to execute postLogin method"
544  ex.printStackTrace()
545  return False
546 
547  return True
548 

◆ getAlternativeAuthenticationMethod()

def GooglePlusExternalAuthenticator.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
82  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
83  return None
84 

◆ getApiVersion()

def GooglePlusExternalAuthenticator.PersonAuthentication.getApiVersion (   self)
76  def getApiVersion(self):
77  return 1
78 

◆ getClientConfiguration()

def GooglePlusExternalAuthenticator.PersonAuthentication.getClientConfiguration (   self,
  configurationAttributes,
  requestParameters 
)
405  def getClientConfiguration(self, configurationAttributes, requestParameters):
406  # Get client configuration
407  if (configurationAttributes.containsKey("gplus_client_configuration_attribute")):
408  clientConfigurationAttribute = configurationAttributes.get("gplus_client_configuration_attribute").getValue2()
409  print "Google+ GetClientConfiguration. Using client attribute: '%s'" % clientConfigurationAttribute
410 
411  if (requestParameters == None):
412  return None
413 
414  clientId = None
415 
416  # Attempt to determine client_id from request
417  clientIdArray = requestParameters.get("client_id")
418  if (ArrayHelper.isNotEmpty(clientIdArray) and StringHelper.isNotEmptyString(clientIdArray[0])):
419  clientId = clientIdArray[0]
420 
421  # Attempt to determine client_id from event context
422  if (clientId == None):
423  identity = CdiUtil.bean(Identity)
424  if (identity.isSetWorkingParameter("sessionAttributes")):
425  clientId = identity.getSessionId().getSessionAttributes().get("client_id")
426 
427  if (clientId == None):
428  print "Google+ GetClientConfiguration. client_id is empty"
429  return None
430 
431  clientService = CdiUtil.bean(ClientService)
432  client = clientService.getClient(clientId)
433  if (client == None):
434  print "Google+ GetClientConfiguration. Failed to find client '%s' in local LDAP" % clientId
435  return None
436 
437  clientConfiguration = clientService.getCustomAttribute(client, clientConfigurationAttribute)
438  if ((clientConfiguration == None) or StringHelper.isEmpty(clientConfiguration.getValue())):
439  print "Google+ GetClientConfiguration. Client '%s' attribute '%s' is empty" % (clientId, clientConfigurationAttribute)
440  else:
441  print "Google+ GetClientConfiguration. Client '%s' attribute '%s' is '%s'" % (clientId, clientConfigurationAttribute, clientConfiguration)
442  return clientConfiguration
443 
444  return None
445 

◆ getCountAuthenticationSteps()

def GooglePlusExternalAuthenticator.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
373  def getCountAuthenticationSteps(self, configurationAttributes):
374  identity = CdiUtil.bean(Identity)
375  if (identity.isSetWorkingParameter("gplus_count_login_steps")):
376  return identity.getWorkingParameter("gplus_count_login_steps")
377 
378  return 2
379 

◆ getCurrentAttributesMapping()

def GooglePlusExternalAuthenticator.PersonAuthentication.getCurrentAttributesMapping (   self,
  currentAttributesMapping,
  configurationAttributes,
  requestParameters 
)
455  def getCurrentAttributesMapping(self, currentAttributesMapping, configurationAttributes, requestParameters):
456  clientConfiguration = self.getClientConfiguration(configurationAttributes, requestParameters)
457  if (clientConfiguration == None):
458  return currentAttributesMapping
459 
460  clientConfigurationValue = json.loads(clientConfiguration.getValue())
461 
462  clientAttributesMapping = self.prepareAttributesMapping(clientConfigurationValue["gplus_remote_attributes_list"], clientConfigurationValue["gplus_local_attributes_list"])
463  if (clientAttributesMapping == None):
464  print "Google+ GetCurrentAttributesMapping. Client attributes mapping is invalid. Using default one"
465  return currentAttributesMapping
466 
467  return clientAttributesMapping
468 

◆ getCurrentClientSecrets()

def GooglePlusExternalAuthenticator.PersonAuthentication.getCurrentClientSecrets (   self,
  currentClientSecrets,
  configurationAttributes,
  requestParameters 
)
446  def getCurrentClientSecrets(self, currentClientSecrets, configurationAttributes, requestParameters):
447  clientConfiguration = self.getClientConfiguration(configurationAttributes, requestParameters)
448  if (clientConfiguration == None):
449  return currentClientSecrets
450 
451  clientConfigurationValue = json.loads(clientConfiguration.getValue())
452 
453  return clientConfigurationValue["gplus"]
454 

◆ getExtraParametersForStep()

def GooglePlusExternalAuthenticator.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
367  def getExtraParametersForStep(self, configurationAttributes, step):
368  if (step == 2):
369  return Arrays.asList("gplus_user_uid")
370 
371  return None
372 

◆ getPageForStep()

def GooglePlusExternalAuthenticator.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
380  def getPageForStep(self, configurationAttributes, step):
381  if (step == 1):
382  return "/auth/gplus/gpluslogin.xhtml"
383 
384  return "/auth/gplus/gpluspostlogin.xhtml"
385 

◆ getTokensByCode()

def GooglePlusExternalAuthenticator.PersonAuthentication.getTokensByCode (   self,
  currentClientSecrets,
  configurationAttributes,
  code 
)
504  def getTokensByCode(self, currentClientSecrets, configurationAttributes, code):
505  tokenRequest = TokenRequest(GrantType.CLIENT_CREDENTIALS)
506  tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_POST)
507  tokenRequest.setCode(code)
508  tokenRequest.setAuthUsername(currentClientSecrets["web"]["client_id"])
509  tokenRequest.setAuthPassword(currentClientSecrets["web"]["client_secret"])
510  tokenRequest.setRedirectUri("postmessage")
511  tokenRequest.setGrantType(GrantType.AUTHORIZATION_CODE)
512 
513  tokenClient = TokenClient(currentClientSecrets["web"]["token_uri"])
514  tokenClient.setRequest(tokenRequest)
515 
516  tokenResponse = tokenClient.exec()
517  if ((tokenResponse == None) or (tokenResponse.getStatus() != 200)):
518  return None
519 
520  return tokenResponse
521 

◆ getUserInfo()

def GooglePlusExternalAuthenticator.PersonAuthentication.getUserInfo (   self,
  currentClientSecrets,
  configurationAttributes,
  accessToken 
)
522  def getUserInfo(self, currentClientSecrets, configurationAttributes, accessToken):
523  userInfoClient = UserInfoClient("https://www.googleapis.com/plus/v1/people/me/openIdConnect")
524 
525  userInfoResponse = userInfoClient.execUserInfo(accessToken)
526  if ((userInfoResponse == None) or (userInfoResponse.getStatus() != 200)):
527  return None
528 
529  return userInfoResponse
530 

◆ init()

def GooglePlusExternalAuthenticator.PersonAuthentication.init (   self,
  configurationAttributes 
)
24  def init(self, configurationAttributes):
25  print "Google+ Initialization"
26 
27  if (not configurationAttributes.containsKey("gplus_client_secrets_file")):
28  print "Google+ Initialization. The property gplus_client_secrets_file is empty"
29  return False
30 
31  clientSecretsFile = configurationAttributes.get("gplus_client_secrets_file").getValue2()
32  self.clientSecrets = self.loadClientSecrets(clientSecretsFile)
33  if (self.clientSecrets == None):
34  print "Google+ Initialization. File with Google+ client secrets should be not empty"
35  return False
36 
37  self.attributesMapping = None
38  if (configurationAttributes.containsKey("gplus_remote_attributes_list") and
39  configurationAttributes.containsKey("gplus_local_attributes_list")):
40 
41  remoteAttributesList = configurationAttributes.get("gplus_remote_attributes_list").getValue2()
42  if (StringHelper.isEmpty(remoteAttributesList)):
43  print "Google+ Initialization. The property gplus_remote_attributes_list is empty"
44  return False
45 
46  localAttributesList = configurationAttributes.get("gplus_local_attributes_list").getValue2()
47  if (StringHelper.isEmpty(localAttributesList)):
48  print "Google+ Initialization. The property gplus_local_attributes_list is empty"
49  return False
50 
51  self.attributesMapping = self.prepareAttributesMapping(remoteAttributesList, localAttributesList)
52  if (self.attributesMapping == None):
53  print "Google+ Initialization. The attributes mapping isn't valid"
54  return False
55 
56  self.extensionModule = None
57  if (configurationAttributes.containsKey("extension_module")):
58  extensionModuleName = configurationAttributes.get("extension_module").getValue2()
59  try:
60  self.extensionModule = __import__(extensionModuleName)
61  extensionModuleInitResult = self.extensionModule.init(configurationAttributes)
62  if (not extensionModuleInitResult):
63  return False
64  except ImportError, ex:
65  print "Google+ Initialization. Failed to load gplus_extension_module: '%s'" % extensionModuleName
66  print "Google+ Initialization. Unexpected error:", ex
67  return False
68 
69  print "Google+ Initialized successfully"
70  return True
71 

◆ isValidAuthenticationMethod()

def GooglePlusExternalAuthenticator.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
79  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
80  return True
81 

◆ loadClientSecrets()

def GooglePlusExternalAuthenticator.PersonAuthentication.loadClientSecrets (   self,
  clientSecretsFile 
)
390  def loadClientSecrets(self, clientSecretsFile):
391  clientSecrets = None
392 
393  # Load certificate from file
394  f = open(clientSecretsFile, 'r')
395  try:
396  clientSecrets = json.loads(f.read())
397  except:
398  print "Failed to load Google+ client secrets from file: '%s'" % clientSecrets
399  return None
400  finally:
401  f.close()
402 
403  return clientSecrets
404 

◆ logout()

def GooglePlusExternalAuthenticator.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
386  def logout(self, configurationAttributes, requestParameters):
387  # TODO Revoke token
388  return True
389 

◆ prepareAttributesMapping()

def GooglePlusExternalAuthenticator.PersonAuthentication.prepareAttributesMapping (   self,
  remoteAttributesList,
  localAttributesList 
)
469  def prepareAttributesMapping(self, remoteAttributesList, localAttributesList):
470  remoteAttributesListArray = StringHelper.split(remoteAttributesList, ",")
471  if (ArrayHelper.isEmpty(remoteAttributesListArray)):
472  print "Google+ PrepareAttributesMapping. There is no attributes specified in remoteAttributesList property"
473  return None
474 
475  localAttributesListArray = StringHelper.split(localAttributesList, ",")
476  if (ArrayHelper.isEmpty(localAttributesListArray)):
477  print "Google+ PrepareAttributesMapping. There is no attributes specified in localAttributesList property"
478  return None
479 
480  if (len(remoteAttributesListArray) != len(localAttributesListArray)):
481  print "Google+ PrepareAttributesMapping. The number of attributes in remoteAttributesList and localAttributesList isn't equal"
482  return None
483 
484  attributeMapping = IdentityHashMap()
485  containsUid = False
486  i = 0
487  count = len(remoteAttributesListArray)
488  while (i < count):
489  remoteAttribute = StringHelper.toLowerCase(remoteAttributesListArray[i])
490  localAttribute = StringHelper.toLowerCase(localAttributesListArray[i])
491  attributeMapping.put(remoteAttribute, localAttribute)
492 
493  if (StringHelper.equalsIgnoreCase(localAttribute, "uid")):
494  containsUid = True
495 
496  i = i + 1
497 
498  if (not containsUid):
499  print "Google+ PrepareAttributesMapping. There is no mapping to mandatory 'uid' attribute"
500  return None
501 
502  return attributeMapping
503 

◆ prepareForStep()

def GooglePlusExternalAuthenticator.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
344  def prepareForStep(self, configurationAttributes, requestParameters, step):
345  identity = CdiUtil.bean(Identity)
346  authenticationService = CdiUtil.bean(AuthenticationService)
347 
348  if (step == 1):
349  print "Google+ Prepare for step 1"
350 
351  currentClientSecrets = self.getCurrentClientSecrets(self.clientSecrets, configurationAttributes, requestParameters)
352  if (currentClientSecrets == None):
353  print "Google+ Prepare for step 1. Google+ client configuration is invalid"
354  return False
355 
356  identity.setWorkingParameter("gplus_client_id", currentClientSecrets["web"]["client_id"])
357  identity.setWorkingParameter("gplus_client_secret", currentClientSecrets["web"]["client_secret"])
358 
359  return True
360  elif (step == 2):
361  print "Google+ Prepare for step 2"
362 
363  return True
364  else:
365  return False
366 

メンバ詳解

◆ attributesMapping

GooglePlusExternalAuthenticator.PersonAuthentication.attributesMapping

◆ clientSecrets

GooglePlusExternalAuthenticator.PersonAuthentication.clientSecrets

◆ currentTimeMillis

GooglePlusExternalAuthenticator.PersonAuthentication.currentTimeMillis

◆ extensionModule

GooglePlusExternalAuthenticator.PersonAuthentication.extensionModule

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