File: base.py

package info (click to toggle)
python-django-push-notifications 1.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: python: 2,694; makefile: 4
file content (55 lines) | stat: -rw-r--r-- 1,595 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from django.core.exceptions import ImproperlyConfigured


class BaseConfig(object):
	def get_apns_certificate(self, application_id=None):
		raise NotImplementedError

	def get_apns_use_sandbox(self, application_id=None):
		raise NotImplementedError

	def get_apns_use_alternative_port(self, application_id=None):
		raise NotImplementedError

	def get_fcm_api_key(self, application_id=None):
		raise NotImplementedError

	def get_gcm_api_key(self, application_id=None):
		raise NotImplementedError

	def get_wns_package_security_id(self, application_id=None):
		raise NotImplementedError

	def get_wns_secret_key(self, application_id=None):
		raise NotImplementedError

	def get_post_url(self, cloud_type, application_id=None):
		raise NotImplementedError

	def get_error_timeout(self, cloud_type, application_id=None):
		raise NotImplementedError

	def get_max_recipients(self, cloud_type, application_id=None):
		raise NotImplementedError

	def get_applications(self):
		"""Returns a collection containing the configured applications."""

		raise NotImplementedError


def check_apns_certificate(ss):
	mode = "start"
	for s in ss.split("\n"):
		if mode == "start":
			if "BEGIN RSA PRIVATE KEY" in s or "BEGIN PRIVATE KEY" in s:
				mode = "key"
		elif mode == "key":
			if "END RSA PRIVATE KEY" in s or "END PRIVATE KEY" in s:
				mode = "end"
				break
			elif s.startswith("Proc-Type") and "ENCRYPTED" in s:
				raise ImproperlyConfigured("Encrypted APNS private keys are not supported")

	if mode != "end":
		raise ImproperlyConfigured("The APNS certificate doesn't contain a private key")