public function getAuthType(\core_kernel_classes_Resource $resource = null)
    {
        if ($resource) {
            $authTypeUri = $resource->getUri();
            foreach ($this->getOption(self::OPTION_TYPES) as $type) {
                if ($type instanceof AbstractAuthType && $type->getAuthClass()->getUri() == $authTypeUri) {
                    $authType = $type;
                }
            }
        } else {
            $authType = $this->getOption(self::OPTION_DEFAULT_TYPE);
        }

        if (!isset($authType) || !is_a($authType, AbstractAuthType::class)) {
            throw new \common_Exception('Auth type not defined');
        }

        return $authType;
    }