gluu
公開メンバ関数 | 公開変数類 | 全メンバ一覧
SuperGluuExternalAuthenticator.PersonAuthentication クラス
SuperGluuExternalAuthenticator.PersonAuthentication の継承関係図
Inheritance graph
SuperGluuExternalAuthenticator.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 authenticate (self, configurationAttributes, requestParameters, step)
 
def prepareForStep (self, configurationAttributes, requestParameters, step)
 
def getNextStep (self, configurationAttributes, requestParameters, step)
 
def getExtraParametersForStep (self, configurationAttributes, step)
 
def getCountAuthenticationSteps (self, configurationAttributes)
 
def getPageForStep (self, configurationAttributes, step)
 
def logout (self, configurationAttributes, requestParameters)
 
def processBasicAuthentication (self, credentials)
 
def validateSessionDeviceStatus (self, client_redirect_uri, session_device_status, user_name=None)
 
def getSessionDeviceStatus (self, session_attributes, user_name)
 
def initPushNotificationService (self, configurationAttributes)
 
def initNativePushNotificationService (self, configurationAttributes)
 
def initSnsPushNotificationService (self, configurationAttributes)
 
def initGluuPushNotificationService (self, configurationAttributes)
 
def loadPushNotificationCreds (self, configurationAttributes)
 
def sendPushNotification (self, client_redirect_uri, user, super_gluu_request)
 
def sendPushNotificationImpl (self, client_redirect_uri, user, super_gluu_request)
 
def getTargetEndpointArn (self, deviceRegistrationService, pushSnsService, platform, user, u2fDevice)
 
def getClientRedirecUri (self, session_attributes)
 
def setRequestScopedParameters (self, identity, step)
 
def addGeolocationData (self, session_attributes, super_gluu_request_dictionary)
 
def determineGeolocationData (self, remote_ip)
 
def isUserMemberOfGroup (self, user, attribute, group)
 
def processAuditGroup (self, user, attribute, group)
 

公開変数類

 currentTimeMillis
 
 registrationUri
 
 oneStep
 
 twoStep
 
 enabledPushNotifications
 
 androidUrl
 
 IOSUrl
 
 customLabel
 
 customQrOptions
 
 use_super_gluu_group
 
 super_gluu_group
 
 use_audit_group
 
 audit_group
 
 audit_email
 
 audit_attribute
 
 valid_license
 
 license_content
 
 pushAndroidService
 
 pushAppleService
 
 pushSnsMode
 
 pushGluuMode
 
 pushAppleServiceProduction
 
 pushAndroidPlatformArn
 
 pushApplePlatformArn
 
 pushAndroidServiceAuth
 
 pushAppleServiceAuth
 

詳解

構築子と解体子

◆ __init__()

def SuperGluuExternalAuthenticator.PersonAuthentication.__init__ (   self,
  currentTimeMillis 
)
41  def __init__(self, currentTimeMillis):
42  self.currentTimeMillis = currentTimeMillis
43 

関数詳解

◆ addGeolocationData()

def SuperGluuExternalAuthenticator.PersonAuthentication.addGeolocationData (   self,
  session_attributes,
  super_gluu_request_dictionary 
)
977  def addGeolocationData(self, session_attributes, super_gluu_request_dictionary):
978  if session_attributes.containsKey("remote_ip"):
979  remote_ip = session_attributes.get("remote_ip")
980  if StringHelper.isNotEmpty(remote_ip):
981  print "Super-Gluu. Prepare for step 2. Adding req_ip and req_loc to super_gluu_request"
982  super_gluu_request_dictionary['req_ip'] = remote_ip
983 
984  remote_loc_dic = self.determineGeolocationData(remote_ip)
985  if remote_loc_dic == None:
986  print "Super-Gluu. Prepare for step 2. Failed to determine remote location by remote IP '%s'" % remote_ip
987  return
988 
989  remote_loc = "%s, %s, %s" % ( remote_loc_dic['country'], remote_loc_dic['regionName'], remote_loc_dic['city'] )
990  remote_loc_encoded = urllib.quote(remote_loc)
991  super_gluu_request_dictionary['req_loc'] = remote_loc_encoded
992 

◆ authenticate()

