File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace OCA \Solid ;
4+
5+ use DateInterval ;
6+ use OCP \IDBConnection ;
7+ use Pdsinterop \Solid \Auth \Utils \Bearer ;
8+ use Pdsinterop \Solid \Auth \Utils \JtiValidator ;
9+
10+ trait BearerFactoryTrait
11+ {
12+ ////////////////////////////// CLASS PROPERTIES \\\\\\\\\\\\\\\\\\\\\\\\\\\\
13+
14+ private IDBConnection $ connection ;
15+ private DateInterval $ validFor ;
16+
17+ //////////////////////////////// PUBLIC API \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
18+
19+ final public function getBearer (): Bearer
20+ {
21+ $ interval = $ this ->getBearerValidFor ();
22+
23+ $ replayDetector = new JtiReplayDetector ($ interval , $ this ->connection );
24+
25+ $ jtiValidator = new JtiValidator ($ replayDetector );
26+
27+ return new Bearer ($ jtiValidator );
28+ }
29+
30+ final public function getBearerValidFor (): DateInterval
31+ {
32+ static $ validFor ;
33+
34+ if ($ validFor === null ) {
35+ $ validFor = new DateInterval ('PT10M ' );
36+ }
37+
38+ return $ validFor ;
39+ }
40+
41+ final public function setJtiStorage (IDBConnection $ connection ): void
42+ {
43+ $ this ->connection = $ connection ;
44+ }
45+
46+ ////////////////////////////// UTILITY METHODS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
47+ }
You can’t perform that action at this time.
0 commit comments