|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the tiqr project. |
|
4
|
|
|
* |
|
5
|
|
|
* The tiqr project aims to provide an open implementation for |
|
6
|
|
|
* authentication using mobile devices. It was initiated by |
|
7
|
|
|
* SURFnet and developed by Egeniq. |
|
8
|
|
|
* |
|
9
|
|
|
* More information: http://www.tiqr.org |
|
10
|
|
|
* |
|
11
|
|
|
* @author Peter Verhage <[email protected]> |
|
12
|
|
|
* |
|
13
|
|
|
* @package tiqr |
|
14
|
|
|
* |
|
15
|
|
|
* @license New BSD License - See LICENSE file for details. |
|
16
|
|
|
* |
|
17
|
|
|
* @copyright (C) 2010-2011 SURFnet BV |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** @internal base includes */ |
|
22
|
|
|
require_once('Tiqr/Message/Abstract.php'); |
|
23
|
|
|
|
|
24
|
|
|
require_once('Zend/Gdata/ClientLogin.php'); |
|
25
|
|
|
require_once 'Zend/Mobile/Push/C2dm.php'; |
|
26
|
|
|
require_once 'Zend/Mobile/Push/Message/C2dm.php'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Android Cloud To Device Messaging message. |
|
30
|
|
|
* @author peter |
|
31
|
|
|
*/ |
|
32
|
|
|
class Tiqr_Message_C2DM extends Tiqr_Message_Abstract |
|
33
|
|
|
{ |
|
34
|
|
|
private static $_services = array(); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Factory method for returning a C2DM service instance for the given |
|
38
|
|
|
* configuration options. |
|
39
|
|
|
* |
|
40
|
|
|
* @param array $options configuration options |
|
41
|
|
|
* |
|
42
|
|
|
* @return Zend_Service_Google_C2dm service instance |
|
|
|
|
|
|
43
|
|
|
* |
|
44
|
|
|
* @throws Tiqr_Message_Exception_AuthFailure |
|
45
|
|
|
*/ |
|
46
|
|
|
private static function _getService($options) |
|
47
|
|
|
{ |
|
48
|
|
|
$username = $options['c2dm.username']; |
|
49
|
|
|
$password = $options['c2dm.password']; |
|
50
|
|
|
$application = $options['c2dm.application']; |
|
51
|
|
|
|
|
52
|
|
|
$key = "{$username}:{$password}@{$application}"; |
|
53
|
|
|
|
|
54
|
|
|
if (!isset(self::$_services[$key])) { |
|
55
|
|
|
try { |
|
56
|
|
|
$client = Zend_GData_ClientLogin::getHttpClient($username, $password, Zend_Mobile_Push_C2dm::AUTH_SERVICE_NAME, null, $application); |
|
|
|
|
|
|
57
|
|
|
} catch (Zend_Gdata_App_CaptchaRequiredException $e) { |
|
58
|
|
|
throw new Tiqr_Message_Exception_AuthFailure("Manual login required", $e); |
|
59
|
|
|
} catch (Zend_Gdata_App_AuthException $e) { |
|
60
|
|
|
throw new Tiqr_Message_Exception_AuthFailure("Problem authenticating", $e); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$service = new Zend_Mobile_Push_C2dm(); |
|
64
|
|
|
$service->setLoginToken($client->getClientLoginToken()); |
|
65
|
|
|
self::$_services[$key] = $service; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return self::$_services[$key]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Send message. |
|
73
|
|
|
* |
|
74
|
|
|
* @throws Tiqr_Message_Exception_AuthFailure |
|
75
|
|
|
* @throws Tiqr_Message_Exception_SendFailure |
|
76
|
|
|
* @throws Tiqr_Message_Exception_InvalidDevice |
|
77
|
|
|
*/ |
|
78
|
|
|
public function send() |
|
79
|
|
|
{ |
|
80
|
|
|
$service = self::_getService($this->getOptions()); |
|
81
|
|
|
|
|
82
|
|
|
$data = $this->getCustomProperties(); |
|
83
|
|
|
$data['text'] = $this->getText(); |
|
84
|
|
|
|
|
85
|
|
|
$message = new Zend_Mobile_Push_Message_C2dm(); |
|
|
|
|
|
|
86
|
|
|
$message->setToken($this->getAddress()); |
|
87
|
|
|
$message->setId($this->getId()); |
|
88
|
|
|
$message->setData($data); |
|
89
|
|
|
|
|
90
|
|
|
try { |
|
91
|
|
|
$service->send($message); |
|
92
|
|
|
} catch (Zend_Mobile_Push_Exception_QuotaExceeded $e) { |
|
93
|
|
|
throw new Tiqr_Message_Exception_SendFailure("Device quota exceeded", true, $e); |
|
94
|
|
|
} catch (Zend_Mobile_Push_Exception_DeviceQuotaExceeded $e) { |
|
95
|
|
|
throw new Tiqr_Message_Exception_SendFailure("Quota exceeded", true, $e); |
|
96
|
|
|
} catch (Zend_Mobile_Push_Exception_ServerUnavailable $e) { |
|
97
|
|
|
throw new Tiqr_Message_Exception_SendFailure("Server unavailable", true, $e); |
|
98
|
|
|
} catch (Zend_Mobile_Push_Exception_InvalidToken $e) { |
|
99
|
|
|
throw new Tiqr_Message_Exception_InvalidDevice("Invalid token", $e); |
|
|
|
|
|
|
100
|
|
|
} catch (Zend_Mobile_Push_Exception_InvalidPayload $e) { |
|
101
|
|
|
throw new Tiqr_Message_Exception_SendFailure("Invalid payload", false, $e); |
|
102
|
|
|
} catch (Zend_Mobile_Push_Exception_InvalidTopic $e) { |
|
103
|
|
|
throw new Tiqr_Message_Exception_SendFailure("Invalid topic", false, $e); |
|
104
|
|
|
} catch (Zend_Mobile_Push_Exception $e) { |
|
105
|
|
|
throw new Tiqr_Message_Exception_SendFailure("General send error", false, $e); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths