Test Failed
Push — master ( b5ef5e...9e488e )
by Michiel
17:47 queued 02:26
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * This file is part of the tiqr project.
4
 *
5
 * The tiqr project aims to provide an open implementation for
6
 * authentication using mobile devices. It was initiated by
7
 * SURFnet and developed by Egeniq.
8
 *
9
 * More information: http://www.tiqr.org
10
 *
11
 * @author Lineke Kerckhoffs-Willems <[email protected]>
12
 *
13
 * @package tiqr
14
 *
15
 * @license New BSD License - See LICENSE file for details.
16
 *
17
 * @copyright (C) 2014 SURFnet BV
18
 */
19
20
use Psr\Log\LoggerInterface;
21
22
require_once('Tiqr/API/Client.php');
23
24
/**
25
 * OATHService storage for user's secret
26
 */
27
class Tiqr_UserSecretStorage_OathServiceClient implements Tiqr_UserSecretStorage_Interface
28
{
29
    private $client;
30
    /**
31
     * @var LoggerInterface
32
     */
33
    private $logger;
34
35
    public function __construct(Tiqr_API_Client $client, LoggerInterface $logger)
36
    {
37
        $this->logger = $logger;
38
        $this->client = $client;
39
    }
40
41
    /**
42
     * Get the user's secret
43
     * Not implemented because the idea of the oathservice is that secrets cannot be retrieved
44
     *
45
     * @param String $userId
46
     *
47
     * @return string The user's secret
48
     */
49
    public function getSecret($userId)
50
    {
51
        $this->logger->notice('Calling getUserSecret on the OathServiceClient is not implemented');
52
        return null;
53
    }
54
55
    /**
56
     * Store a secret for a user
57
     *
58
     * Note that this storage engine does not use the encryption mechnism that PDO and File storage do implement. This
59
     * is taken care of by the OathService itself.
60
     *
61
     * @param string $userId
62
     * @param string $secret
63
     * @throws Exception
64
     */
65
    public function setSecret($userId, $secret)
66
    {
67
        $this->logger->info('Storing the user secret on the OathServiceClient (api call)');
68
        $this->client->call('/secrets/'.urlencode($userId), 'POST', array('secret' => $secret));
69
    }
70
}
71