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
|
|
|
use Psr\Log\LoggerInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Abstract base class for notification messages. |
24
|
|
|
*/ |
25
|
|
|
abstract class Tiqr_Message_Abstract |
26
|
|
|
{ |
27
|
|
|
private $_options; |
28
|
|
|
private $_id; |
29
|
|
|
private $_address; |
30
|
|
|
private $_text; |
31
|
|
|
private $_properties = array(); |
32
|
|
|
/** @var LoggerInterface */ |
33
|
|
|
protected $logger; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Construct a new message. |
37
|
|
|
* |
38
|
|
|
* @param array $options configuration options |
39
|
|
|
*/ |
40
|
|
|
public function __construct(array $options, LoggerInterface $logger) |
41
|
|
|
{ |
42
|
|
|
$this->_options = $options; |
43
|
|
|
$this->logger = $logger; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns the configuration options. |
48
|
|
|
* |
49
|
|
|
* @return array configuration options |
50
|
|
|
*/ |
51
|
|
|
public function getOptions() |
52
|
|
|
{ |
53
|
|
|
return $this->_options; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Returns the message id. |
58
|
|
|
* |
59
|
|
|
* @return string message id |
60
|
|
|
*/ |
61
|
|
|
public function getId() |
62
|
|
|
{ |
63
|
|
|
return $this->_id; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Sets the message id. |
68
|
|
|
* |
69
|
|
|
* @param string $id message id |
70
|
|
|
*/ |
71
|
|
|
public function setId($id) |
72
|
|
|
{ |
73
|
|
|
$this->_id = $id; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Returns the device address. |
78
|
|
|
* |
79
|
|
|
* @return string device address |
80
|
|
|
*/ |
81
|
|
|
public function getAddress() |
82
|
|
|
{ |
83
|
|
|
return $this->_address; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Sets the device address. |
88
|
|
|
* |
89
|
|
|
* @param string $address device address |
90
|
|
|
*/ |
91
|
|
|
public function setAddress($address) |
92
|
|
|
{ |
93
|
|
|
$this->_address = $address; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Returns the message text. |
98
|
|
|
* |
99
|
|
|
* @return string message text |
100
|
|
|
*/ |
101
|
|
|
public function getText() |
102
|
|
|
{ |
103
|
|
|
return $this->_text; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Sets the message text. |
108
|
|
|
* |
109
|
|
|
* @param string message text |
110
|
|
|
*/ |
111
|
|
|
public function setText($text) |
112
|
|
|
{ |
113
|
|
|
$this->_text = $text; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Returns the value for a custom property. |
118
|
|
|
* |
119
|
|
|
* @param string $name property name |
120
|
|
|
* |
121
|
|
|
* @return mixed property value |
122
|
|
|
*/ |
123
|
|
|
public function getCustomProperty($name) |
124
|
|
|
{ |
125
|
|
|
return $this->_properties[$name]; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Returns all custom properties. |
130
|
|
|
* |
131
|
|
|
* @return array custom properties |
132
|
|
|
*/ |
133
|
|
|
public function getCustomProperties() |
134
|
|
|
{ |
135
|
|
|
return $this->_properties; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Sets the value for a custom property. |
140
|
|
|
* |
141
|
|
|
* @param string $name property name |
142
|
|
|
* @param mixed $value property value |
143
|
|
|
*/ |
144
|
|
|
public function setCustomProperty($name, $value) |
145
|
|
|
{ |
146
|
|
|
$this->_properties[$name] = $value; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Send message. |
151
|
|
|
* |
152
|
|
|
* @throws Tiqr_Message_Exception_AuthError |
153
|
|
|
* @throws Tiqr_Message_Exception_SendError |
154
|
|
|
* @throws Tiqr_Message_Exception_InvalidDevice |
155
|
|
|
*/ |
156
|
|
|
public abstract function send(); |
157
|
|
|
} |