Passed
Push — master ( 35fb8a...2dccb2 )
by Pieter van der
05:32 queued 14s
created

Tiqr_OcraService_Abstract::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
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 Ivo Jansch <[email protected]>
12
 *
13
 * @package tiqr
14
 *
15
 * @license New BSD License - See LICENSE file for details.
16
 *
17
 * @copyright (C) 2010-2012 SURFnet BV
18
 */
19
20
use Psr\Log\LoggerInterface;
21
22
require_once(__DIR__ . '/../OATH/OCRAParser.php');
23
24
abstract class Tiqr_OcraService_Abstract implements Tiqr_OcraService_Interface
25
{
26
    /** @var OATH_OCRAParser */
27
    protected $_ocraParser;
28
    /** @var String */
29
    protected $_ocraSuite;
30
    /** @var LoggerInterface  */
31
    protected $logger;
32
33
    /**
34
     * @throws Exception
35
     */
36 11
    public function __construct(array $config, LoggerInterface $logger) {
37 11
        $this->logger = $logger;
38
39
        // Set the OCRA suite
40 11
        $this->_ocraSuite = $config['ocra.suite'] ?? 'OCRA-1:HOTP-SHA1-6:QH10-S';   // Use tiqr server default suite
41 11
        $this->_ocraParser = new OATH_OCRAParser($this->_ocraSuite);
42 11
    }
43
44
    /**
45
     * Generate a challenge string based on an ocraSuite
46
     * @return String An OCRA challenge that matches the specification of
47
     *         the ocraSuite.
48
     * @throws Exception
49
     */
50 6
    public function generateChallenge(): string
51
    {
52 6
        return $this->_ocraParser->generateChallenge();
53
    }
54
55
}