Skip to content

Commit

Permalink
fix: update push part in SG script to conform Jans config and API (#4345
Browse files Browse the repository at this point in the history
)

Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
  • Loading branch information
yuremm and yurem authored Mar 28, 2023
1 parent 3c8f9f4 commit e1cb416
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def initPushNotificationService(self, configurationAttributes):
notificationServiceMode = configurationAttributes.get("notification_service_mode").getValue2()
if StringHelper.equalsIgnoreCase(notificationServiceMode, "sns"):
return self.initSnsPushNotificationService(configurationAttributes)
elif StringHelper.equalsIgnoreCase(notificationServiceMode, "gluu"):
elif StringHelper.equalsIgnoreCase(notificationServiceMode, "jans"):
return self.initGluuPushNotificationService(configurationAttributes)

return self.initNativePushNotificationService(configurationAttributes)
Expand Down Expand Up @@ -696,9 +696,9 @@ def initGluuPushNotificationService(self, configurationAttributes):
return False

try:
gluu_conf = creds["gluu"]
android_creds = creds["android"]["gluu"]
ios_creds = creds["ios"]["gluu"]
gluu_conf = creds["jans"]
android_creds = creds["android"]["jans"]
ios_creds = creds["ios"]["jans"]
except:
print "Super-Gluu. Initialize Gluu notification services. Invalid credentials file format"
return False
Expand Down Expand Up @@ -791,11 +791,9 @@ def sendPushNotificationImpl(self, client_redirect_uri, user, super_gluu_request
userService = CdiUtil.bean(UserService)
registrationPersistenceService = CdiUtil.bean(RegistrationPersistenceService)

user_inum = userService.getUserInum(user_name)

send_android = 0
send_ios = 0
u2f_devices_list = registrationPersistenceService.findByRpRegisteredUserDevices(user_inum, client_redirect_uri, "jansId", "jansDeviceData", "jansDeviceNotificationConf")
u2f_devices_list = registrationPersistenceService.findByRpRegisteredUserDevices(user_name, client_redirect_uri, "jansId", "jansDeviceData", "jansDeviceNotificationConf")
if u2f_devices_list.size() > 0:
for u2f_device in u2f_devices_list:
device_data = u2f_device.getDeviceData()
Expand Down Expand Up @@ -958,9 +956,10 @@ def getTargetEndpointArn(self, registrationPersistenceService, pushSnsService, p

# Store created endpoint ARN in device entry
userInum = user.getAttribute("inum")
u2fDeviceUpdate = registrationPersistenceService.findByRpRegisteredUserDevices(userInum, u2fDevice.getId())
u2fDeviceUpdate = registrationPersistenceService.findRegisteredUserDevice(userInum, u2fDevice.getId())
u2fDeviceUpdate.setDeviceNotificationConf('{"sns_endpoint_arn" : "%s"}' % targetEndpointArn)
registrationPersistenceService.update(u2fDeviceUpdate)
print "Super-Gluu. Send push notification. Stored ARN user's '%s' enpoint " % user.getUserId()

return targetEndpointArn

Expand Down

0 comments on commit e1cb416

Please sign in to comment.