def initPushNotificationService(self, configurationAttributes):
        print "Super-Gluu. Initialize notification services"
        if not configurationAttributes.containsKey("credentials_file"):
            return False

        super_gluu_creds_file = configurationAttributes.get(
            "credentials_file").getValue2()

        # Load credentials from file
        f = open(super_gluu_creds_file, 'r')
        try:
            creds = json.loads(f.read())
        except:
            print "Super-Gluu. Initialize notification services. Failed to load credentials from file:", super_gluu_creds_file
            return False
        finally:
            f.close()

        try:
            android_creds = creds["android"]["gcm"]
            ios_creads = creds["ios"]["apns"]
        except:
            print "Super-Gluu. Initialize notification services. Invalid credentials file '%s' format:" % super_gluu_creds_file
            return False

        self.pushAndroidService = None
        self.pushAppleService = None
        if android_creds["enabled"]:
            self.pushAndroidService = Sender(android_creds["api_key"])
            print "Super-Gluu. Initialize notification services. Created Android notification service"

        if ios_creads["enabled"]:
            p12_file_path = ios_creads["p12_file_path"]
            p12_passowrd = ios_creads["p12_password"]

            try:
                stringEncrypter = StringEncrypter.defaultInstance()
                p12_passowrd = stringEncrypter.decrypt(p12_passowrd)
            except:
                # Ignore exception. Password is not encrypted
                print "Super-Gluu. Initialize notification services. Assuming that 'p12_passowrd' password in not encrypted"

            apnsServiceBuilder = APNS.newService().withCert(
                p12_file_path, p12_passowrd)
            if ios_creads["production"]:
                self.pushAppleService = apnsServiceBuilder.withProductionDestination(
                ).build()
            else:
                self.pushAppleService = apnsServiceBuilder.withSandboxDestination(
                ).build()

            print "Super-Gluu. Initialize notification services. Created iOS notification service"

        enabled = self.pushAndroidService != None or self.pushAppleService != None

        return enabled
    def initPushNotificationService(self, configurationAttributes):
        print "Super-Gluu. Initialize notification services"
        if not configurationAttributes.containsKey("credentials_file"):
            return False

        super_gluu_creds_file = configurationAttributes.get("credentials_file").getValue2()

        # Load credentials from file
        f = open(super_gluu_creds_file, 'r')
        try:
            creds = json.loads(f.read())
        except:
            print "Super-Gluu. Initialize notification services. Failed to load credentials from file:", super_gluu_creds_file
            return False
        finally:
            f.close()
        
        try:
            android_creds = creds["android"]["gcm"]
            ios_creads = creds["ios"]["apns"]
        except:
            print "Super-Gluu. Initialize notification services. Invalid credentials file '%s' format:" % super_gluu_creds_file
            return False
        
        self.pushAndroidService = None
        self.pushAppleService = None
        if android_creds["enabled"]:
            self.pushAndroidService = Sender(android_creds["api_key"]) 
            print "Super-Gluu. Initialize notification services. Created Android notification service"
            
        if ios_creads["enabled"]:
            p12_file_path = ios_creads["p12_file_path"]
            p12_passowrd = ios_creads["p12_password"]

            try:
                stringEncrypter = StringEncrypter.defaultInstance()
                p12_passowrd = stringEncrypter.decrypt(p12_passowrd)
            except:
                # Ignore exception. Password is not encrypted
                print "Super-Gluu. Initialize notification services. Assuming that 'p12_passowrd' password in not encrypted"

            apnsServiceBuilder =  APNS.newService().withCert(p12_file_path, p12_passowrd)
            if ios_creads["production"]:
                self.pushAppleService = apnsServiceBuilder.withProductionDestination().build()
            else:
                self.pushAppleService = apnsServiceBuilder.withSandboxDestination().build()

            print "Super-Gluu. Initialize notification services. Created iOS notification service"

        enabled = self.pushAndroidService != None or self.pushAppleService != None

        return enabled
