Find all blacklisted tokens that have naturally expired, and so no longer need to be tracked

TODO: Use export() method

Returns any blacklisted tokens that will have expired naturally and so no longer need to be considered.

@return array
553007
public function findAllExpired()
    {
        $expiredBlacklistedTokens = $this->model->where('expiry', '<', Carbon::now())->get();

        return $expiredBlacklistedTokens->toArray();
    }
1164736
public function getReceptionCodes()
    {
        $rcLib = $this->util->getReceptionCodeLibrary();

        if ($this->unDelete) {
            return $rcLib->getTokenRestoreCodes();
        }
        if ($this->token->isCompleted()) {
            return $rcLib->getCompletedTokenDeletionCodes();
        }
        return $rcLib->getUnansweredTokenDeletionCodes();
    }
331055
public function getAuthTypeAllowableValues()
    {
        return [
            self::AUTH_TYPE_NONE,
            self::AUTH_TYPE_PASSWORD,
            self::AUTH_TYPE_OAUTH,
            self::AUTH_TYPE_EMAIL_LINK,
            self::AUTH_TYPE_PHONE_NUMBER,
            self::AUTH_TYPE_LDAP,
            self::AUTH_TYPE_SAML,
        ];
    }
207877
public function getTokens()
    {
        $pool = null;
        $session = \PHPSession::singleton();
        if($session->hasAttribute(self::TOKEN_KEY)){
            $pool = $session->getAttribute(self::TOKEN_KEY);
        }
        if(is_null($pool)){
            $pool = [];
        }

        return $pool;
    }
688693
public function jsonSerialize(): array
    {
        $array = parent::jsonSerialize();
        $array['ID'] = $this->blacklistEntryID;
        $array['Created'] =  isset($this->created) ? $this->created->format("Y-m-d\TH:i:s.").
            substr($this->updated->format('u'), 0, 3) : null;
        return array_filter($array);
    }
141675
public function collectExpectedExportIgnores()
    {
        $expectedExportIgnores = [];

        $initialWorkingDirectory = (string) getcwd();

        chdir($this->directory);

        $ignoredGlobMatches = array_merge(
            $this->ignoredGlobMatches,
            $this->getGitignoredPatterns()
        );

        foreach (glob($this->globPattern, GLOB_BRACE) as $filename) {
            if (!in_array($filename, $ignoredGlobMatches)) {
                if (is_dir($filename)) {
                    $expectedExportIgnores[] = $filename . '/';
                    continue;
                }
                $expectedExportIgnores[] = $filename;
            }
        }

        chdir($initialWorkingDirectory);

        if ($this->hasGitattributesFile()) {
            $expectedExportIgnores = array_merge(
                $expectedExportIgnores,
                $this->getPresentExportIgnoresToPreserve($expectedExportIgnores)
            );
        }

        sort($expectedExportIgnores, SORT_STRING | SORT_FLAG_CASE);

        if ($this->isKeepLicenseEnabled()) {
            $licenseLessExpectedExportIgnores = [];
            array_filter($expectedExportIgnores, function ($exportIgnore) use (
                &$licenseLessExpectedExportIgnores
            ) {
                if (!preg_match('/(License.*)/i', $exportIgnore)) {
                    $licenseLessExpectedExportIgnores[] = $exportIgnore;
                }
            });

            $expectedExportIgnores = $licenseLessExpectedExportIgnores;
        }

        return array_unique($expectedExportIgnores);
    }
238152
public function expired()
    {
        // Update if empty
        if (empty($this->entries)) {
            return true;
        }

        // Check timestamps
        if ($this->timestampManager) {
            return $this->timestampManager->check($this->getTimestamp());
        }

        return false;
    }
1111076
public function isExpired()
    {
        $payload = $this->getPayload();

        if (isset($payload['exp'])) {
            $now = new \DateTime('now');

            if (is_int($payload['exp'])) {
                return ($now->getTimestamp() - $payload['exp']) > 0;
            }

            if (is_numeric($payload['exp'])) {
                return ($now->format('U') - $payload['exp']) > 0;
            }
        }

        return false;
    }
400109
public function isExpired()
    {
        return $this->hasPayLoad() && ($this->payLoad['created'] + $this->payLoad['expires_in']) < Carbon::now()
                                                                                                         ->format('U');
    }
