Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2019 (original work) Open Assessment Technologies SA;
19 */
20
21namespace oat\tao\model\oauth;
22
23use IMSGlobal\LTI\OAuth\OAuthConsumer;
24use IMSGlobal\LTI\OAuth\OAuthToken;
25
26/**
27 * IMSGlobal lib doesn't define an interface for DataStore, but
28 * has OAuthDataStore class instead. This interface duplicates it's requirements
29 * @see \IMSGlobal\LTI\OAuth\OAuthDataStore
30 */
31interface ImsOauthDataStoreInterface
32{
33    /**
34     * Returns the OauthConsumer for the specified key
35     * @param string $consumer_key
36     * @return OAuthConsumer
37     *
38     * phpcs:disable PSR1.Methods.CamelCapsMethodName
39     */
40    public function lookup_consumer($consumer_key);
41    // phpcs:enable PSR1.Methods.CamelCapsMethodName
42
43    /**
44     * Should verify if the token exists and return it
45     * Always returns an token with an empty secret for now
46     *
47     * @param OAuthConsumer $consumer
48     * @param string $token_type
49     * @param string $token
50     * @return OAuthToken
51     *
52     * phpcs:disable PSR1.Methods.CamelCapsMethodName
53     */
54    public function lookup_token($consumer, $token_type, $token);
55    // phpcs:enable PSR1.Methods.CamelCapsMethodName
56
57    /**
58     * Should verify if a nonce has already been used by specified consumer (got from lookup_consumer() call).
59     * Should return false in case of acceptable nonce (which hasn't been used before)
60     *
61     * @param OAuthConsumer $consumer
62     * @param string $token
63     * @param string $nonce
64     * @param string $timestamp
65     * @return bool if nonce value exists
66     *
67     * phpcs:disable PSR1.Methods.CamelCapsMethodName
68     */
69    public function lookup_nonce($consumer, $token, $nonce, $timestamp);
70    // phpcs:enable PSR1.Methods.CamelCapsMethodName
71
72    /**
73     * Perform request_token request according to OAuth flow
74     * Needed only for
75     * @see \IMSGlobal\LTI\OAuth\OAuthServer::fetch_request_token()
76     * call
77     *
78     * @param OAuthConsumer $consumer
79     * @param callable|null $callback
80     * @return mixed
81     *
82     * phpcs:disable PSR1.Methods.CamelCapsMethodName
83     */
84    public function new_request_token($consumer, $callback = null);
85    // phpcs:enable PSR1.Methods.CamelCapsMethodName
86
87    /**
88     * Perform access_token request according to OAuth flow
89     * Needed only for
90     * @see \IMSGlobal\LTI\OAuth\OAuthServer::fetch_access_token()
91     * call
92     *
93     * @param string $token
94     * @param OAuthConsumer $consumer
95     * @param string $verifier Verification code
96     * @return string
97     *
98     * phpcs:disable PSR1.Methods.CamelCapsMethodName
99     */
100    public function new_access_token($token, $consumer, $verifier = null);
101    // phpcs:enable PSR1.Methods.CamelCapsMethodName
102}