void oauth_check_valid_signature_header_2() { boost::optional<std::string> auth_header = std::string("OAuth oauth_consumer_key=\"x3tHSMbotPe5fBlItMbg\", oauth_nonce=\"ZGsGj6qzGYUhSLHJWUC8tyW6RbxOQuX4mv6PKj0mU\", oauth_signature=\"H%2Fxl6jdk4dC0WaONfohWfZhcHYA%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1475754589\", oauth_token=\"15zpwgGjdjBu1DD65X7kcHzaWqfQpvqmMtqa3ZIO\", oauth_version=\"1.0\""); test_request req( "GET", "http", "www.openstreetmap.org", "80", "/api/0.6/relation/165475/full", "", 1475754589, auth_header); assert_equal<boost::optional<std::string> >( oauth::detail::signature_base_string(req), std::string("GET&http%3A%2F%2Fwww.openstreetmap.org%2Fapi%2F0.6%2Frelation%2F165475%2Ffull&oauth_consumer_key%3Dx3tHSMbotPe5fBlItMbg%26oauth_nonce%3DZGsGj6qzGYUhSLHJWUC8tyW6RbxOQuX4mv6PKj0mU%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1475754589%26oauth_token%3D15zpwgGjdjBu1DD65X7kcHzaWqfQpvqmMtqa3ZIO%26oauth_version%3D1.0")); std::string consumer_key("x3tHSMbotPe5fBlItMbg"); std::string consumer_secret("1NZRJ0u2o7OilPDe60nfZsKJTC7RUZPrNfYwGBjATw"); std::string token_id("15zpwgGjdjBu1DD65X7kcHzaWqfQpvqmMtqa3ZIO"); std::string token_secret("H3Vb9Kgf4LpTyVlft5xsI9MwzknQsTu6CkHE0qK3"); test_secret_store store(consumer_key, consumer_secret, token_id, token_secret); assert_equal<boost::optional<std::string> >( oauth::detail::hashed_signature(req, store), std::string("H/xl6jdk4dC0WaONfohWfZhcHYA=")); oauth::validity::copacetic copacetic(token_id); oauth::validity::validity expected(copacetic); assert_equal(oauth::is_valid_signature(req, store, store, store), expected); }
token_cache() : cache(T_LAST_TOKEN - T_FIRST_TOKEN) { typename std::vector<StringT>::iterator it = cache.begin(); for (unsigned int i = T_FIRST_TOKEN; i < T_LAST_TOKEN; ++i, ++it) { *it = StringT(boost::wave::get_token_value(token_id(i))); } }
inline Token& include_guards<Token>::state_1a(Token& t) { token_id id = token_id(t); if (T_NOT == BASE_TOKEN(id)) state = &include_guards::state_1b; else if (!is_skippable(id)) current_state = false; return t; }
inline Token const& include_guards<Token>::state_1b(Token const& t) { token_id id = token_id(t); if (T_IDENTIFIER == id && t.get_value() == "defined") state = &include_guards::state_1c; else if (!is_skippable(id)) current_state = false; return t; }
inline Token& include_guards<Token>::state_2(Token& t) { token_id id = token_id(t); if (T_PP_DEFINE == id) state = &include_guards::state_3; else if (!is_skippable(id)) current_state = false; return t; }
inline Token& include_guards<Token>::state_5(Token& t) { token_id id = token_id(t); if (T_EOF == id) detected_guards = current_state; else if (!is_skippable(id)) current_state = false; return t; }
inline Token& include_guards<Token>::state_3(Token& t) { token_id id = token_id(t); if (T_IDENTIFIER == id && t.get_value() == guard_name) state = &include_guards::state_4; else if (!is_skippable(id)) current_state = false; return t; }
inline Token& include_guards<Token>::state_1e(Token& t) { token_id id = token_id(t); if (T_RIGHTPAREN == id) state = &include_guards::state_2; else if (!is_skippable(id)) current_state = false; return t; }
inline Token const& include_guards<Token>::state_0(Token const& t) { token_id id = token_id(t); if (T_PP_IFNDEF == id) state = &include_guards::state_1; else if (T_PP_IF == id) state = &include_guards::state_1a; else if (!is_skippable(id)) current_state = false; return t; }
inline Token& include_guards<Token>::state_1d(Token& t) { token_id id = token_id(t); if (T_IDENTIFIER == id) { guard_name = t.get_value(); state = &include_guards::state_1e; } else if (!is_skippable(id)) current_state = false; return t; }
/* read next id token and look it up as a node name; if it does not exist and alloc is 1, allocate it; if it does not exist and alloc is 0, abort with error */ int token_node(int alloc) { const char *id = token_id(); if (htsi_has(name2node, (char *)id)) return htsi_get(name2node, (char *)id); if (alloc) { node2name[num_nodes] = strdup(id); htsi_set(name2node, node2name[num_nodes], num_nodes); return num_nodes++; } fprintf(stderr, "Error: unknown node %s\n", id); abort(); }
inline Token& include_guards<Token>::state_4(Token& t) { token_id id = token_id(t); if (T_PP_IF == id || T_PP_IFDEF == id || T_PP_IFNDEF == id) ++if_depth; else if (T_PP_ENDIF == id) { if (if_depth > 0) --if_depth; else state = &include_guards::state_5; } return t; }
inline Token const& include_guards<Token>::state_1c(Token const& t) { token_id id = token_id(t); if (T_LEFTPAREN == id) state = &include_guards::state_1d; else if (T_IDENTIFIER == id) { guard_name = t.get_value(); state = &include_guards::state_2; } else if (!is_skippable(id)) current_state = false; return t; }
static struct ast_node* term(void) { struct ast_node_const *_const; struct ast_node *node; if (match(TOKEN_ID)) { node = token_id(lex_prev.id); return node; } else if (match(TOKEN_DOUBLE)) { _const = ast_node_const(VALUE_TYPE_DIGIT, &lex_prev.real); return AST_NODE(_const); } else if (match(TOKEN_STRING)) { _const = ast_node_const(VALUE_TYPE_STRING, lex_prev.string); return AST_NODE(_const); } else if (match(TOKEN_LBRACKET)) { node = process_matrix(); return node; } return NULL; }
// access functions for the tree_to_xml functionality static int get_token_id(lex_token const &t) { return ID_FROM_TOKEN(token_id(t)); }
// access functions for the tree_to_xml functionality static int get_token_id(lex_token const &t) { return token_id(t); }
bool is_valid() const { return 0 != data && token_id(*data) != T_UNKNOWN; }
// accessors operator token_id() const { return token_id(*data); }
bool is_eoi() const { return 0 == data || token_id(*data) == T_EOI; }
// accessors operator token_id() const { return 0 != data ? token_id(*data) : T_EOI; }