Exemplo n.º 3
0
    def initNativePushNotificationService(self, configurationAttributes):
        print "Super-Gluu. Initialize native notification services"
        self.pushSnsMode = False

        creds = self.loadPushNotificationCreds(configurationAttributes)
        if creds == None:
            return False

        try:
            android_creds = creds["android"]["gcm"]
            ios_creads = creds["ios"]["apns"]
        except:
            print "Super-Gluu. Initialize native notification services. Invalid credentials file format"
            return False

        self.pushAndroidService = None
        self.pushAppleService = None
        if android_creds["enabled"]:
            self.pushAndroidService = Sender(android_creds["api_key"])
            print "Super-Gluu. Initialize native notification services. Created Android notification service"

        if ios_creads["enabled"]:
            p12_file_path = ios_creads["p12_file_path"]
            p12_passowrd = ios_creads["p12_password"]

            try:
                encryptionService = CdiUtil.bean(EncryptionService)
                p12_passowrd = encryptionService.decrypt(p12_passowrd)
            except:
                # Ignore exception. Password is not encrypted
                print "Super-Gluu. Initialize native notification services. Assuming that 'p12_passowrd' password in not encrypted"

            apnsServiceBuilder = APNS.newService().withCert(
                p12_file_path, p12_passowrd)
            if ios_creads["production"]:
                self.pushAppleService = apnsServiceBuilder.withProductionDestination(
                ).build()
            else:
                self.pushAppleService = apnsServiceBuilder.withSandboxDestination(
                ).build()

            print "Super-Gluu. Initialize native notification services. Created iOS notification service"

        enabled = self.pushAndroidService != None or self.pushAppleService != None

        return enabled
Exemplo n.º 4
0
    def initNativePushNotifications(self, creds):
        print "Super-Gluu-Push. Native push notifications init ... "
        try:
            android_creds = creds["android"]["gcm"]
            ios_creds = creds["ios"]["apns"]
        except:
            print "Super-Gluu-Push. Invalid credentials format"
            return None

        self.pushAndroidService = None
        self.pushAppleService = None

        if android_creds["enabled"]:
            self.pushAndroidService = Sender(android_creds["api_key"])
            print "Super-Gluu-Push. Created native Android notification service"

        if ios_creds["enabled"]:
            p12_file_path = ios_creds["p12_file_path"]
            p12_password = ios_creds["p12_password"]

            try:
                encryptionService = CdiUtil.bean(EncryptionService)
                p12_password = encryptionService.decrypt(p12_password)
            except:
                # Ignore exception. Password is not encrypted
                print "Super-Gluu-Push. Assuming 'p12_password' is not encrypted"

            apnsServiceBuilder = APNS.newService().withCert(
                p12_file_path, p12_password)
            if ios_creds["production"]:
                self.pushAppleService = apnsServiceBuilder.withProductionDestination(
                ).build()
            else:
                self.pushAppleService = apnsServiceBuilder.withSandboxDestination(
                ).build()

            self.pushAppleServiceProduction = ios_creds["production"]
            print "Super-Gluu-Push. Created native iOS notification service"

        self.pushNotificationsEnabled = self.pushAndroidService != None or self.pushAppleService != None
    def initNativePushNotifications(self, creds):
        print "Super-Gluu-Push. Native push notifications init ... "
        try:
            android_creds = creds["android"]["gcm"]
            ios_creds = creds["ios"]["apns"]
        except:
            print "Super-Gluu-Push. Invalid credentials format"
            return None
        
        self.pushAndroidService = None
        self.pushAppleService = None

        if android_creds["enabled"]:
            self.pushAndroidService = Sender(android_creds["api_key"])
            print "Super-Gluu-Push. Created native Android notification service"
        
        if ios_creds["enabled"]:
            p12_file_path = ios_creds["p12_file_path"]
            p12_password  = ios_creds["p12_password"]

            try:
                encryptionService = CdiUtil.bean(EncryptionService)
                p12_password = encryptionService.decrypt(p12_password)
            except:
                # Ignore exception. Password is not encrypted
                print "Super-Gluu-Push. Assuming 'p12_password' is not encrypted"

            apnsServiceBuilder = APNS.newService().withCert(p12_file_path,p12_password)
            if ios_creds["production"]:
                self.pushAppleService = apnsServiceBuilder.withProductionDestination().build()
            else:
                self.pushAppleService = apnsServiceBuilder.withSandboxDestination().build()
            
            self.pushAppleServiceProduction = ios_creds["production"]
            print "Super-Gluu-Push. Created native iOS notification service"
        
        self.pushNotificationsEnabled = self.pushAndroidService != None or self.pushAppleService != None