Asserts a provided string is a valid duration token representation

    :param  token: duration representation token
    :type   token: string
968734
def valid_token(token):
    
    is_scale = False

    # Check if the token represents a scale
    # If it doesn't set a flag accordingly
    try:
        Scale(token)
        is_scale = True
    except ScaleFormatError:
        pass

    # If token either represents a numerical value, a
    # separator token, or a scale, it is considered valid
    if any([token.isdigit(), token in SEPARATOR_TOKENS, is_scale]):
        return True

    return False
724757
public final boolean isValidEmailConfirmationToken(String token) {
		Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
		return isValidToken(s, Config._EMAIL_TOKEN, token);
	}
742464
public final boolean isValidPasswordResetToken(String token) {
		Sysprop s = CoreUtils.getInstance().getDao().read(getAppid(), identifier);
		return isValidToken(s, Config._RESET_TOKEN, token);
	}
922590
function validateTokenIndent(token, desiredIndentLevel) {
            const indentation = tokenInfo.getTokenIndent(token);
            const expectedChar = indentType === "space" ? " " : "\t";

            return indentation === expectedChar.repeat(desiredIndentLevel * indentSize) ||

                // To avoid conflicts with no-mixed-spaces-and-tabs, don't report mixed spaces and tabs.
                indentation.includes(" ") && indentation.includes("\t");
        }
225029
function _checkIsHttpToken(val) {
	if (typeof val !== 'string' || val.length === 0) {
		return false;
	}
	if (!_isValidTokenChar(val.charCodeAt(0))) {
		return false;
	}
	const len = val.length;
	if (len > 1) {
		if (!_isValidTokenChar(val.charCodeAt(1))) {
			return false;
		}
		if (len > 2) {
			if (!_isValidTokenChar(val.charCodeAt(2))) {
				return false;
			}
			if (len > 3) {
				if (!_isValidTokenChar(val.charCodeAt(3))) {
					return false;
				}
				for (var i = 4; i < len; i++) {
					if (!_isValidTokenChar(val.charCodeAt(i))) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
168901
function isSameToken(token1, token2) {
  if (isValidToken(token1) && isValidToken(token2)) {
    return String(token1) === String(token2);
  }

  return false;
}
1224601
def check_token(data: dict, token: str) -> bool:
    
    param_hash = data.get('hash', '') or ''
    return param_hash == generate_hash(data, token)
1109629
private boolean _validate(Token token, Term term) {

		if (token == null) {
			return true;
		}

		Set<String> terms = token.getTerms();
		if ((!terms.contains(Token.ALL)) && !terms.contains(term.getName()) && !(terms.contains(":" + term.getNatureStr()))) {
			return true;
		}

		boolean flag = token.getRegexs().size() != 0;

		for (String regex : token.getRegexs()) {
			if (term.getName().matches(regex)) {
				flag = false;
				break;
			}
		}

		return flag;
	}
1307669
def _expect_token(lexer, types):
    """"""
    tok = next(lexer)
    if any(isinstance(tok, t) for t in types):
        return tok
    else:
        raise Error("unexpected token: " + str(tok))
78064
def verify_token(self, token) -> bool:
        
        try:
            self.data = jwt.decode(Security.decrypt(token), self.app_secret)
            return True
        except (Exception, BaseException) as error:
            self.errors.append(error)
            return False
        return False
1342575
def access_token_valid(self, token, log_msg):
        
        if (token in self.access_tokens):
            (cookie, issue_time) = self.access_tokens[token]
            age = int(time.time()) - issue_time
            if (age <= (self.access_token_lifetime + 1)):
                self.logger.info(log_msg + " " + token +
                                 " ACCEPTED TOKEN (%ds old)" % age)
                return True
            # Expired...
            self.logger.info(log_msg + " " + token +
                             " EXPIRED TOKEN (%ds old > %ds)" %
                             (age, self.access_token_lifetime))
            # Keep token for 2x lifetim in order to generate
            # helpful expired message
            if (age > (self.access_token_lifetime * 2)):
                del self.access_tokens[token]
            return False
        else:
            self.logger.info(log_msg + " " + token + " REJECTED TOKEN")
            return False
19988
def token_expired(self):
        """"""
        if self._token_timer is None:
            return True
        return timeutil.is_newer_than(self._token_timer, timeutil.ONE_HOUR)
666665
def authenticate(self, token):
        
        if self.verify_token_callback:
            # Specified verify function overrides below
            return self.verify_token_callback(token)

        if not token:
            return False

        name = self.token_manager.verify(token)
        if not name:
            return False

        return True
737499
public static void verifyToken(HttpString header) {
        int length = header.length();
        for(int i = 0; i < length; ++i) {
            byte c = header.byteAt(i);
            if(!ALLOWED_TOKEN_CHARACTERS[c]) {
                throw UndertowMessages.MESSAGES.invalidToken(c);
            }
        }
    }
604464
def is_expired_token(self, client):
        
        if 'expires' not in client:
            return True

        expires = dateutil.parser.parse(client['expires'])
        if expires < datetime.datetime.now():
            return True

        return False
680230
def _verify_token(self):
        
        res = self._session.get(self._token_verification_url)
        if not res.ok:
            raise exceptions.BadToken(consts.LOG_MSG_BAD_TOKEN)
        return True
144531
def check_token_auth(self, token):
        
        serializer = self.get_signature()

        try:
            data = serializer.loads(token)
        except BadSignature:
            log.warning('Received bad token signature')
            return False, None
        if data['username'] not in self.users.users():
            log.warning(
                'Token auth signed message, but invalid user %s',
                data['username']
            )
            return False, None
        if data['hashhash'] != self.get_hashhash(data['username']):
            log.warning(
                'Token and password do not match, %s '
                'needs to regenerate token',
                data['username']
            )
            return False, None
        return True, data['username']