Cleans up expired Kapost previews after twice the token expiry
320989
private function cleanUpExpiredPreviews() {
        $expiredPreviews=KapostObject::get()->filter('IsKapostPreview', true)->filter('LastEdited:LessThan', date('Y-m-d H:i:s', strtotime('-'.(KapostService::config()->preview_data_expiry).' minutes')));
        if($expiredPreviews->count()>0) {
            foreach($expiredPreviews as $kapostObj) {
                $kapostObj->delete();
            }
        }
    }
816507
private function pruneTokens()
    {
        $now = new \DateTime('now');
        // Delete access tokens that have no refresh token associated
        $qb = $this->entityManager->createQueryBuilder();
        $items = $qb->select('token')
            ->from(AccessToken::class, 'token')
            ->where($qb->expr()->lt('token.expiryDateTime', ':now'))
            ->getQuery()->execute([':now' => $now]);

        $this->pruneResults($items);

        // Delete all expired access tokens that have expired refresh tokens
        $qb = $this->entityManager->createQueryBuilder();
        $items = $qb->select('token')
            ->from(AccessToken::class, 'token')
            ->where($qb->expr()->lt('token.expiryDateTime', ':now'))
            ->getQuery()->execute([':now' => $now]);

        $this->pruneResults($items);

        // Delete all expired auth codes
        $qb = $this->entityManager->createQueryBuilder();
        $qb->delete(AuthCode::class, 'token')
            ->where($qb->expr()->lt('token.expiryDateTime', ':now'))
            ->getQuery()->execute([':now' => $now]);
    }
652586
function touch(token, cb) {
  var date = stampify(conf.session_maxage);
  db.getClient(function(err, client, done) {
    client.query("UPDATE tokens SET expires_at = $1 WHERE token = $2", [date, token], function() {
      cb.apply(null, arguments);
      done();
    });
  });
}
1195268
def cancel_expired_invitations(invitations=None):
    
    expiration_date = timezone.now() - settings.WALDUR_CORE['INVITATION_LIFETIME']
    if not invitations:
        invitations = models.Invitation.objects.filter(state=models.Invitation.State.PENDING)
    invitations = invitations.filter(created__lte=expiration_date)
    invitations.update(state=models.Invitation.State.EXPIRED)
575047
private function cleanExpired()
    {
        // 10% chance to clean the database of expired sessions
        if (mt_rand(1, 10) == 1) {
            $expiredTime = $this->now - $this->secondsUntilExpiration;
            $stmt = $this->db->prepare("DELETE FROM {$this->tableName} WHERE time_updated < {$expiredTime}");
            $stmt->execute();
        }
    }
149557
public function preview() {
        $auth=$this->request->getVar('auth');
        $token=KapostPreviewToken::get()->filter('Code', Convert::raw2sql($auth))->first();
        
        //Verify the token exists and hasn't expired yet
        if(!empty($token) && $token!==false && $token->exists() && time()-strtotime($token->Created)<self::config()->preview_token_expiry*60 && $token->KapostRefID==$this->urlParams['ID']) {
            $kapostObj=KapostObject::get()->filter('KapostRefID', Convert::raw2sql($this->urlParams['ID']))->sort('"Created" DESC')->first();
            if(!empty($kapostObj) && $kapostObj!==false && $kapostObj->exists()) {
                $previewController=$kapostObj->renderPreview();
                
                $this->extend('updatePreviewDisplay', $kapostObj, $previewController);
                
                return $previewController;
            }
        }
        
        
        //Token expired or object not found
        if(class_exists('ErrorPage')) {
            $response=ErrorPage::response_for(404);
            if(!empty($response)) {
                return parent::httpError(404, $response);
            }
        }
        
        return parent::httpError(404);
    }
598264
def revoke_tokens(self):
        

        self.is_active = False
        self.save()

        self.refresh_token.revoke_tokens()
28172
@Override
    @Scheduled(fixedRate = REAP_INTERVAL)
    public void removeExpired() {
        final Set<String> reapable = sessions.entrySet().stream()
                .filter(e -> e.getValue().getExpires().isPresent())
                .filter(e -> e.getValue().getExpires().get().isBefore(now()))
                .map(Map.Entry::getKey).collect(toSet());
        reapable.forEach(key -> {
            final FedoraSession s = sessions.get(key);
            if (s != null) {
                try {
                    s.expire();
                } catch (final RepositoryRuntimeException e) {
                    LOGGER.error("Got exception rolling back expired session {}: {}", s, e.getMessage());
                }
            }
            sessions.remove(key);
        });
    }
270985
public final void validateExpiration() throws TokenExpiredException {
        Date d = new Date();
        Date expD = new Date(getExpiration());
        boolean expired = d.after(expD);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "Current time = " + d + ", expiration time = " + expD);
        }
        if (expired) {
            String msg = "The token has expired: current time = \"" + d + "\", expire time = \"" + expD + "\"";
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, msg);
            }
            throw new TokenExpiredException(expirationInMilliseconds, msg);
        }
    }
1332475
def clean_expired_tokens(opts):
    '''
    
    '''
    loadauth = salt.auth.LoadAuth(opts)
    for tok in loadauth.list_tokens():
        token_data = loadauth.get_tok(tok)
        if 'expire' not in token_data or token_data.get('expire', 0) < time.time():
            loadauth.rm_token(tok)
922971
def cleanup(self):
        """"""
        expires = maybe_timedelta(self.expires)
        for model in self.TaskModel, self.TaskSetModel:
            model._default_manager.delete_expired(expires)
75924
function cleanUp() {
    publicAPI.removeRenderObserver(model.view_id);
    publicAPI.unsubscribeRenderTopic();
    while (model.urlToRevoke.length) {
      window.URL.revokeObjectURL(model.urlToRevoke.pop());
    }
  }
688129
public function cleanExpiredTokens($expiryTime)
    {
        $sql = "DELETE FROM {$this->tableName} WHERE {$this->expiresColumn} < ? ";

        $query = $this->connection->prepare($sql);
        $query->execute(array(date("Y-m-d H:i:s", $expiryTime)));
    }
1348872
def expire_combined_submission(combined_submission_id, opts = {})
      data, _status_code, _headers = expire_combined_submission_with_http_info(combined_submission_id, opts)
      data
    end
556759
private void cleanupLoggedOutToken(HttpServletRequest req, HttpServletResponse res) {
        AuthenticateApi aa = new AuthenticateApi(ssoCookieHelper, authenticationService);
        aa.simpleLogout(req, res);
    }
1047063
def expire_submission(submission_id, opts = {})
      data, _status_code, _headers = expire_submission_with_http_info(submission_id, opts)
      data
    end
1284529
function validateExpires(req, expires) {
	if(!expires) {
		return false;
	}
	if(Date.now() - (expires * 1000) > 0) {
		clearAllPersistentData(req);
		return false;
	}
	return true;
}