1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the tiqr project. |
5
|
|
|
* |
6
|
|
|
* The tiqr project aims to provide an open implementation for |
7
|
|
|
* authentication using mobile devices. It was initiated by |
8
|
|
|
* SURFnet and developed by Egeniq. |
9
|
|
|
* |
10
|
|
|
* More information: http://www.tiqr.org |
11
|
|
|
* |
12
|
|
|
* @author Ivo Jansch <[email protected]> |
13
|
|
|
* |
14
|
|
|
* @package tiqr |
15
|
|
|
* |
16
|
|
|
* @license New BSD License - See LICENSE file for details. |
17
|
|
|
* |
18
|
|
|
* @copyright (C) 2010-2012 SURFnet BV |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The version 1 implementation of the response object. |
23
|
|
|
* |
24
|
|
|
* @author Lineke Kerckhoffs-Willems <[email protected]> |
25
|
|
|
* |
26
|
|
|
*/ |
27
|
|
|
class Tiqr_Response_V1 extends Tiqr_Response_Abstract |
28
|
|
|
{ |
29
|
|
|
const RESPONSE_LOGIN_OK = 1; |
30
|
|
|
const RESPONSE_LOGIN_ERROR = 200; |
31
|
|
|
const RESPONSE_INVALID = 201; |
32
|
|
|
const RESPONSE_INVALID_USER = 205; |
33
|
|
|
const RESPONSE_INVALID_REQUEST = 202; |
34
|
|
|
const RESPONSE_INVALID_CHALLENGE = 203; |
35
|
|
|
const RESPONSE_ACCOUNT_BLOCKED = 204; |
36
|
|
|
const RESPONSE_ENROLLMENT_OK = 1; |
37
|
|
|
const RESPONSE_ENROLLMENT_ERROR = 101; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get the Tiqr error response in the correct format |
41
|
|
|
* |
42
|
|
|
* @return string The response |
43
|
|
|
*/ |
44
|
|
|
public function getErrorResponse() |
45
|
|
|
{ |
46
|
|
|
$result = array(); |
47
|
|
|
$result['responseCode'] = self::RESPONSE_LOGIN_ERROR; |
48
|
|
|
return $result; |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get the Tiqr invalid response |
53
|
|
|
* |
54
|
|
|
* @param int $attemptsLeft Number of login attempts left before a block |
55
|
|
|
* |
56
|
|
|
* @return array The response object |
57
|
|
|
*/ |
58
|
|
|
public function getInvalidResponse($attemptsLeft = null) |
59
|
|
|
{ |
60
|
|
|
$result = array(); |
61
|
|
|
$result['responseCode'] = self::RESPONSE_INVALID; |
62
|
|
|
if (!is_null($attemptsLeft)) { |
63
|
|
|
$result['attemptsLeft'] = $attemptsLeft; |
64
|
|
|
} |
65
|
|
|
return $result; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the Tiqr invalid userid response |
70
|
|
|
* |
71
|
|
|
* @return array The response object |
72
|
|
|
*/ |
73
|
|
|
public function getInvalidUserResponse() |
74
|
|
|
{ |
75
|
|
|
$result = array(); |
76
|
|
|
$result['responseCode'] = self::RESPONSE_INVALID_USER; |
77
|
|
|
return $result; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Get the Tiqr invalid request response |
82
|
|
|
* |
83
|
|
|
* @return array The response object |
84
|
|
|
*/ |
85
|
|
|
public function getInvalidRequestResponse() |
86
|
|
|
{ |
87
|
|
|
$result = array(); |
88
|
|
|
$result['responseCode'] = self::RESPONSE_INVALID_REQUEST; |
89
|
|
|
return $result; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get the Tiqr invalid challenge response |
94
|
|
|
* |
95
|
|
|
* @return array The response object |
96
|
|
|
*/ |
97
|
|
|
public function getInvalidChallengeResponse() |
98
|
|
|
{ |
99
|
|
|
$result = array(); |
100
|
|
|
$result['responseCode'] = self::RESPONSE_INVALID_CHALLENGE; |
101
|
|
|
return $result; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get the Tiqr invalid userid response |
106
|
|
|
* |
107
|
|
|
* @param int $duration The duration of the block (only for temporary blocks) |
108
|
|
|
* |
109
|
|
|
* @return array The response object |
110
|
|
|
*/ |
111
|
|
|
public function getAccountBlockedResponse($duration = null) |
112
|
|
|
{ |
113
|
|
|
$result = array(); |
114
|
|
|
$result['responseCode'] = self::RESPONSE_ACCOUNT_BLOCKED; |
115
|
|
|
if (!is_null($duration)) { |
116
|
|
|
$result['duration'] = $duration; |
117
|
|
|
} |
118
|
|
|
return $result; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get the Tiqr logged in response |
123
|
|
|
* |
124
|
|
|
* @return array The response object |
125
|
|
|
*/ |
126
|
|
|
public function getLoginResponse() |
127
|
|
|
{ |
128
|
|
|
$result = array(); |
129
|
|
|
$result['responseCode'] = self::RESPONSE_LOGIN_OK; |
130
|
|
|
return $result; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Get the response when enrollment was succesful |
135
|
|
|
* |
136
|
|
|
* @return array The response object |
137
|
|
|
*/ |
138
|
|
|
public function getEnrollmentOkResponse() |
139
|
|
|
{ |
140
|
|
|
$result = array(); |
141
|
|
|
$result['responseCode'] = self::RESPONSE_ENROLLMENT_OK; |
142
|
|
|
return $result; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Get the response when enrollment had an error |
147
|
|
|
* |
148
|
|
|
* @return array The response object |
149
|
|
|
*/ |
150
|
|
|
public function getEnrollmentErrorResponse() |
151
|
|
|
{ |
152
|
|
|
$result = array(); |
153
|
|
|
$result['responseCode'] = self::RESPONSE_ENROLLMENT_ERROR; |
154
|
|
|
return $result; |
155
|
|
|
} |
156
|
|
|
} |