def SuperGluuExternalAuthenticator.PersonAuthentication.authenticate (   self,
  configurationAttributes,
  requestParameters,
  step 
)
159  def authenticate(self, configurationAttributes, requestParameters, step):
160  authenticationService = CdiUtil.bean(AuthenticationService)
161 
162  identity = CdiUtil.bean(Identity)
163  credentials = identity.getCredentials()
164 
165  session_attributes = identity.getSessionId().getSessionAttributes()
166 
167  client_redirect_uri = self.getClientRedirecUri(session_attributes)
168  if client_redirect_uri == None:
169  print "Super-Gluu. Authenticate. redirect_uri is not set"
170  return False
171 
172  self.setRequestScopedParameters(identity, step)
173 
174  # Validate form result code and initialize QR code regeneration if needed (retry_current_step = True)
175  identity.setWorkingParameter("retry_current_step", False)
176  form_auth_result = ServerUtil.getFirstValue(requestParameters, "auth_result")
177  if StringHelper.isNotEmpty(form_auth_result):
178  print "Super-Gluu. Authenticate for step %s. Get auth_result: '%s'" % (step, form_auth_result)
179  if form_auth_result in ['error']:
180  return False
181 
182  if form_auth_result in ['timeout']:
183  if ((step == 1) and self.oneStep) or ((step == 2) and self.twoStep):
184  print "Super-Gluu. Authenticate for step %s. Reinitializing current step" % step
185  identity.setWorkingParameter("retry_current_step", True)
186  return False
187 
188  userService = CdiUtil.bean(UserService)
189  deviceRegistrationService = CdiUtil.bean(DeviceRegistrationService)
190  if step == 1:
191  print "Super-Gluu. Authenticate for step 1"
192 
193  user_name = credentials.getUsername()
194  if self.oneStep:
195  session_device_status = self.getSessionDeviceStatus(session_attributes, user_name)
196  if session_device_status == None:
197  return False
198 
199  u2f_device_id = session_device_status['device_id']
200 
201  validation_result = self.validateSessionDeviceStatus(client_redirect_uri, session_device_status)
202  if validation_result:
203  print "Super-Gluu. Authenticate for step 1. User successfully authenticated with u2f_device '%s'" % u2f_device_id
204  else:
205  return False
206 
207  if not session_device_status['one_step']:
208  print "Super-Gluu. Authenticate for step 1. u2f_device '%s' is not one step device" % u2f_device_id
209  return False
210 
211  # There are two steps only in enrollment mode
212  if session_device_status['enroll']:
213  return validation_result
214 
215  identity.setWorkingParameter("super_gluu_count_login_steps", 1)
216 
217  user_inum = session_device_status['user_inum']
218 
219  u2f_device = deviceRegistrationService.findUserDeviceRegistration(user_inum, u2f_device_id, "oxId")
220  if u2f_device == None:
221  print "Super-Gluu. Authenticate for step 1. Failed to load u2f_device '%s'" % u2f_device_id
222  return False
223 
224  logged_in = authenticationService.authenticate(user_name)
225  if not logged_in:
226  print "Super-Gluu. Authenticate for step 1. Failed to authenticate user '%s'" % user_name
227  return False
228 
229  print "Super-Gluu. Authenticate for step 1. User '%s' successfully authenticated with u2f_device '%s'" % (user_name, u2f_device_id)
230 
231  return True
232  elif self.twoStep:
233  authenticated_user = self.processBasicAuthentication(credentials)
234  if authenticated_user == None:
235  return False
236 
237  if (self.use_super_gluu_group):
238  print "Super-Gluu. Authenticate for step 1. Checking if user belong to super_gluu group"
239  is_member_super_gluu_group = self.isUserMemberOfGroup(authenticated_user, self.audit_attribute, self.super_gluu_group)
240  if (is_member_super_gluu_group):
241  print "Super-Gluu. Authenticate for step 1. User '%s' member of super_gluu group" % authenticated_user.getUserId()
242  super_gluu_count_login_steps = 2
243  else:
244  if self.use_audit_group:
245  self.processAuditGroup(authenticated_user, self.audit_attribute, self.audit_group)
246  super_gluu_count_login_steps = 1
247 
248  identity.setWorkingParameter("super_gluu_count_login_steps", super_gluu_count_login_steps)
249 
250  if super_gluu_count_login_steps == 1:
251  return True
252 
253  auth_method = 'authenticate'
254  enrollment_mode = ServerUtil.getFirstValue(requestParameters, "loginForm:registerButton")
255  if StringHelper.isNotEmpty(enrollment_mode):
256  auth_method = 'enroll'
257 
258  if auth_method == 'authenticate':
259  user_inum = userService.getUserInum(authenticated_user)
260  u2f_devices_list = deviceRegistrationService.findUserDeviceRegistrations(user_inum, client_redirect_uri, "oxId")
261  if u2f_devices_list.size() == 0:
262  auth_method = 'enroll'
263  print "Super-Gluu. Authenticate for step 1. There is no U2F '%s' user devices associated with application '%s'. Changing auth_method to '%s'" % (user_name, client_redirect_uri, auth_method)
264 
265  print "Super-Gluu. Authenticate for step 1. auth_method: '%s'" % auth_method
266 
267  identity.setWorkingParameter("super_gluu_auth_method", auth_method)
268 
269  return True
270 
271  return False
272  elif step == 2:
273  print "Super-Gluu. Authenticate for step 2"
274 
275  user = authenticationService.getAuthenticatedUser()
276  if (user == None):
277  print "Super-Gluu. Authenticate for step 2. Failed to determine user name"
278  return False
279  user_name = user.getUserId()
280 
281  session_attributes = identity.getSessionId().getSessionAttributes()
282 
283  session_device_status = self.getSessionDeviceStatus(session_attributes, user_name)
284  if session_device_status == None:
285  return False
286 
287  u2f_device_id = session_device_status['device_id']
288 
289  # There are two steps only in enrollment mode
290  if self.oneStep and session_device_status['enroll']:
291  authenticated_user = self.processBasicAuthentication(credentials)
292  if authenticated_user == None:
293  return False
294 
295  user_inum = userService.getUserInum(authenticated_user)
296 
297  attach_result = deviceRegistrationService.attachUserDeviceRegistration(user_inum, u2f_device_id)
298 
299  print "Super-Gluu. Authenticate for step 2. Result after attaching u2f_device '%s' to user '%s': '%s'" % (u2f_device_id, user_name, attach_result)
300 
301  return attach_result
302  elif self.twoStep:
303  if user_name == None:
304  print "Super-Gluu. Authenticate for step 2. Failed to determine user name"
305  return False
306 
307  validation_result = self.validateSessionDeviceStatus(client_redirect_uri, session_device_status, user_name)
308  if validation_result:
309  print "Super-Gluu. Authenticate for step 2. User '%s' successfully authenticated with u2f_device '%s'" % (user_name, u2f_device_id)
310  else:
311  return False
312 
313  super_gluu_request = json.loads(session_device_status['super_gluu_request'])
314  auth_method = super_gluu_request['method']
315  if auth_method in ['enroll', 'authenticate']:
316  if validation_result and self.use_audit_group:
317  user = authenticationService.getAuthenticatedUser()
318  self.processAuditGroup(user, self.audit_attribute, self.audit_group)
319 
320  return validation_result
321 
322  print "Super-Gluu. Authenticate for step 2. U2F auth_method is invalid"
323 
324  return False
325  else:
326  return False
327 

◆ destroy()

def SuperGluuExternalAuthenticator.PersonAuthentication.destroy (   self,
  configurationAttributes 
)
141  def destroy(self, configurationAttributes):
142  print "Super-Gluu. Destroy"
143 
144  self.pushAndroidService = None
145  self.pushAppleService = None
146 
147  print "Super-Gluu. Destroyed successfully"
148  return True
149 

◆ determineGeolocationData()

def SuperGluuExternalAuthenticator.PersonAuthentication.determineGeolocationData (   self,
  remote_ip 
)
993  def determineGeolocationData(self, remote_ip):
994  print "Super-Gluu. Determine remote location. remote_ip: '%s'" % remote_ip
995  httpService = CdiUtil.bean(HttpService)
996 
997  http_client = httpService.getHttpsClient()
998  http_client_params = http_client.getParams()
999  http_client_params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 15 * 1000)
1000 
1001  geolocation_service_url = "http://ip-api.com/json/%s?fields=49177" % remote_ip
1002  geolocation_service_headers = { "Accept" : "application/json" }
1003 
1004  try:
1005  http_service_response = httpService.executeGet(http_client, geolocation_service_url, geolocation_service_headers)
1006  http_response = http_service_response.getHttpResponse()
1007  except:
1008  print "Super-Gluu. Determine remote location. Exception: ", sys.exc_info()[1]
1009  return None
1010 
1011  try:
1012  if not httpService.isResponseStastusCodeOk(http_response):
1013  print "Super-Gluu. Determine remote location. Get invalid response from validation server: ", str(http_response.getStatusLine().getStatusCode())
1014  httpService.consume(http_response)
1015  return None
1016 
1017  response_bytes = httpService.getResponseContent(http_response)
1018  response_string = httpService.convertEntityToString(response_bytes)
1019  httpService.consume(http_response)
1020  finally:
1021  http_service_response.closeConnection()
1022 
1023  if response_string == None:
1024  print "Super-Gluu. Determine remote location. Get empty response from location server"
1025  return None
1026 
1027  response = json.loads(response_string)
1028 
1029  if not StringHelper.equalsIgnoreCase(response['status'], "success"):
1030  print "Super-Gluu. Determine remote location. Get response with status: '%s'" % response['status']
1031  return None
1032 
1033  return response
1034 

