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