if (is_array($token) && isset($_POST['revoke'])) {
            $tokenStore->removeAuthorizationCode($_REQUEST['tokenId']);
            SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML_Module::getModuleURL('oauth2server/manage/status.php'));
        }
    } else {
        if (array_search($_REQUEST['tokenId'], $user['refreshTokens']) !== false) {
            $token = $tokenStore->getRefreshToken($_REQUEST['tokenId']);
            if (is_array($token) && isset($_POST['revoke'])) {
                $tokenStore->removeRefreshToken($_REQUEST['tokenId']);
                SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML_Module::getModuleURL('oauth2server/manage/status.php'));
            }
        } else {
            if (array_search($_REQUEST['tokenId'], $user['accessTokens']) !== false) {
                $token = $tokenStore->getAccessToken($_REQUEST['tokenId']);
                if (is_array($token) && isset($_POST['revoke'])) {
                    $tokenStore->removeAccessToken($_REQUEST['tokenId']);
                    SimpleSAML\Utils\HTTP::redirectTrustedURL(SimpleSAML_Module::getModuleURL('oauth2server/manage/status.php'));
                }
            }
        }
    }
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'oauth2server:manage/token.php');
foreach ($config->getValue('scopes', array()) as $scope => $translations) {
    $t->includeInlineTranslation('{oauth2server:oauth2server:' . $scope . '}', $translations);
}
if (isset($token)) {
    $clientStore = new sspmod_oauth2server_OAuth2_ClientStore($config);
    $client = $clientStore->getClient($token['clientId']);
    if (!is_null($client)) {
     $token = $tokenStore->getRefreshToken($id);
     if (!is_null($token)) {
         if (isset($_REQUEST['tokenId']) && $id === $_REQUEST['tokenId']) {
             $tokenStore->removeRefreshToken($id);
         } else {
             array_push($refreshTokens, $token);
             array_push($liveRefreshTokens, $token['id']);
         }
     }
 }
 $liveAccessTokens = array();
 foreach ($user['accessTokens'] as $id) {
     $token = $tokenStore->getAccessToken($id);
     if (!is_null($token)) {
         if (isset($_REQUEST['tokenId']) && $id === $_REQUEST['tokenId']) {
             $tokenStore->removeAccessToken($id);
         } else {
             array_push($accessTokens, $token);
             array_push($liveAccessTokens, $token['id']);
         }
     }
 }
 $liveClients = array();
 foreach ($user['clients'] as $id) {
     $client = $clientStore->getClient($id);
     if (!is_null($client)) {
         array_push($clients, $client);
         array_push($liveClients, $client['id']);
     }
 }
 if (count($liveAuthorizationCodes) != count($user['authorizationCodes']) || count($liveRefreshTokens) != count($user['refreshTokens']) || count($liveAccessTokens) != count($user['accessTokens']) || count($liveClients) != count($user['clients'])) {
 /**
  * @group unit
  * @group oauth2
  */
 public function testRemoveAccessToken()
 {
     $store = new \sspmod_oauth2server_OAuth2_TokenStore($this->getDefaultConfiguration());
     $token1 = array('id' => 'dummy', 'expire' => time() + 1000);
     $store->addAccessToken($token1);
     $token2 = $store->getAccessToken($token1['id']);
     $this->assertNotNull($token2);
     $this->assertEquals($token1['id'], $token2['id']);
     $store->removeAccessToken($token2['id']);
     $token3 = $store->getAccessToken($token2['id']);
     $this->assertNull($token3);
 }