◆ getAlternativeAuthenticationMethod()

def SuperGluuExternalAuthenticator.PersonAuthentication.getAlternativeAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
156  def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
157  return None
158 

◆ getApiVersion()

def SuperGluuExternalAuthenticator.PersonAuthentication.getApiVersion (   self)
150  def getApiVersion(self):
151  return 2
152 

◆ getClientRedirecUri()

def SuperGluuExternalAuthenticator.PersonAuthentication.getClientRedirecUri (   self,
  session_attributes 
)
954  def getClientRedirecUri(self, session_attributes):
955  if not session_attributes.containsKey("redirect_uri"):
956  return None
957 
958  return session_attributes.get("redirect_uri")
959 

◆ getCountAuthenticationSteps()

def SuperGluuExternalAuthenticator.PersonAuthentication.getCountAuthenticationSteps (   self,
  configurationAttributes 
)
443  def getCountAuthenticationSteps(self, configurationAttributes):
444  identity = CdiUtil.bean(Identity)
445  if identity.isSetWorkingParameter("super_gluu_count_login_steps"):
446  return identity.getWorkingParameter("super_gluu_count_login_steps")
447  else:
448  return 2
449 

◆ getExtraParametersForStep()

def SuperGluuExternalAuthenticator.PersonAuthentication.getExtraParametersForStep (   self,
  configurationAttributes,
  step 
)
432  def getExtraParametersForStep(self, configurationAttributes, step):
433  if step == 1:
434  if self.oneStep:
435  return Arrays.asList("super_gluu_request")
436  elif self.twoStep:
437  return Arrays.asList("display_register_action")
438  elif step == 2:
439  return Arrays.asList("super_gluu_auth_method", "super_gluu_request")
440 
441  return None
442 

◆ getNextStep()

def SuperGluuExternalAuthenticator.PersonAuthentication.getNextStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
417  def getNextStep(self, configurationAttributes, requestParameters, step):
418  # If user not pass current step change step to previous
419  identity = CdiUtil.bean(Identity)
420  retry_current_step = identity.getWorkingParameter("retry_current_step")
421  if retry_current_step:
422  print "Super-Gluu. Get next step. Retrying current step"
423 
424  # Remove old QR code
425  identity.setWorkingParameter("super_gluu_request", "timeout")
426 
427  resultStep = step
428  return resultStep
429 
430  return -1
431 

◆ getPageForStep()

def SuperGluuExternalAuthenticator.PersonAuthentication.getPageForStep (   self,
  configurationAttributes,
  step 
)
450  def getPageForStep(self, configurationAttributes, step):
451  if step == 1:
452  if self.oneStep:
453  return "/auth/super-gluu/login.xhtml"
454  elif step == 2:
455  if self.oneStep:
456  return "/login.xhtml"
457  else:
458  identity = CdiUtil.bean(Identity)
459  authmethod = identity.getWorkingParameter("super_gluu_auth_method")
460  print "Super-Gluu. authmethod '%s'" % authmethod
461  if authmethod == "enroll":
462  return "/auth/super-gluu/login.xhtml"
463  else:
464  return "/auth/super-gluu/login.xhtml"
465 
466  return ""
467 

◆ getSessionDeviceStatus()

def SuperGluuExternalAuthenticator.PersonAuthentication.getSessionDeviceStatus (   self,
  session_attributes,
  user_name 
)
521  def getSessionDeviceStatus(self, session_attributes, user_name):
522  print "Super-Gluu. Get session device status"
523 
524  if not session_attributes.containsKey("super_gluu_request"):
525  print "Super-Gluu. Get session device status. There is no Super-Gluu request in session attributes"
526  return None
527 
528  # Check session state extended
529  if not session_attributes.containsKey("session_custom_state"):
530  print "Super-Gluu. Get session device status. There is no session_custom_state in session attributes"
531  return None
532 
533  session_custom_state = session_attributes.get("session_custom_state")
534  if not StringHelper.equalsIgnoreCase("approved", session_custom_state):
535  print "Super-Gluu. Get session device status. User '%s' not approve or not pass U2F authentication. session_custom_state: '%s'" % (user_name, session_custom_state)
536  return None
537 
538  # Try to find device_id in session attribute
539  if not session_attributes.containsKey("oxpush2_u2f_device_id"):
540  print "Super-Gluu. Get session device status. There is no u2f_device associated with this request"
541  return None
542 
543  # Try to find user_inum in session attribute
544  if not session_attributes.containsKey("oxpush2_u2f_device_user_inum"):
545  print "Super-Gluu. Get session device status. There is no user_inum associated with this request"
546  return None
547 
548  enroll = False
549  if session_attributes.containsKey("oxpush2_u2f_device_enroll"):
550  enroll = StringHelper.equalsIgnoreCase("true", session_attributes.get("oxpush2_u2f_device_enroll"))
551 
552  one_step = False
553  if session_attributes.containsKey("oxpush2_u2f_device_one_step"):
554  one_step = StringHelper.equalsIgnoreCase("true", session_attributes.get("oxpush2_u2f_device_one_step"))
555 
556  super_gluu_request = session_attributes.get("super_gluu_request")
557  u2f_device_id = session_attributes.get("oxpush2_u2f_device_id")
558  user_inum = session_attributes.get("oxpush2_u2f_device_user_inum")
559 
560  session_device_status = {"super_gluu_request": super_gluu_request, "device_id": u2f_device_id, "user_inum" : user_inum, "enroll" : enroll, "one_step" : one_step}
561  print "Super-Gluu. Get session device status. session_device_status: '%s'" % (session_device_status)
562 
563  return session_device_status
564 

◆ getTargetEndpointArn()

