| @@ 219-243 (lines=25) @@ | ||
| 216 | * @return boolean true on success, false when we don't have a signature. |
|
| 217 | * @throws \Exception |
|
| 218 | */ |
|
| 219 | public function validate(XMLSecurityKey $key) |
|
| 220 | { |
|
| 221 | if (count($this->validators) === 0) { |
|
| 222 | return false; |
|
| 223 | } |
|
| 224 | ||
| 225 | $exceptions = array(); |
|
| 226 | ||
| 227 | foreach ($this->validators as $validator) { |
|
| 228 | $function = $validator['Function']; |
|
| 229 | $data = $validator['Data']; |
|
| 230 | ||
| 231 | try { |
|
| 232 | call_user_func($function, $data, $key); |
|
| 233 | /* We were able to validate the message with this validator. */ |
|
| 234 | ||
| 235 | return true; |
|
| 236 | } catch (\Exception $e) { |
|
| 237 | $exceptions[] = $e; |
|
| 238 | } |
|
| 239 | } |
|
| 240 | ||
| 241 | /* No validators were able to validate the message. */ |
|
| 242 | throw $exceptions[0]; |
|
| 243 | } |
|
| 244 | ||
| 245 | /** |
|
| 246 | * Retrieve the identifier of this message. |
|
| @@ 98-122 (lines=25) @@ | ||
| 95 | * @return boolean true on success, false when we don't have a signature. |
|
| 96 | * @throws \Exception |
|
| 97 | */ |
|
| 98 | public function validate(XMLSecurityKey $key) |
|
| 99 | { |
|
| 100 | if (count($this->validators) === 0) { |
|
| 101 | return false; |
|
| 102 | } |
|
| 103 | ||
| 104 | $exceptions = array(); |
|
| 105 | ||
| 106 | foreach ($this->validators as $validator) { |
|
| 107 | $function = $validator['Function']; |
|
| 108 | $data = $validator['Data']; |
|
| 109 | ||
| 110 | try { |
|
| 111 | call_user_func($function, $data, $key); |
|
| 112 | /* We were able to validate the message with this validator. */ |
|
| 113 | ||
| 114 | return true; |
|
| 115 | } catch (\Exception $e) { |
|
| 116 | $exceptions[] = $e; |
|
| 117 | } |
|
| 118 | } |
|
| 119 | ||
| 120 | /* No validators were able to validate the message. */ |
|
| 121 | throw $exceptions[0]; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * Retrieve the private key we should use to sign the message. |
|