1 | <?php |
||
14 | final class Helper |
||
15 | { |
||
16 | const TIME_FORMAT = 'Y-m-d\TH:i:s\Z'; |
||
17 | |||
18 | /** |
||
19 | * @param string $duration |
||
20 | */ |
||
21 | 5 | public static function validateDurationString($duration) |
|
31 | |||
32 | /** |
||
33 | * @param int $time |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | 30 | public static function time2string($time) |
|
41 | |||
42 | /** |
||
43 | * @param int|string|\DateTime $value |
||
44 | * |
||
45 | * @return int |
||
46 | * |
||
47 | * @throws \InvalidArgumentException |
||
48 | */ |
||
49 | 116 | public static function getTimestampFromValue($value) |
|
61 | |||
62 | /** |
||
63 | * @param string $time |
||
64 | * |
||
65 | * @return int |
||
66 | * |
||
67 | * @throws \InvalidArgumentException |
||
68 | */ |
||
69 | 42 | public static function parseSAMLTime($time) |
|
82 | |||
83 | /** |
||
84 | * @param int $length |
||
85 | * |
||
86 | * @return string |
||
87 | * |
||
88 | * @throws \InvalidArgumentException |
||
89 | */ |
||
90 | 15 | public static function generateRandomBytes($length) |
|
108 | |||
109 | /** |
||
110 | * @param string $bytes |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | 13 | public static function stringToHex($bytes) |
|
124 | |||
125 | /** |
||
126 | * @return string |
||
127 | */ |
||
128 | 13 | public static function generateID() |
|
132 | |||
133 | /** |
||
134 | * Is ID element at least 128 bits in length (SAML2.0 standard section 1.3.4). |
||
135 | * |
||
136 | * @param string $id |
||
137 | * |
||
138 | * @return bool |
||
139 | */ |
||
140 | 22 | public static function validateIdString($id) |
|
144 | |||
145 | /** |
||
146 | * @param string $value |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | 65 | public static function validateRequiredString($value) |
|
154 | |||
155 | /** |
||
156 | * @param string $value |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | 14 | public static function validateOptionalString($value) |
|
164 | |||
165 | /** |
||
166 | * @param string $value |
||
167 | * |
||
168 | * @return bool |
||
169 | */ |
||
170 | 47 | public static function validateWellFormedUriString($value) |
|
192 | |||
193 | /** |
||
194 | * @param int $notBefore |
||
195 | * @param int $now |
||
196 | * @param int $allowedSecondsSkew |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | 8 | public static function validateNotBefore($notBefore, $now, $allowedSecondsSkew) |
|
204 | |||
205 | /** |
||
206 | * @param int $notOnOrAfter |
||
207 | * @param int $now |
||
208 | * @param int $allowedSecondsSkew |
||
209 | * |
||
210 | * @return bool |
||
211 | */ |
||
212 | 7 | public static function validateNotOnOrAfter($notOnOrAfter, $now, $allowedSecondsSkew) |
|
216 | } |
||
217 |