def SuperGluuExternalAuthenticator.PersonAuthentication.getTargetEndpointArn (   self,
  deviceRegistrationService,
  pushSnsService,
  platform,
  user,
  u2fDevice 
)
897  def getTargetEndpointArn(self, deviceRegistrationService, pushSnsService, platform, user, u2fDevice):
898  targetEndpointArn = None
899 
900  # Return endpoint ARN if it created already
901  notificationConf = u2fDevice.getDeviceNotificationConf()
902  if StringHelper.isNotEmpty(notificationConf):
903  notificationConfJson = json.loads(notificationConf)
904  targetEndpointArn = notificationConfJson['sns_endpoint_arn']
905  if StringHelper.isNotEmpty(targetEndpointArn):
906  print "Super-Gluu. Get target endpoint ARN. There is already created target endpoint ARN"
907  return targetEndpointArn
908 
909  # Create endpoint ARN
910  pushClient = None
911  pushClientAuth = None
912  platformApplicationArn = None
913  if platform == PushPlatform.GCM:
914  pushClient = self.pushAndroidService
915  if self.pushSnsMode:
916  platformApplicationArn = self.pushAndroidPlatformArn
917  if self.pushGluuMode:
918  pushClientAuth = self.pushAndroidServiceAuth
919  elif platform == PushPlatform.APNS:
920  pushClient = self.pushAppleService
921  if self.pushSnsMode:
922  platformApplicationArn = self.pushApplePlatformArn
923  if self.pushGluuMode:
924  pushClientAuth = self.pushAppleServiceAuth
925  else:
926  return None
927 
928  deviceData = u2fDevice.getDeviceData()
929  pushToken = deviceData.getPushToken()
930 
931  print "Super-Gluu. Get target endpoint ARN. Attempting to create target endpoint ARN for user: '%s'" % user.getUserId()
932  if self.pushSnsMode:
933  targetEndpointArn = pushSnsService.createPlatformArn(pushClient, platformApplicationArn, pushToken, user)
934  else:
935  customUserData = pushSnsService.getCustomUserData(user)
936  registerDeviceResponse = pushClient.registerDevice(pushClientAuth, pushToken, customUserData);
937  if registerDeviceResponse != None and registerDeviceResponse.getStatusCode() == 200:
938  targetEndpointArn = registerDeviceResponse.getEndpointArn()
939 
940  if StringHelper.isEmpty(targetEndpointArn):
941  print "Super-Gluu. Failed to get endpoint ARN for user: '%s'" % user.getUserId()
942  return None
943 
944  print "Super-Gluu. Get target endpoint ARN. Create target endpoint ARN '%s' for user: '%s'" % (targetEndpointArn, user.getUserId())
945 
946  # Store created endpoint ARN in device entry
947  userInum = user.getAttribute("inum")
948  u2fDeviceUpdate = deviceRegistrationService.findUserDeviceRegistration(userInum, u2fDevice.getId())
949  u2fDeviceUpdate.setDeviceNotificationConf('{"sns_endpoint_arn" : "%s"}' % targetEndpointArn)
950  deviceRegistrationService.updateDeviceRegistration(userInum, u2fDeviceUpdate)
951 
952  return targetEndpointArn
953 

◆ init()

def SuperGluuExternalAuthenticator.PersonAuthentication.init (   self,
  configurationAttributes 
)
44  def init(self, configurationAttributes):
45  print "Super-Gluu. Initialization"
46 
47  if not configurationAttributes.containsKey("authentication_mode"):
48  print "Super-Gluu. Initialization. Property authentication_mode is mandatory"
49  return False
50 
51  self.registrationUri = None
52  if configurationAttributes.containsKey("registration_uri"):
53  self.registrationUri = configurationAttributes.get("registration_uri").getValue2()
54 
55  authentication_mode = configurationAttributes.get("authentication_mode").getValue2()
56  if StringHelper.isEmpty(authentication_mode):
57  print "Super-Gluu. Initialization. Failed to determine authentication_mode. authentication_mode configuration parameter is empty"
58  return False
59 
60  self.oneStep = StringHelper.equalsIgnoreCase(authentication_mode, "one_step")
61  self.twoStep = StringHelper.equalsIgnoreCase(authentication_mode, "two_step")
62 
63  if not (self.oneStep or self.twoStep):
64  print "Super-Gluu. Initialization. Valid authentication_mode values are one_step and two_step"
65  return False
66 
67  self.enabledPushNotifications = self.initPushNotificationService(configurationAttributes)
68 
69  self.androidUrl = None
70  if configurationAttributes.containsKey("supergluu_android_download_url"):
71  self.androidUrl = configurationAttributes.get("supergluu_android_download_url").getValue2()
72 
73  self.IOSUrl = None
74  if configurationAttributes.containsKey("supergluu_ios_download_url"):
75  self.IOSUrl = configurationAttributes.get("supergluu_ios_download_url").getValue2()
76 
77  self.customLabel = None
78  if configurationAttributes.containsKey("label"):
79  self.customLabel = configurationAttributes.get("label").getValue2()
80 
81  self.customQrOptions = {}
82  if configurationAttributes.containsKey("qr_options"):
83  self.customQrOptions = configurationAttributes.get("qr_options").getValue2()
84 
85  self.use_super_gluu_group = False
86  if configurationAttributes.containsKey("super_gluu_group"):
87  self.super_gluu_group = configurationAttributes.get("super_gluu_group").getValue2()
88  self.use_super_gluu_group = True
89  print "Super-Gluu. Initialization. Using super_gluu only if user belong to group: %s" % self.super_gluu_group
90 
91  self.use_audit_group = False
92  if configurationAttributes.containsKey("audit_group"):
93  self.audit_group = configurationAttributes.get("audit_group").getValue2()
94 
95  if (not configurationAttributes.containsKey("audit_group_email")):
96  print "Super-Gluu. Initialization. Property audit_group_email is not specified"
97  return False
98 
99  self.audit_email = configurationAttributes.get("audit_group_email").getValue2()
100  self.use_audit_group = True
101 
102  print "Super-Gluu. Initialization. Using audit group: %s" % self.audit_group
103 
104  if self.use_super_gluu_group or self.use_audit_group:
105  if not configurationAttributes.containsKey("audit_attribute"):
106  print "Super-Gluu. Initialization. Property audit_attribute is not specified"
107  return False
108  else:
109  self.audit_attribute = configurationAttributes.get("audit_attribute").getValue2()
110 
111  self.valid_license = False
112  # Removing or altering this block validation is against the terms of the license.
113  if has_license_api and configurationAttributes.containsKey("license_file"):
114  license_file = configurationAttributes.get("license_file").getValue2()
115 
116  # Load license from file
117  f = open(license_file, 'r')
118  try:
119  license = json.loads(f.read())
120  except:
121  print "Super-Gluu. Initialization. Failed to load license from file: %s" % license_file
122  return False
123  finally:
124  f.close()
125 
126  # Validate license
127  try:
128  self.license_content = LicenseValidator.validate(license["public_key"], license["public_password"], license["license_password"], license["license"],
129  Product.fromValue("super_gluu"), Date())
130  self.valid_license = self.license_content.isValid()
131  except:
132  print "Super-Gluu. Initialization. Failed to validate license. Exception: ", sys.exc_info()[1]
133  return False
134 
135  print "Super-Gluu. Initialization. License status: '%s'. License metadata: '%s'" % (self.valid_license, self.license_content.getMetadata())
136 
137  print "Super-Gluu. Initialized successfully. oneStep: '%s', twoStep: '%s', pushNotifications: '%s', customLabel: '%s'" % (self.oneStep, self.twoStep, self.enabledPushNotifications, self.customLabel)
138 
139  return True
140 

◆ initGluuPushNotificationService()