523563
public function getAllTxrefs()
    {
        $allTxrefs = array();
        if (is_array($this->txrefs)) {
            $allTxrefs = array_merge($allTxrefs, $this->txrefs);
        }
        if (is_array($this->unconfirmed_txrefs)) {
            $allTxrefs = array_merge($allTxrefs, $this->unconfirmed_txrefs);
        }

        if (count($allTxrefs) == 0)
            return null;
        else
            return $allTxrefs;
    }
1180586
public function getBlacklist()
    {
        if (isset($this->raw->blacklist)) {
            $blacklist = (array) $this->raw->blacklist;

            array_walk(
                $blacklist,
                function (&$file) {
                    $file = Path::canonical($file);
                }
            );

            return $blacklist;
        }

        return array();
    }
1166280
public boolean hasExpired()
    {
        if ( expiresAt == null ) {
            LOGGER.debug( "hasExpired - token is not expirable" );
            return false;
        }

        long now = System.currentTimeMillis();
        if ( LOGGER.isDebugEnabled() ) {
            LOGGER.debug( "hasExpired? - now: {} expiredAt: {} ", new Date( now ), expiresAt );
        }
        return now > expiresAt.getTime();
    }
1015049
private function getExpired()
    {
        if (count($this->expired) < 1) {
            return null;
        }
        $expired = key($this->expired);
        $this->increment($this->expired);
        return $expired;
    }
1339728
protected function getChecked()
    {
        $return = [];

        $class = $this->compileEntity();
        $res = $class::getList([
            'select' => ['*'],
        ])->fetchAll();

        foreach ($res as $key => $value) {
            $return[$value['UF_MIGRATION_NAME']] = $value;
        }

        return $return;
    }
1192359
public function getTokenExpire()
    {
        return $this->_state->token->obtained
            + $this->_state->token->data->expires_in - time();
    }
420219
public function getAllLastVersion()
	{
		$qb = $this->createQueryBuilder('p');
		$qb->where('p.original IS NULL AND p.state=:state')
			->setParameter(':state', DocumentModel::STATE_PUBLISHED);
		
		$result = $qb->getQuery()->getResult();
		$return = array();
		foreach($result as $original) {
			$return[] = $this->getLastVersion($original->getId());
		}
		return $return;
	}
758111
public function getUnusedFilesListFilter()
    {
        Deprecation::notice('5.0', 'Will be removed in 5.0');

        // Add all records in link tracking
        $usedFiles = FileLink::get()->column('LinkedID');

        // Get all classes that aren't folder
        $fileClasses = array_diff_key(
            ClassInfo::subclassesFor(File::class),
            ClassInfo::subclassesFor(Folder::class)
        );

        // Search on a class-by-class basis
        $classes = ClassInfo::subclassesFor(SiteTree::class);

        $schema = DataObject::getSchema();
        foreach ($classes as $className) {
            // Build query based on all direct has_ones on this class
            $hasOnes = Config::inst()->get($className, 'has_one', Config::UNINHERITED);
            if (empty($hasOnes)) {
                continue;
            }
            $where = [];
            $columns = [];
            foreach ($hasOnes as $relName => $joinClass) {
                if (in_array($joinClass, $fileClasses)) {
                    $column = $relName . 'ID';
                    $columns[] = $column;
                    $quotedColumn = $schema->sqlColumnForField($className, $column);
                    $where[] = "{$quotedColumn} > 0";
                }
            }

            // Get all records with any file ID in the searched columns
            $recordsArray = DataList::create($className)->whereAny($where)->toArray();
            $records = ArrayList::create($recordsArray);
            foreach ($columns as $column) {
                $usedFiles = array_unique(array_merge($usedFiles, $records->column($column)));
            }
        }

        // Create filter based on class and id
        $classFilter = sprintf(
            "(\"File\".\"ClassName\" IN (%s))",
            implode(", ", Convert::raw2sql($fileClasses, true))
        );
        if ($usedFiles) {
            return "\"File\".\"ID\" NOT IN (" . implode(', ', $usedFiles) . ") AND $classFilter";
        } else {
            return $classFilter;
        }
    }