Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  namespace Packback\Lti1p3;
   4  
   5  use Packback\Lti1p3\Interfaces\ILtiRegistration;
   6  
   7  class LtiRegistration implements ILtiRegistration
   8  {
   9      private $issuer;
  10      private $clientId;
  11      private $keySetUrl;
  12      private $authTokenUrl;
  13      private $authLoginUrl;
  14      private $authServer;
  15      private $toolPrivateKey;
  16      private $kid;
  17  
  18      public function __construct(array $registration = [])
  19      {
  20          $this->issuer = $registration['issuer'] ?? null;
  21          $this->clientId = $registration['clientId'] ?? null;
  22          $this->keySetUrl = $registration['keySetUrl'] ?? null;
  23          $this->authTokenUrl = $registration['authTokenUrl'] ?? null;
  24          $this->authLoginUrl = $registration['authLoginUrl'] ?? null;
  25          $this->authServer = $registration['authServer'] ?? null;
  26          $this->toolPrivateKey = $registration['toolPrivateKey'] ?? null;
  27          $this->kid = $registration['kid'] ?? null;
  28      }
  29  
  30      public static function new(array $registration = [])
  31      {
  32          return new LtiRegistration($registration);
  33      }
  34  
  35      public function getIssuer()
  36      {
  37          return $this->issuer;
  38      }
  39  
  40      public function setIssuer($issuer)
  41      {
  42          $this->issuer = $issuer;
  43  
  44          return $this;
  45      }
  46  
  47      public function getClientId()
  48      {
  49          return $this->clientId;
  50      }
  51  
  52      public function setClientId($clientId)
  53      {
  54          $this->clientId = $clientId;
  55  
  56          return $this;
  57      }
  58  
  59      public function getKeySetUrl()
  60      {
  61          return $this->keySetUrl;
  62      }
  63  
  64      public function setKeySetUrl($keySetUrl)
  65      {
  66          $this->keySetUrl = $keySetUrl;
  67  
  68          return $this;
  69      }
  70  
  71      public function getAuthTokenUrl()
  72      {
  73          return $this->authTokenUrl;
  74      }
  75  
  76      public function setAuthTokenUrl($authTokenUrl)
  77      {
  78          $this->authTokenUrl = $authTokenUrl;
  79  
  80          return $this;
  81      }
  82  
  83      public function getAuthLoginUrl()
  84      {
  85          return $this->authLoginUrl;
  86      }
  87  
  88      public function setAuthLoginUrl($authLoginUrl)
  89      {
  90          $this->authLoginUrl = $authLoginUrl;
  91  
  92          return $this;
  93      }
  94  
  95      public function getAuthServer()
  96      {
  97          return empty($this->authServer) ? $this->authTokenUrl : $this->authServer;
  98      }
  99  
 100      public function setAuthServer($authServer)
 101      {
 102          $this->authServer = $authServer;
 103  
 104          return $this;
 105      }
 106  
 107      public function getToolPrivateKey()
 108      {
 109          return $this->toolPrivateKey;
 110      }
 111  
 112      public function setToolPrivateKey($toolPrivateKey)
 113      {
 114          $this->toolPrivateKey = $toolPrivateKey;
 115  
 116          return $this;
 117      }
 118  
 119      public function getKid()
 120      {
 121          return $this->kid ?? hash('sha256', trim($this->issuer.$this->clientId));
 122      }
 123  
 124      public function setKid($kid)
 125      {
 126          $this->kid = $kid;
 127  
 128          return $this;
 129      }
 130  }