protected function checkNonce(BBUserToken $token, $secret)
    {
        $digest = $token->getDigest();
        $nonce = $token->getNonce();
        $created = $token->getCreated();

        if (time() - strtotime($created) > 300) {
            throw new SecurityException('Request expired', SecurityException::EXPIRED_TOKEN);
        }

        if (md5($nonce.$created.$secret) !== $digest) {
            throw new SecurityException('Invalid authentication informations', SecurityException::INVALID_CREDENTIALS);
        }

        $value = $this->readNonceValue($nonce);
        if (null !== $value && $value[0] + $this->lifetime < time()) {
            throw new SecurityException('Prior authentication expired', SecurityException::EXPIRED_AUTH);
        }

        return true;
    }