summaryrefslogtreecommitdiff
path: root/libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php
blob: 4f8897195f0f5d2ed7d68faf69fdf07bbfde89a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

namespace JsonRPC\Validator;

use JsonRPC\Exception\AuthenticationFailureException;

/**
 * Class UserValidator
 *
 * @package JsonRPC\Validator
 * @author  Frederic Guillot
 */
class UserValidator
{
    public static function validate(array $users, $username, $password)
    {
        if (! empty($users) && (! isset($users[$username]) || $users[$username] !== $password)) {
            throw new AuthenticationFailureException('Access not allowed');
        }
    }
}