public function authenticate(array $credentials)
{
list($username, $password) = $credentials;
foreach ($this->userlist as $name => $pass) {
if (strcasecmp($name, $username) === 0) {
if ((string) $pass === (string) $password) {
return new Identity($name, isset($this->usersRoles[$name]) ? $this->usersRoles[$name] : NULL);
} else {
throw new AuthenticationException('Invalid password.', self::INVALID_CREDENTIAL);
}
}
}
throw new AuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
}