def SuperGluuExternalAuthenticator.PersonAuthentication.initGluuPushNotificationService (   self,
  configurationAttributes 
)
676  def initGluuPushNotificationService(self, configurationAttributes):
677  print "Super-Gluu. Initialize Gluu notification services"
678 
679  self.pushGluuMode = True
680 
681  creds = self.loadPushNotificationCreds(configurationAttributes)
682  if creds == None:
683  return False
684 
685  try:
686  gluu_conf = creds["gluu"]
687  android_creds = creds["android"]["gluu"]
688  ios_creds = creds["ios"]["gluu"]
689  except:
690  print "Super-Gluu. Initialize Gluu notification services. Invalid credentials file format"
691  return False
692 
693  self.pushAndroidService = None
694  self.pushAppleService = None
695  if not (android_creds["enabled"] or ios_creds["enabled"]):
696  print "Super-Gluu. Initialize Gluu notification services. Gluu disabled for all platforms"
697  return False
698 
699  gluu_server_uri = gluu_conf["server_uri"]
700  notifyClientFactory = NotifyClientFactory.instance()
701  metadataConfiguration = None
702  try:
703  metadataConfiguration = notifyClientFactory.createMetaDataConfigurationService(gluu_server_uri).getMetadataConfiguration()
704  except:
705  print "Super-Gluu. Initialize Gluu notification services. Failed to load metadata. Exception: ", sys.exc_info()[1]
706  return False
707 
708  gluuClient = notifyClientFactory.createNotifyService(metadataConfiguration)
709  encryptionService = CdiUtil.bean(EncryptionService)
710 
711  if android_creds["enabled"]:
712  gluu_access_key = android_creds["access_key"]
713  gluu_secret_access_key = android_creds["secret_access_key"]
714 
715  try:
716  gluu_secret_access_key = encryptionService.decrypt(gluu_secret_access_key)
717  except:
718  # Ignore exception. Password is not encrypted
719  print "Super-Gluu. Initialize Gluu notification services. Assuming that 'gluu_secret_access_key' in not encrypted"
720 
721  self.pushAndroidService = gluuClient
722  self.pushAndroidServiceAuth = notifyClientFactory.getAuthorization(gluu_access_key, gluu_secret_access_key);
723  print "Super-Gluu. Initialize Gluu notification services. Created Android notification service"
724 
725  if ios_creds["enabled"]:
726  gluu_access_key = ios_creds["access_key"]
727  gluu_secret_access_key = ios_creds["secret_access_key"]
728 
729  try:
730  gluu_secret_access_key = encryptionService.decrypt(gluu_secret_access_key)
731  except:
732  # Ignore exception. Password is not encrypted
733  print "Super-Gluu. Initialize Gluu notification services. Assuming that 'gluu_secret_access_key' in not encrypted"
734 
735  self.pushAppleService = gluuClient
736  self.pushAppleServiceAuth = notifyClientFactory.getAuthorization(gluu_access_key, gluu_secret_access_key);
737  print "Super-Gluu. Initialize Gluu notification services. Created iOS notification service"
738 
739  enabled = self.pushAndroidService != None or self.pushAppleService != None
740 
741  return enabled
742 

◆ initNativePushNotificationService()

def SuperGluuExternalAuthenticator.PersonAuthentication.initNativePushNotificationService (   self,
  configurationAttributes 
)
579  def initNativePushNotificationService(self, configurationAttributes):
580  print "Super-Gluu. Initialize native notification services"
581 
582  creds = self.loadPushNotificationCreds(configurationAttributes)
583  if creds == None:
584  return False
585 
586  try:
587  android_creds = creds["android"]["gcm"]
588  ios_creds = creds["ios"]["apns"]
589  except:
590  print "Super-Gluu. Initialize native notification services. Invalid credentials file format"
591  return False
592 
593  self.pushAndroidService = None
594  self.pushAppleService = None
595  if android_creds["enabled"]:
596  self.pushAndroidService = Sender(android_creds["api_key"])
597  print "Super-Gluu. Initialize native notification services. Created Android notification service"
598 
599  if ios_creds["enabled"]:
600  p12_file_path = ios_creds["p12_file_path"]
601  p12_passowrd = ios_creds["p12_password"]
602 
603  try:
604  encryptionService = CdiUtil.bean(EncryptionService)
605  p12_passowrd = encryptionService.decrypt(p12_passowrd)
606  except:
607  # Ignore exception. Password is not encrypted
608  print "Super-Gluu. Initialize native notification services. Assuming that 'p12_passowrd' password in not encrypted"
609 
610  apnsServiceBuilder = APNS.newService().withCert(p12_file_path, p12_passowrd)
611  if ios_creds["production"]:
612  self.pushAppleService = apnsServiceBuilder.withProductionDestination().build()
613  else:
614  self.pushAppleService = apnsServiceBuilder.withSandboxDestination().build()
615 
616  self.pushAppleServiceProduction = ios_creds["production"]
617 
618  print "Super-Gluu. Initialize native notification services. Created iOS notification service"
619 
620  enabled = self.pushAndroidService != None or self.pushAppleService != None
621 
622  return enabled
623 

◆ initPushNotificationService()

def SuperGluuExternalAuthenticator.PersonAuthentication.initPushNotificationService (   self,
  configurationAttributes 
)
565  def initPushNotificationService(self, configurationAttributes):
566  print "Super-Gluu. Initialize Native/SNS/Gluu notification services"
567 
568  self.pushSnsMode = False
569  self.pushGluuMode = False
570  if configurationAttributes.containsKey("notification_service_mode"):
571  notificationServiceMode = configurationAttributes.get("notification_service_mode").getValue2()
572  if StringHelper.equalsIgnoreCase(notificationServiceMode, "sns"):
573  return self.initSnsPushNotificationService(configurationAttributes)
574  elif StringHelper.equalsIgnoreCase(notificationServiceMode, "gluu"):
575  return self.initGluuPushNotificationService(configurationAttributes)
576 
577  return self.initNativePushNotificationService(configurationAttributes)
578 

◆ initSnsPushNotificationService()

def SuperGluuExternalAuthenticator.PersonAuthentication.initSnsPushNotificationService (   self,
  configurationAttributes 
)
624  def initSnsPushNotificationService(self, configurationAttributes):
625  print "Super-Gluu. Initialize SNS notification services"
626  self.pushSnsMode = True
627 
628  creds = self.loadPushNotificationCreds(configurationAttributes)
629  if creds == None:
630  return False
631 
632  try:
633  sns_creds = creds["sns"]
634  android_creds = creds["android"]["sns"]
635  ios_creds = creds["ios"]["sns"]
636  except:
637  print "Super-Gluu. Initialize SNS notification services. Invalid credentials file format"
638  return False
639 
640  self.pushAndroidService = None
641  self.pushAppleService = None
642  if not (android_creds["enabled"] or ios_creds["enabled"]):
643  print "Super-Gluu. Initialize SNS notification services. SNS disabled for all platforms"
644  return False
645 
646  sns_access_key = sns_creds["access_key"]
647  sns_secret_access_key = sns_creds["secret_access_key"]
648  sns_region = sns_creds["region"]
649 
650  encryptionService = CdiUtil.bean(EncryptionService)
651 
652  try:
653  sns_secret_access_key = encryptionService.decrypt(sns_secret_access_key)
654  except:
655  # Ignore exception. Password is not encrypted
656  print "Super-Gluu. Initialize SNS notification services. Assuming that 'sns_secret_access_key' in not encrypted"
657 
658  pushSnsService = CdiUtil.bean(PushSnsService)
659  pushClient = pushSnsService.createSnsClient(sns_access_key, sns_secret_access_key, sns_region)
660 
661  if android_creds["enabled"]:
662  self.pushAndroidService = pushClient
663  self.pushAndroidPlatformArn = android_creds["platform_arn"]
664  print "Super-Gluu. Initialize SNS notification services. Created Android notification service"
665 
666  if ios_creds["enabled"]:
667  self.pushAppleService = pushClient
668  self.pushApplePlatformArn = ios_creds["platform_arn"]
669  self.pushAppleServiceProduction = ios_creds["production"]
670  print "Super-Gluu. Initialize SNS notification services. Created iOS notification service"
671 
672  enabled = self.pushAndroidService != None or self.pushAppleService != None
673 
674  return enabled
675 

