region Token Verification
516724
private static HttpRequest createTokenVerificationRequest(String apptentiveAppKey, String apptentiveAppSignature, String token, HttpRequest.Listener<HttpJsonRequest> listener) {
		// TODO: move this logic to ApptentiveHttpClient
		String URL = Constants.CONFIG_DEFAULT_SERVER_URL + "/debug_token/verify";
		HttpRequest request = new HttpJsonRequest(URL, createVerityRequestObject(token));
		request.setTag(TAG_VERIFICATION_REQUEST);
		request.setMethod(HttpRequestMethod.POST);
		request.setRequestManager(HttpRequestManager.sharedManager());
		request.setRequestProperty("X-API-Version", Constants.API_VERSION);
		request.setRequestProperty("APPTENTIVE-KEY", apptentiveAppKey);
		request.setRequestProperty("APPTENTIVE-SIGNATURE", apptentiveAppSignature);
		request.setRequestProperty("Content-Type", "application/json");
		request.setRequestProperty("Accept", "application/json");
		request.setRequestProperty("User-Agent", String.format(USER_AGENT_STRING, Constants.getApptentiveSdkVersion()));
		request.setRetryPolicy(createVerityRequestRetryPolicy());
		request.addListener(listener);
		return request;
	}
1030495
private boolean isStringTokenMatched(AnalyzedToken token) {
    String testToken = getTestToken(token);
    if (stringRegExp) {
      Matcher m = pattern.matcher(new InterruptibleCharSequence(testToken));
      return m.matches();
    }
    if (caseSensitive) {
      return stringToken.equals(testToken);
    }
    return stringToken.equalsIgnoreCase(testToken);
  }
1371748
def check_token(self, respond):
        
        if respond.status_code == 401:
            self.credential.obtain_token(config=self.config)
            return False
        return True
17958
boolean checkCredentials() {


		if(!httpPut)
		{
			if (token.equals(CONFIG_TOKEN) || token.equals(""))
			{
				//Check if set in an environment variable, used with PaaS providers
				String envToken = getEnvVar( CONFIG_TOKEN);

				if (envToken == ""){
					dbg(INVALID_TOKEN);
					return false;
				}

				this.setToken(envToken);
			}

			return checkValidUUID(this.getToken());
		}else{
			if ( !checkValidUUID(this.getKey()) || this.getLocation().equals(""))
				return false;

			return true;
		}
	}
480585
def _win_user_token_is_admin(user_token):
    '''
    
    '''
    class SID_IDENTIFIER_AUTHORITY(ctypes.Structure):
        _fields_ = [
            ("byte0", ctypes.c_byte),
            ("byte1", ctypes.c_byte),
            ("byte2", ctypes.c_byte),
            ("byte3", ctypes.c_byte),
            ("byte4", ctypes.c_byte),
            ("byte5", ctypes.c_byte),
        ]
    nt_authority = SID_IDENTIFIER_AUTHORITY()
    nt_authority.byte5 = 5

    SECURITY_BUILTIN_DOMAIN_RID = 0x20
    DOMAIN_ALIAS_RID_ADMINS = 0x220
    administrators_group = ctypes.c_void_p()
    if ctypes.windll.advapi32.AllocateAndInitializeSid(
            ctypes.byref(nt_authority),
            2,
            SECURITY_BUILTIN_DOMAIN_RID,
            DOMAIN_ALIAS_RID_ADMINS,
            0, 0, 0, 0, 0, 0,
            ctypes.byref(administrators_group)) == 0:
        raise Exception("AllocateAndInitializeSid failed")

    try:
        is_admin = ctypes.wintypes.BOOL()
        if ctypes.windll.advapi32.CheckTokenMembership(
                user_token,
                administrators_group,
                ctypes.byref(is_admin)) == 0:
            raise Exception("CheckTokenMembership failed")
        return is_admin.value != 0

    finally:
        ctypes.windll.advapi32.FreeSid(administrators_group)
303091
def _verify(self, rj, token):
        
        keys = self.key_jar.get_jwt_verify_keys(rj.jwt)
        return rj.verify_compact(token, keys)
800339
function validateToken (token) {
  const header = jwt.decode(token)
  const now = Math.floor(Date.now() / 1000)
  return header && header.exp > now
}
976363
def validate_regions(self):
        
        for region in self.aws_regions:
            if region not in aws_regions:
                print "Error: Specified region: {} is not a valid aws_region".format(region)
                print "Valid regions are: {}".format(aws_regions)
