protected function getEntitiesDescriptor()
    {
        $ret = new EntitiesDescriptor();
        $now = time();

        // add RegistrationInfo extension if enabled
        if (!empty($this->regInfo)) {
            $ri = new RegistrationInfo();
            $ri->registrationInstant = $now;
            foreach ($this->regInfo as $riName => $riValues) {
                switch ($riName) {
                    case 'authority':
                        $ri->registrationAuthority = $riValues;
                        break;
                    case 'instant':
                        $ri->registrationInstant = Utils::xsDateTimeToTimestamp($riValues);
                        break;
                    case 'policies':
                        $ri->RegistrationPolicy = $riValues;
                        break;
                }
            }
            $ret->Extensions[] = $ri;
        }

        foreach ($this->sources as $source) {
            $m = $source->getMetadata();
            if ($m === NULL) {
                continue;
            }
            if ($m instanceof EntityDescriptor) {
                $ret->children[] = $m;
            } elseif ($m instanceof EntitiesDescriptor) {
                $ret->children = array_merge($ret->children, self::extractEntityDescriptors($m));
            }
        }

        $ret->children = array_unique($ret->children, SORT_REGULAR);
        $ret->validUntil = $now + $this->validLength;

        return $ret;
    }