aboutsummaryrefslogtreecommitdiff
path: root/src/identity-provider
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-05-04 09:44:35 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-05-04 09:44:35 +0000
commit493305a0d4e9d7f9bdc35fabfd8027a487586e47 (patch)
treeec05c1bde5b5cfb7937de6f06dc3586f26f557f9 /src/identity-provider
parent8e9bb50b7543608c2c1a833a5b92f19941ed7a0a (diff)
downloadgnunet-493305a0d4e9d7f9bdc35fabfd8027a487586e47.tar.gz
gnunet-493305a0d4e9d7f9bdc35fabfd8027a487586e47.zip
- rework rest/jsonapi API; bugfixes
Diffstat (limited to 'src/identity-provider')
-rw-r--r--src/identity-provider/identity_token.c9
-rw-r--r--src/identity-provider/plugin_rest_identity_provider.c29
2 files changed, 25 insertions, 13 deletions
diff --git a/src/identity-provider/identity_token.c b/src/identity-provider/identity_token.c
index 3bed6962e..8a90138ec 100644
--- a/src/identity-provider/identity_token.c
+++ b/src/identity-provider/identity_token.c
@@ -98,7 +98,10 @@ decrypt_str_ecdhe (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key,
98 &enc_key, 98 &enc_key,
99 &enc_iv, 99 &enc_iv,
100 str_buf); 100 str_buf);
101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted bytes: %d Expected bytes: %d\n", str_size, cyphertext_len); 101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
102 "Decrypted bytes: %zd Expected bytes: %zd\n",
103 str_size,
104 cyphertext_len);
102 if (-1 == str_size) 105 if (-1 == str_size)
103 { 106 {
104 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ECDH invalid\n"); 107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ECDH invalid\n");
@@ -172,14 +175,14 @@ encrypt_str_ecdhe (const char *plaintext,
172 pub_key, 175 pub_key,
173 &new_key_hash)); 176 &new_key_hash));
174 create_sym_key_from_ecdh(&new_key_hash, &skey, &iv); 177 create_sym_key_from_ecdh(&new_key_hash, &skey, &iv);
175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting string %s\n (len=%d)", 178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting string %s\n (len=%zd)",
176 plaintext, 179 plaintext,
177 strlen (plaintext)); 180 strlen (plaintext));
178 enc_size = GNUNET_CRYPTO_symmetric_encrypt (plaintext, 181 enc_size = GNUNET_CRYPTO_symmetric_encrypt (plaintext,
179 strlen (plaintext), 182 strlen (plaintext),
180 &skey, &iv, 183 &skey, &iv,
181 *cyphertext); 184 *cyphertext);
182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted (len=%d)", enc_size); 185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted (len=%zd)", enc_size);
183 return GNUNET_OK; 186 return GNUNET_OK;
184} 187}
185 188
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c
index 1f03713ea..1e1878cad 100644
--- a/src/identity-provider/plugin_rest_identity_provider.c
+++ b/src/identity-provider/plugin_rest_identity_provider.c
@@ -199,7 +199,7 @@ struct RequestHandle
199 /** 199 /**
200 * Handle to the rest connection 200 * Handle to the rest connection
201 */ 201 */
202 struct RestConnectionDataHandle *conndata_handle; 202 struct GNUNET_REST_RequestHandle *conndata_handle;
203 203
204 /** 204 /**
205 * The processing state 205 * The processing state
@@ -272,6 +272,11 @@ struct RequestHandle
272 char *emsg; 272 char *emsg;
273 273
274 /** 274 /**
275 * Reponse code
276 */
277 int response_code;
278
279 /**
275 * Response object 280 * Response object
276 */ 281 */
277 struct GNUNET_JSONAPI_Object *resp_object; 282 struct GNUNET_JSONAPI_Object *resp_object;
@@ -337,7 +342,7 @@ do_error (void *cls)
337 "{Error while processing request: %s}", 342 "{Error while processing request: %s}",
338 handle->emsg); 343 handle->emsg);
339 resp = GNUNET_REST_create_json_response (json_error); 344 resp = GNUNET_REST_create_json_response (json_error);
340 handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); 345 handle->proc (handle->proc_cls, resp, handle->response_code);
341 cleanup_handle (handle); 346 cleanup_handle (handle);
342 GNUNET_free (json_error); 347 GNUNET_free (json_error);
343} 348}
@@ -434,7 +439,7 @@ token_creat_cont (void *cls,
434 * @param cls the request handle 439 * @param cls the request handle
435 */ 440 */
436static void 441static void
437issue_token_cont (struct RestConnectionDataHandle *con, 442issue_token_cont (struct GNUNET_REST_RequestHandle *con,
438 const char *url, 443 const char *url,
439 void *cls) 444 void *cls)
440{ 445{
@@ -730,7 +735,7 @@ token_collect (void *cls,
730 * @param cls the RequestHandle 735 * @param cls the RequestHandle
731 */ 736 */
732static void 737static void
733list_token_cont (struct RestConnectionDataHandle *con_handle, 738list_token_cont (struct GNUNET_REST_RequestHandle *con_handle,
734 const char* url, 739 const char* url,
735 void *cls) 740 void *cls)
736{ 741{
@@ -919,7 +924,7 @@ exchange_token_ticket_cb (void *cls,
919 * @param cls the RequestHandle 924 * @param cls the RequestHandle
920 */ 925 */
921static void 926static void
922exchange_token_ticket_cont (struct RestConnectionDataHandle *con_handle, 927exchange_token_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle,
923 const char* url, 928 const char* url,
924 void *cls) 929 void *cls)
925{ 930{
@@ -940,7 +945,7 @@ exchange_token_ticket_cont (struct RestConnectionDataHandle *con_handle,
940 * @param cls the RequestHandle 945 * @param cls the RequestHandle
941 */ 946 */
942static void 947static void
943options_cont (struct RestConnectionDataHandle *con_handle, 948options_cont (struct GNUNET_REST_RequestHandle *con_handle,
944 const char* url, 949 const char* url,
945 void *cls) 950 void *cls)
946{ 951{
@@ -965,7 +970,8 @@ options_cont (struct RestConnectionDataHandle *con_handle,
965static void 970static void
966init_cont (struct RequestHandle *handle) 971init_cont (struct RequestHandle *handle)
967{ 972{
968 static const struct GNUNET_REST_RestConnectionHandler handlers[] = { 973 struct GNUNET_REST_RequestHandlerError err;
974 static const struct GNUNET_REST_RequestHandler handlers[] = {
969 {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TOKEN_ISSUE, &issue_token_cont}, 975 {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TOKEN_ISSUE, &issue_token_cont},
970 //{MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_TOKEN_CHECK, &check_token_cont}, 976 //{MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_TOKEN_CHECK, &check_token_cont},
971 {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PROVIDER, &list_token_cont}, 977 {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PROVIDER, &list_token_cont},
@@ -974,9 +980,12 @@ init_cont (struct RequestHandle *handle)
974 GNUNET_REST_HANDLER_END 980 GNUNET_REST_HANDLER_END
975 }; 981 };
976 982
977 if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, handlers, handle)) 983 if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle,
984 handlers,
985 &err,
986 handle))
978 { 987 {
979 handle->emsg = GNUNET_strdup ("Request unsupported"); 988 handle->response_code = err.error_code;
980 GNUNET_SCHEDULER_add_now (&do_error, handle); 989 GNUNET_SCHEDULER_add_now (&do_error, handle);
981 } 990 }
982} 991}
@@ -1054,7 +1063,7 @@ list_ego (void *cls,
1054 * @return GNUNET_OK if request accepted 1063 * @return GNUNET_OK if request accepted
1055 */ 1064 */
1056static void 1065static void
1057rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, 1066rest_identity_process_request(struct GNUNET_REST_RequestHandle *conndata_handle,
1058 GNUNET_REST_ResultProcessor proc, 1067 GNUNET_REST_ResultProcessor proc,
1059 void *proc_cls) 1068 void *proc_cls)
1060{ 1069{