◆ isUserMemberOfGroup()

def SuperGluuExternalAuthenticator.PersonAuthentication.isUserMemberOfGroup (   self,
  user,
  attribute,
  group 
)
1035  def isUserMemberOfGroup(self, user, attribute, group):
1036  is_member = False
1037  member_of_list = user.getAttributeValues(attribute)
1038  if (member_of_list != None):
1039  for member_of in member_of_list:
1040  if StringHelper.equalsIgnoreCase(group, member_of) or member_of.endswith(group):
1041  is_member = True
1042  break
1043 
1044  return is_member
1045 

◆ isValidAuthenticationMethod()

def SuperGluuExternalAuthenticator.PersonAuthentication.isValidAuthenticationMethod (   self,
  usageType,
  configurationAttributes 
)
153  def isValidAuthenticationMethod(self, usageType, configurationAttributes):
154  return True
155 

◆ loadPushNotificationCreds()

def SuperGluuExternalAuthenticator.PersonAuthentication.loadPushNotificationCreds (   self,
  configurationAttributes 
)
743  def loadPushNotificationCreds(self, configurationAttributes):
744  print "Super-Gluu. Initialize notification services"
745  if not configurationAttributes.containsKey("credentials_file"):
746  return None
747 
748  super_gluu_creds_file = configurationAttributes.get("credentials_file").getValue2()
749 
750  # Load credentials from file
751  f = open(super_gluu_creds_file, 'r')
752  try:
753  creds = json.loads(f.read())
754  except:
755  print "Super-Gluu. Initialize notification services. Failed to load credentials from file:", super_gluu_creds_file
756  return None
757  finally:
758  f.close()
759 
760  return creds
761 

◆ logout()

def SuperGluuExternalAuthenticator.PersonAuthentication.logout (   self,
  configurationAttributes,
  requestParameters 
)
468  def logout(self, configurationAttributes, requestParameters):
469  return True
470 

◆ prepareForStep()

def SuperGluuExternalAuthenticator.PersonAuthentication.prepareForStep (   self,
  configurationAttributes,
  requestParameters,
  step 
)
328  def prepareForStep(self, configurationAttributes, requestParameters, step):
329  identity = CdiUtil.bean(Identity)
330  session_attributes = identity.getSessionId().getSessionAttributes()
331 
332  client_redirect_uri = self.getClientRedirecUri(session_attributes)
333  if client_redirect_uri == None:
334  print "Super-Gluu. Prepare for step. redirect_uri is not set"
335  return False
336 
337  self.setRequestScopedParameters(identity, step)
338 
339  if step == 1:
340  print "Super-Gluu. Prepare for step 1"
341  if self.oneStep:
342  session_id = CdiUtil.bean(SessionIdService).getSessionIdFromCookie()
343  if StringHelper.isEmpty(session_id):
344  print "Super-Gluu. Prepare for step 2. Failed to determine session_id"
345  return False
346 
347  issuer = CdiUtil.bean(ConfigurationFactory).getConfiguration().getIssuer()
348  super_gluu_request_dictionary = {'app': client_redirect_uri,
349  'issuer': issuer,
350  'state': session_id,
351  'licensed': self.valid_license,
352  'created': datetime.datetime.now().isoformat()}
353 
354  self.addGeolocationData(session_attributes, super_gluu_request_dictionary)
355 
356  super_gluu_request = json.dumps(super_gluu_request_dictionary, separators=(',',':'))
357  print "Super-Gluu. Prepare for step 1. Prepared super_gluu_request:", super_gluu_request
358 
359  identity.setWorkingParameter("super_gluu_request", super_gluu_request)
360  elif self.twoStep:
361  identity.setWorkingParameter("display_register_action", True)
362 
363  return True
364  elif step == 2:
365  print "Super-Gluu. Prepare for step 2"
366  if self.oneStep:
367  return True
368 
369  authenticationService = CdiUtil.bean(AuthenticationService)
370  user = authenticationService.getAuthenticatedUser()
371  if user == None:
372  print "Super-Gluu. Prepare for step 2. Failed to determine user name"
373  return False
374 
375  if session_attributes.containsKey("super_gluu_request"):
376  super_gluu_request = session_attributes.get("super_gluu_request")
377  if not StringHelper.equalsIgnoreCase(super_gluu_request, "timeout"):
378  print "Super-Gluu. Prepare for step 2. Request was generated already"
379  return True
380 
381  session_id = CdiUtil.bean(SessionIdService).getSessionIdFromCookie()
382  if StringHelper.isEmpty(session_id):
383  print "Super-Gluu. Prepare for step 2. Failed to determine session_id"
384  return False
385 
386  auth_method = session_attributes.get("super_gluu_auth_method")
387  if StringHelper.isEmpty(auth_method):
388  print "Super-Gluu. Prepare for step 2. Failed to determine auth_method"
389  return False
390 
391  print "Super-Gluu. Prepare for step 2. auth_method: '%s'" % auth_method
392 
393  issuer = CdiUtil.bean(ConfigurationFactory).getAppConfiguration().getIssuer()
394  super_gluu_request_dictionary = {'username': user.getUserId(),
395  'app': client_redirect_uri,
396  'issuer': issuer,
397  'method': auth_method,
398  'state': session_id,
399  'licensed': self.valid_license,
400  'created': datetime.datetime.now().isoformat()}
401 
402  self.addGeolocationData(session_attributes, super_gluu_request_dictionary)
403 
404  super_gluu_request = json.dumps(super_gluu_request_dictionary, separators=(',',':'))
405  print "Super-Gluu. Prepare for step 2. Prepared super_gluu_request:", super_gluu_request
406 
407  identity.setWorkingParameter("super_gluu_request", super_gluu_request)
408  identity.setWorkingParameter("super_gluu_auth_method", auth_method)
409 
410  if auth_method in ['authenticate']:
411  self.sendPushNotification(client_redirect_uri, user, super_gluu_request)
412 
413  return True
414  else:
415  return False
416 

◆ processAuditGroup()

