<?php
namespace nur\b\authnz;

use nur\config;
use nur\func;

/**
 * Class CasAuthzManager: un utilisateur authentifié par CAS v3
 */
class CasAuthzManager extends AuthzManager {
  const USER_MANAGER_CLASS = CasUserManager::class;
  const APPCODE = null;

  function __construct(?string $appcode=null) {
    if ($appcode === null) $appcode = static::APPCODE;
    if ($appcode === null) $appcode = config::get_appcode();
    $this->appcode = $appcode;
  }

  protected $appcode;

  protected $userManager;

  protected function getUserManager(): IUserManager {
    if ($this->userManager === null) {
      $class = static::USER_MANAGER_CLASS;
      $this->userManager = func::cons($class, $this->appcode);
    }
    return $this->userManager;
  }
}