707109
function checkUrange(i) {
  const start = i;
  let l;

  if (i >= tokensLength) return 0;

  // Check for unicode prefix (u+ or U+)
  if (tokens[i].value === 'U' || tokens[i].value === 'u') i += 1;
  else return 0;

  if (i >= tokensLength) return 0;

  if (tokens[i].value === '+') i += 1;
  else return 0;

  while (i < tokensLength) {
    if (l = checkIdent(i)) i += l;
    else if (l = checkNumber(i)) i += l;
    else if (l = checkUnary(i)) i += l;
    else if (l = _checkUnicodeWildcard(i)) i += l;
    else break;
  }

  tokens[start].urangeEnd = i - 1;

  return i - start;
}
532182
async function _verifyToken (jwksClient, token) {
  const decoded = jwt.decode(token, { complete: true })
  const signingKey = await jwksClient.getSigningKeyAsync(decoded.header.kid)
  return jwt.verifyAsync(token, signingKey.publicKey || signingKey.rsaPublicKey)
}
387973
void scanToken() {

        int character = charAt(currentPosition);

        resetState();

        token.tokenType = Tokens.X_IDENTIFIER;

        switch (character) {

/*
            case '%' :
            case '^' :
            case '&' :
            case ':' :
            case '{' :
            case '}' :
                break;
*/
            case '(' :
                token.tokenString = Tokens.T_OPENBRACKET;
                token.tokenType   = Tokens.OPENBRACKET;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case ')' :
                token.tokenString = Tokens.T_CLOSEBRACKET;
                token.tokenType   = Tokens.CLOSEBRACKET;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case ',' :
                token.tokenString = Tokens.T_COMMA;
                token.tokenType   = Tokens.COMMA;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '*' :
                token.tokenString = Tokens.T_ASTERISK;
                token.tokenType   = Tokens.ASTERISK;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '=' :
                token.tokenString = Tokens.T_EQUALS;
                token.tokenType   = Tokens.EQUALS;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case ';' :
                token.tokenString = Tokens.T_SEMICOLON;
                token.tokenType   = Tokens.SEMICOLON;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '+' :
                token.tokenString = Tokens.T_PLUS;
                token.tokenType   = Tokens.PLUS;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case ':' :
                if (charAt(currentPosition + 1) == ':') {
                    currentPosition   += 2;
                    token.tokenString = Tokens.T_DOUBLE_COLON;
                    token.tokenType   = Tokens.COLON;
                    token.isDelimiter = true;

                    return;
                } else {
                    token.tokenString = Tokens.T_COLON;
                    token.tokenType   = Tokens.COLON;

                    currentPosition++;

                    token.isDelimiter = true;

                    return;
                }
            case '?' :
                if (charAt(currentPosition + 1) == '?') {
                    if (charAt(currentPosition + 2) == '(') {
                        token.tokenString = Tokens.T_OPENBRACKET;
                        token.tokenType   = Tokens.OPENBRACKET;
                        currentPosition   += 3;
                        token.isDelimiter = true;

                        return;
                    } else if (charAt(currentPosition + 2) == ')') {
                        token.tokenString = Tokens.T_CLOSEBRACKET;
                        token.tokenType   = Tokens.CLOSEBRACKET;
                        currentPosition   += 3;
                        token.isDelimiter = true;

                        return;
                    }
                }

                token.tokenString = Tokens.T_QUESTION;
                token.tokenType   = Tokens.QUESTION;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '!' :
                if (charAt(currentPosition + 1) == '=') {
                    token.tokenString = Tokens.T_NOT_EQUALS;
                    token.tokenType   = Tokens.NOT_EQUALS;
                    currentPosition   += 2;
                    token.isDelimiter = true;

                    return;
                }

                token.tokenString = sqlString.substring(currentPosition,
                        currentPosition + 2);
                token.tokenType   = Tokens.X_UNKNOWN_TOKEN;
                token.isDelimiter = true;

                return;

            case '<' :
                if (charAt(currentPosition + 1) == '>') {
                    token.tokenString = Tokens.T_NOT_EQUALS;
                    token.tokenType   = Tokens.NOT_EQUALS;
                    currentPosition   += 2;
                    token.isDelimiter = true;

                    return;
                }

                if (charAt(currentPosition + 1) == '=') {
                    token.tokenString = Tokens.T_LESS_EQUALS;
                    token.tokenType   = Tokens.LESS_EQUALS;
                    currentPosition   += 2;
                    token.isDelimiter = true;

                    return;
                }

                token.tokenString = Tokens.T_LESS;
                token.tokenType   = Tokens.LESS;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '>' :
                if (charAt(currentPosition + 1) == '=') {
                    token.tokenString = Tokens.T_GREATER_EQUALS;
                    token.tokenType   = Tokens.GREATER_EQUALS;
                    currentPosition   += 2;
                    token.isDelimiter = true;

                    return;
                }

                token.tokenString = Tokens.T_GREATER;
                token.tokenType   = Tokens.GREATER;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '|' :
                if (charAt(currentPosition + 1) == '|') {
                    token.tokenString = Tokens.T_CONCAT;
                    token.tokenType   = Tokens.CONCAT;
                    currentPosition   += 2;
                    token.isDelimiter = true;

                    return;
                }

                token.tokenString = sqlString.substring(currentPosition,
                        currentPosition + 2);
                token.tokenType   = Tokens.X_UNKNOWN_TOKEN;
                token.isDelimiter = true;

                return;

            case '/' :
                if (charAt(currentPosition + 1) == '/') {
                    int pos = sqlString.indexOf('\r', currentPosition + 2);

                    if (pos == -1) {
                        pos = sqlString.indexOf('\n', currentPosition + 2);
                    }

                    if (pos == -1) {
                        pos = limit;
                    }

                    token.tokenString = sqlString.substring(currentPosition
                            + 2, pos);
                    token.tokenType   = Tokens.X_REMARK;
                    token.isDelimiter = true;

                    return;
                } else if (charAt(currentPosition + 1) == '*') {
                    int pos = sqlString.indexOf("*/", currentPosition + 2);

                    if (pos == -1) {
                        token.tokenString =
                            sqlString.substring(currentPosition,
                                                currentPosition + 2);
                        token.tokenType   = Tokens.X_UNKNOWN_TOKEN;
                        token.isDelimiter = true;

                        return;
                    }

                    token.tokenString = sqlString.substring(currentPosition
                            + 2, pos);
                    token.tokenType   = Tokens.X_REMARK;
                    token.isDelimiter = true;

                    return;
                }

                token.tokenString = Tokens.T_DIVIDE;
                token.tokenType   = Tokens.DIVIDE;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '-' :
                if (charAt(currentPosition + 1) == '-') {
                    int pos = sqlString.indexOf('\r', currentPosition + 2);

                    if (pos == -1) {
                        pos = sqlString.indexOf('\n', currentPosition + 2);
                    }

                    if (pos == -1) {
                        pos = limit;
                    }

                    token.tokenString = sqlString.substring(currentPosition
                            + 2, pos);
                    token.tokenType   = Tokens.X_REMARK;
                    token.isDelimiter = true;

                    return;
                }

                token.tokenString = Tokens.T_MINUS;
                token.tokenType   = Tokens.MINUS;

                currentPosition++;

                token.isDelimiter = true;

                return;

            case '\"' :
                token.tokenType = Tokens.X_DELIMITED_IDENTIFIER;
                break;

            case '\'' :
                scanCharacterString();

                token.dataType = CharacterType.getCharacterType(Types.SQL_CHAR,
                        token.tokenString.length());
                token.tokenType   = Tokens.X_VALUE;
                token.isDelimiter = true;

                return;

            case 'x' :
            case 'X' :
                if (charAt(currentPosition + 1) == '\'') {
                    currentPosition++;

                    scanBinaryString();

                    if (token.isMalformed) {
                        return;
                    }

                    token.dataType = BinaryType.getBinaryType(
                        Types.SQL_VARBINARY,
                        ((BinaryData) token.tokenValue).length(null));
                    token.tokenType = Tokens.X_VALUE;

                    return;
                }
                break;

            // A VoltDB extension -- disable broken handling for binary literals
            /* disable 19 lines ...
            case 'b' :
            case 'B' :
                if (charAt(currentPosition + 1) == '\'') {
                    currentPosition++;

                    scanBitString();

                    if (token.isMalformed) {
                        return;
                    }

                    token.dataType = BitType.getBitType(
                        Types.SQL_BIT,
                        ((BinaryData) token.tokenValue).bitLength(null));
                    token.tokenType = Tokens.X_VALUE;

                    return;
                }
                break;
            ... disabled 19 lines */
            // End of VoltDB extension

            case 'n' :
            case 'N' :
                if (charAt(currentPosition + 1) == '\'') {
                    currentPosition++;

                    scanCharacterString();

                    if (token.isMalformed) {
                        return;
                    }

                    token.dataType = CharacterType.getCharacterType(
                        Types.SQL_CHAR, token.tokenString.length());
                    token.tokenType = Tokens.X_VALUE;

                    return;
                }
                break;

            case 'u' :
            case 'U' :
                if (charAt(currentPosition + 1) == '&') {
                    if (charAt(currentPosition + 2) == '\'') {
                        currentPosition += 2;
                        token.dataType  = Type.SQL_CHAR;
                        token.tokenType = Tokens.X_VALUE;

                        scanUnicodeString();

                        if (token.isMalformed) {
                            return;
                        }

                        token.dataType = CharacterType.getCharacterType(
                            Types.SQL_CHAR,
                            ((String) token.tokenValue).length());

                        return;
                    }
                }
                break;

            case '_' :

                /**
                 * @todo 1.9.0 - review following
                 * identifier chain must not have catalog identifier
                 * character set specification to be included in the token.dataType
                 */
                currentPosition++;

                scanIdentifierChain();

                if (token.isMalformed) {
                    return;
                }

                if (token.tokenType != Tokens.X_IDENTIFIER
                        || token.namePrePrefix != null) {

                    /** @todo 1.9.0 - review message malformed character set identifier */
                    token.tokenType   = Tokens.X_MALFORMED_STRING;
                    token.isMalformed = true;

                    return;
                }

                token.charsetSchema = token.namePrefix;
                token.charsetName   = token.tokenString;

                scanSeparator();

                if (charAt(currentPosition) == '\'') {
                    scanCharacterString();

                    token.tokenType = Tokens.X_VALUE;
                    token.dataType = CharacterType.getCharacterType(
                        Types.SQL_CHAR, token.tokenString.length());
                    token.isDelimiter = true;

                    return;
                }
                break;

            case '0' :
            case '1' :
            case '2' :
            case '3' :
            case '4' :
            case '5' :
            case '6' :
            case '7' :
            case '8' :
            case '9' :
            case '.' :
                token.tokenType = Tokens.X_VALUE;

                scanNumber();

                return;
        }

        scanIdentifierChain();

        if (token.tokenType == Tokens.X_IDENTIFIER) {
            token.isUndelimitedIdentifier = true;
            token.tokenType = Tokens.getKeywordID(token.tokenString,
                                                  Tokens.X_IDENTIFIER);

            if (token.tokenType == Tokens.X_IDENTIFIER) {
                token.tokenType = Tokens.getNonKeywordID(token.tokenString,
                        Tokens.X_IDENTIFIER);
            } else {
                token.isReservedIdentifier = true;
                token.isCoreReservedIdentifier =
                    Tokens.isCoreKeyword(token.tokenType);
            }
        } else if (token.tokenType == Tokens.X_DELIMITED_IDENTIFIER) {
            token.isDelimitedIdentifier = true;
        }
    }