def SuperGluuExternalAuthenticator.PersonAuthentication.processAuditGroup (   self,
  user,
  attribute,
  group 
)
1046  def processAuditGroup(self, user, attribute, group):
1047  is_member = self.isUserMemberOfGroup(user, attribute, group)
1048  if (is_member):
1049  print "Super-Gluu. Authenticate for processAuditGroup. User '%s' member of audit group" % user.getUserId()
1050  print "Super-Gluu. Authenticate for processAuditGroup. Sending e-mail about user '%s' login to %s" % (user.getUserId(), self.audit_email)
1051 
1052  # Send e-mail to administrator
1053  user_id = user.getUserId()
1054  mailService = CdiUtil.bean(MailService)
1055  subject = "User log in: %s" % user_id
1056  body = "User log in: %s" % user_id
1057  mailService.sendMail(self.audit_email, subject, body)
1058 

◆ processBasicAuthentication()

def SuperGluuExternalAuthenticator.PersonAuthentication.processBasicAuthentication (   self,
  credentials 
)
471  def processBasicAuthentication(self, credentials):
472  authenticationService = CdiUtil.bean(AuthenticationService)
473 
474  user_name = credentials.getUsername()
475  user_password = credentials.getPassword()
476 
477  logged_in = False
478  if StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password):
479  logged_in = authenticationService.authenticate(user_name, user_password)
480 
481  if not logged_in:
482  return None
483 
484  find_user_by_uid = authenticationService.getAuthenticatedUser()
485  if find_user_by_uid == None:
486  print "Super-Gluu. Process basic authentication. Failed to find user '%s'" % user_name
487  return None
488 
489  return find_user_by_uid
490 

◆ sendPushNotification()

def SuperGluuExternalAuthenticator.PersonAuthentication.sendPushNotification (   self,
  client_redirect_uri,
  user,
  super_gluu_request 
)
762  def sendPushNotification(self, client_redirect_uri, user, super_gluu_request):
763  try:
764  self.sendPushNotificationImpl(client_redirect_uri, user, super_gluu_request)
765  except:
766  print "Super-Gluu. Send push notification. Failed to send push notification: ", sys.exc_info()[1]
767 

◆ sendPushNotificationImpl()

def SuperGluuExternalAuthenticator.PersonAuthentication.sendPushNotificationImpl (   self,
  client_redirect_uri,
  user,
  super_gluu_request 
)
768  def sendPushNotificationImpl(self, client_redirect_uri, user, super_gluu_request):
769  if not self.enabledPushNotifications:
770  return
771 
772  user_name = user.getUserId()
773  print "Super-Gluu. Send push notification. Loading user '%s' devices" % user_name
774 
775  send_notification = False
776  send_notification_result = True
777 
778  userService = CdiUtil.bean(UserService)
779  deviceRegistrationService = CdiUtil.bean(DeviceRegistrationService)
780 
781  user_inum = userService.getUserInum(user_name)
782 
783  send_android = 0
784  send_ios = 0
785  u2f_devices_list = deviceRegistrationService.findUserDeviceRegistrations(user_inum, client_redirect_uri, "oxId", "oxDeviceData", "oxDeviceNotificationConf")
786  if u2f_devices_list.size() > 0:
787  for u2f_device in u2f_devices_list:
788  device_data = u2f_device.getDeviceData()
789 
790  # Device data which Super-Gluu gets during enrollment
791  if device_data == None:
792  continue
793 
794  platform = device_data.getPlatform()
795  push_token = device_data.getPushToken()
796  debug = False
797 
798  if StringHelper.equalsIgnoreCase(platform, "ios") and StringHelper.isNotEmpty(push_token):
799  # Sending notification to iOS user's device
800  if self.pushAppleService == None:
801  print "Super-Gluu. Send push notification. Apple native push notification service is not enabled"
802  else:
803  send_notification = True
804 
805  title = "Super-Gluu"
806  message = "Super-Gluu login request to: %s" % client_redirect_uri
807 
808  if self.pushSnsMode or self.pushGluuMode:
809  pushSnsService = CdiUtil.bean(PushSnsService)
810  targetEndpointArn = self.getTargetEndpointArn(deviceRegistrationService, pushSnsService, PushPlatform.APNS, user, u2f_device)
811  if targetEndpointArn == None:
812  return
813 
814  send_notification = True
815 
816  sns_push_request_dictionary = { "aps":
817  { "badge": 0,
818  "alert" : {"body": message, "title" : title},
819  "category": "ACTIONABLE",
820  "content-available": "1",
821  "sound": 'default'
822  },
823  "request" : super_gluu_request
824  }
825  push_message = json.dumps(sns_push_request_dictionary, separators=(',',':'))
826 
827  if self.pushSnsMode:
828  apple_push_platform = PushPlatform.APNS
829  if not self.pushAppleServiceProduction:
830  apple_push_platform = PushPlatform.APNS_SANDBOX
831 
832  send_notification_result = pushSnsService.sendPushMessage(self.pushAppleService, apple_push_platform, targetEndpointArn, push_message, None)
833  if debug:
834  print "Super-Gluu. Send iOS SNS push notification. token: '%s', message: '%s', send_notification_result: '%s', apple_push_platform: '%s'" % (push_token, push_message, send_notification_result, apple_push_platform)
835  elif self.pushGluuMode:
836  send_notification_result = self.pushAppleService.sendNotification(self.pushAppleServiceAuth, targetEndpointArn, push_message)
837  if debug:
838  print "Super-Gluu. Send iOS Gluu push notification. token: '%s', message: '%s', send_notification_result: '%s'" % (push_token, push_message, send_notification_result)
839  else:
840  additional_fields = { "request" : super_gluu_request }
841 
842  msgBuilder = APNS.newPayload().alertBody(message).alertTitle(title).sound("default")
843  msgBuilder.category('ACTIONABLE').badge(0)
844  msgBuilder.forNewsstand()
845  msgBuilder.customFields(additional_fields)
846  push_message = msgBuilder.build()
847 
848  send_notification_result = self.pushAppleService.push(push_token, push_message)
849  if debug:
850  print "Super-Gluu. Send iOS Native push notification. token: '%s', message: '%s', send_notification_result: '%s'" % (push_token, push_message, send_notification_result)
851  send_ios = send_ios + 1
852 
853  if StringHelper.equalsIgnoreCase(platform, "android") and StringHelper.isNotEmpty(push_token):
854  # Sending notification to Android user's device
855  if self.pushAndroidService == None:
856  print "Super-Gluu. Send native push notification. Android native push notification service is not enabled"
857  else:
858  send_notification = True
859 
860  title = "Super-Gluu"
861  if self.pushSnsMode or self.pushGluuMode:
862  pushSnsService = CdiUtil.bean(PushSnsService)
863  targetEndpointArn = self.getTargetEndpointArn(deviceRegistrationService, pushSnsService, PushPlatform.GCM, user, u2f_device)
864  if targetEndpointArn == None:
865  return
866 
867  send_notification = True
868 
869  sns_push_request_dictionary = { "collapse_key": "single",
870  "content_available": True,
871  "time_to_live": 60,
872  "data":
873  { "message" : super_gluu_request,
874  "title" : title }
875  }
876  push_message = json.dumps(sns_push_request_dictionary, separators=(',',':'))
877 
878  if self.pushSnsMode:
879  send_notification_result = pushSnsService.sendPushMessage(self.pushAndroidService, PushPlatform.GCM, targetEndpointArn, push_message, None)
880  if debug:
881  print "Super-Gluu. Send Android SNS push notification. token: '%s', message: '%s', send_notification_result: '%s'" % (push_token, push_message, send_notification_result)
882  elif self.pushGluuMode:
883  send_notification_result = self.pushAndroidService.sendNotification(self.pushAndroidServiceAuth, targetEndpointArn, push_message)
884  if debug:
885  print "Super-Gluu. Send Android Gluu push notification. token: '%s', message: '%s', send_notification_result: '%s'" % (push_token, push_message, send_notification_result)
886  else:
887  msgBuilder = Message.Builder().addData("message", super_gluu_request).addData("title", title).collapseKey("single").contentAvailable(True)
888  push_message = msgBuilder.build()
889 
890  send_notification_result = self.pushAndroidService.send(push_message, push_token, 3)
891  if debug:
892  print "Super-Gluu. Send Android Native push notification. token: '%s', message: '%s', send_notification_result: '%s'" % (push_token, push_message, send_notification_result)
893  send_android = send_android + 1
894 
895  print "Super-Gluu. Send push notification. send_android: '%s', send_ios: '%s'" % (send_android, send_ios)
896 

