Skip to content

Commit eb20ef1

Browse files
committed
make JwtHandler accessible
1 parent d28cff4 commit eb20ef1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/OpencastApi/Opencast.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use OpencastApi\Rest\OcRestClient;
55
use OpencastApi\Rest\OcIngest;
6+
use OpencastApi\Auth\JWT\OcJwtHandler;
67

78
class Opencast
89
{
@@ -75,7 +76,6 @@ class Opencast
7576
/** @var \OpencastApi\Rest\OcInfo $info */
7677
public $info;
7778

78-
7979
/*
8080
$config = [
8181
'url' => 'https://develop.opencast.org/', // The API url of the opencast instance (required)
@@ -119,6 +119,16 @@ public function __construct($config, $engageConfig = [], $enableingest = true)
119119
$this->setEndpointProperties($config, $enableingest);
120120
}
121121

122+
/**
123+
* Get the JWT Handler from the Rest Client.
124+
*
125+
* @return OcJwtHandler|null
126+
*/
127+
public function getRestJwtHandler(): ?OcJwtHandler
128+
{
129+
return $this->restClient->getJwtHandler();
130+
}
131+
122132
private function setEndpointProperties($config, $enableingest)
123133
{
124134
foreach(glob(__DIR__ . '/Rest/*.php') as $classPath) {

src/OpencastApi/Rest/OcRestClient.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class OcRestClient extends Client
2323
private array $globalOptions = [];
2424
private array $jwtConfig = [];
2525
private ?OcJwtClaim $jwtClaim = null;
26+
private ?OcJwtHandler $jwtHandler = null;
2627

2728
/*
2829
$config = [
@@ -76,11 +77,21 @@ public function __construct($config)
7677

7778
if (isset($config['jwt']) && is_array($config['jwt'])) {
7879
$this->jwtConfig = $config['jwt'];
80+
$this->jwtHandler = new OcJwtHandler(
81+
$this->jwtConfig['private_key'],
82+
$this->jwtConfig['algorithm'] ?? null,
83+
$this->jwtConfig['expiration'] ?? null
84+
);
7985
}
8086

8187
parent::__construct($parentConstructorConfig);
8288
}
8389

90+
public function getJwtHandler(): ?OcJwtHandler
91+
{
92+
return $this->jwtHandler;
93+
}
94+
8495
public function readFeatures($key = null) {
8596
if (empty($key)) {
8697
return $this->features;

0 commit comments

Comments
 (0)