340856
def check_unique_tokens(sender, instance, **kwargs):
    
    if isinstance(instance, CallbackToken):
        if CallbackToken.objects.filter(key=instance.key, is_active=True).exists():
            instance.key = generate_numeric_token()
160972
def verify(self, token, verifying_key_or_keys, num_required=None):
        
        if not isinstance(verifying_key_or_keys, (list, str, unicode)):
            raise ValueError("Invalid verifying key(s): expected list or string")

        if isinstance(verifying_key_or_keys, list):
            return self._verify_multi(token, verifying_key_or_keys, num_required=num_required)

        else:
            return self._verify_single(token, str(verifying_key_or_keys))
256612
public static boolean validateToken(Controller controller, String tokenName) {
		String clientTokenId = controller.getPara(tokenName);
		if (tokenCache == null) {
			String serverTokenId = controller.getSessionAttr(tokenName);
			controller.removeSessionAttr(tokenName);		// important!
			return StrKit.notBlank(clientTokenId) && clientTokenId.equals(serverTokenId);
		}
		else {
			Token token = new Token(clientTokenId);
			boolean result = tokenCache.contains(token);
			tokenCache.remove(token);
			return result;
		}
	}
914766
def _verify(leniency, numobj, candidate, matcher):
    """"""
    if leniency == Leniency.POSSIBLE:
        return is_possible_number(numobj)
    elif leniency == Leniency.VALID:
        if (not is_valid_number(numobj) or
            not _contains_only_valid_x_chars(numobj, candidate)):
            return False
        return _is_national_prefix_present_if_required(numobj)
    elif leniency == Leniency.STRICT_GROUPING:
        return _verify_strict_grouping(numobj, candidate, matcher)
    elif leniency == Leniency.EXACT_GROUPING:
        return _verify_exact_grouping(numobj, candidate, matcher)
    else:
        raise Exception("Error: unsupported Leniency value %s" % leniency)
150053
private void checkToken(String token) {
        for (int i = 0; i < token.length(); i++) {
            char ch = token.charAt(i);
            if (!TOKEN.get(ch)) {
                throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + token + "\"");
            }
        }
    }
783427
private void checkToken(String s) {
		for (int i = 0; i < s.length(); i++) {
			char ch = s.charAt(i);
			if (!TOKEN.get(ch)) {
				throw new IllegalArgumentException("Invalid token character '" + ch + "' in token \"" + s + "\"");
			}
		}
	}