◆ setRequestScopedParameters()

def SuperGluuExternalAuthenticator.PersonAuthentication.setRequestScopedParameters (   self,
  identity,
  step 
)
960  def setRequestScopedParameters(self, identity, step):
961  downloadMap = HashMap()
962  if self.registrationUri != None:
963  identity.setWorkingParameter("external_registration_uri", self.registrationUri)
964 
965  if self.androidUrl!= None and step == 1:
966  downloadMap.put("android", self.androidUrl)
967 
968  if self.IOSUrl != None and step == 1:
969  downloadMap.put("ios", self.IOSUrl)
970 
971  if self.customLabel != None:
972  identity.setWorkingParameter("super_gluu_label", self.customLabel)
973 
974  identity.setWorkingParameter("download_url", downloadMap)
975  identity.setWorkingParameter("super_gluu_qr_options", self.customQrOptions)
976 

◆ validateSessionDeviceStatus()

def SuperGluuExternalAuthenticator.PersonAuthentication.validateSessionDeviceStatus (   self,
  client_redirect_uri,
  session_device_status,
  user_name = None 
)
491  def validateSessionDeviceStatus(self, client_redirect_uri, session_device_status, user_name = None):
492  userService = CdiUtil.bean(UserService)
493  deviceRegistrationService = CdiUtil.bean(DeviceRegistrationService)
494 
495  u2f_device_id = session_device_status['device_id']
496 
497  u2f_device = None
498  if session_device_status['enroll'] and session_device_status['one_step']:
499  u2f_device = deviceRegistrationService.findOneStepUserDeviceRegistration(u2f_device_id)
500  if u2f_device == None:
501  print "Super-Gluu. Validate session device status. There is no one step u2f_device '%s'" % u2f_device_id
502  return False
503  else:
504  # Validate if user has specified device_id enrollment
505  user_inum = userService.getUserInum(user_name)
506 
507  if session_device_status['one_step']:
508  user_inum = session_device_status['user_inum']
509 
510  u2f_device = deviceRegistrationService.findUserDeviceRegistration(user_inum, u2f_device_id)
511  if u2f_device == None:
512  print "Super-Gluu. Validate session device status. There is no u2f_device '%s' associated with user '%s'" % (u2f_device_id, user_inum)
513  return False
514 
515  if not StringHelper.equalsIgnoreCase(client_redirect_uri, u2f_device.application):
516  print "Super-Gluu. Validate session device status. u2f_device '%s' associated with other application '%s'" % (u2f_device_id, u2f_device.application)
517  return False
518 
519  return True
520 

メンバ詳解

◆ androidUrl

SuperGluuExternalAuthenticator.PersonAuthentication.androidUrl

◆ audit_attribute

SuperGluuExternalAuthenticator.PersonAuthentication.audit_attribute

◆ audit_email

SuperGluuExternalAuthenticator.PersonAuthentication.audit_email

◆ audit_group

SuperGluuExternalAuthenticator.PersonAuthentication.audit_group

◆ currentTimeMillis

SuperGluuExternalAuthenticator.PersonAuthentication.currentTimeMillis

◆ customLabel

SuperGluuExternalAuthenticator.PersonAuthentication.customLabel

◆ customQrOptions

SuperGluuExternalAuthenticator.PersonAuthentication.customQrOptions

◆ enabledPushNotifications

SuperGluuExternalAuthenticator.PersonAuthentication.enabledPushNotifications

◆ IOSUrl

SuperGluuExternalAuthenticator.PersonAuthentication.IOSUrl

◆ license_content

SuperGluuExternalAuthenticator.PersonAuthentication.license_content

◆ oneStep

SuperGluuExternalAuthenticator.PersonAuthentication.oneStep

◆ pushAndroidPlatformArn

SuperGluuExternalAuthenticator.PersonAuthentication.pushAndroidPlatformArn

◆ pushAndroidService

SuperGluuExternalAuthenticator.PersonAuthentication.pushAndroidService

◆ pushAndroidServiceAuth

SuperGluuExternalAuthenticator.PersonAuthentication.pushAndroidServiceAuth

◆ pushApplePlatformArn

SuperGluuExternalAuthenticator.PersonAuthentication.pushApplePlatformArn

◆ pushAppleService

SuperGluuExternalAuthenticator.PersonAuthentication.pushAppleService

◆ pushAppleServiceAuth

SuperGluuExternalAuthenticator.PersonAuthentication.pushAppleServiceAuth

◆ pushAppleServiceProduction

SuperGluuExternalAuthenticator.PersonAuthentication.pushAppleServiceProduction

◆ pushGluuMode

SuperGluuExternalAuthenticator.PersonAuthentication.pushGluuMode

◆ pushSnsMode

SuperGluuExternalAuthenticator.PersonAuthentication.pushSnsMode

◆ registrationUri

SuperGluuExternalAuthenticator.PersonAuthentication.registrationUri

◆ super_gluu_group

SuperGluuExternalAuthenticator.PersonAuthentication.super_gluu_group

◆ twoStep

SuperGluuExternalAuthenticator.PersonAuthentication.twoStep

◆ use_audit_group

SuperGluuExternalAuthenticator.PersonAuthentication.use_audit_group

◆ use_super_gluu_group

SuperGluuExternalAuthenticator.PersonAuthentication.use_super_gluu_group

◆ valid_license

SuperGluuExternalAuthenticator.PersonAuthentication.valid_license

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