gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: rework de-/serialization


From: gnunet
Subject: [taler-anastasis] branch master updated: rework de-/serialization
Date: Wed, 09 Sep 2020 11:47:58 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 1dc4b8e  rework de-/serialization
     new a904825  Merge branch 'master' of ssh://git.taler.net/anastasis into 
master
1dc4b8e is described below

commit 1dc4b8ed80882f9621e75009767cc9e293aa339d
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Wed Sep 9 11:42:58 2020 +0200

    rework de-/serialization
---
 src/include/anastasis_json.h | 455 ++++++++++++++++++++++++++++---------------
 1 file changed, 303 insertions(+), 152 deletions(-)

diff --git a/src/include/anastasis_json.h b/src/include/anastasis_json.h
index 9d4227f..1952ba2 100644
--- a/src/include/anastasis_json.h
+++ b/src/include/anastasis_json.h
@@ -25,170 +25,321 @@
 
 #include <jansson.h>
 #include <gnunet/gnunet_util_lib.h>
+#include "anastasis_error_codes.h"
 
-/**
- * Defines a user with all possible attributes.
- */
-struct UserData
+struct ANASTASIS_BackupState
 {
-  /**
-   * First name of user
-   */
-  char *first_name;
-
-  /**
-   * Last name of user
-   */
-  char *last_name;
-
-  /**
-   * Birthdate of user
-   */
-  struct GNUNET_TIME_Absolute date;
-
-  /**
-   * Social security number for swiss citizens (AHV number)
-   */
-  char *AHV_number;
-
-  // FIXME: more attributes following here
+  enum state
+  {
+    ANASTASIS_BA_GET_SELECT_CONTINENT,
+    ANASTASIS_BA_GET_SELECT_COUNTRY,
+    ANASTASIS_BA_GET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_BA_GET_ADD_AUTHENTICATION_METHOD,
+    ANASTASIS_BA_GET_ADD_POLICY,
+    ANASTASIS_BA_GET_PAY,
+    ANASTASIS_BA_SET_SELECT_CONTINENT,
+    ANASTASIS_BA_SET_SELECT_COUNTRY,
+    ANASTASIS_BA_SET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_BA_SET_ADD_AUTHENTICATION_METHOD,
+    ANASTASIS_BA_SET_ADD_POLICY,
+    ANASTASIS_BA_SET_PAY
+  };
+
+  union
+  {
+
+    struct
+    {
+      // empty!
+    } select_continent;
+
+    struct
+    {
+      const char *continent;
+    } select_country;
+
+    struct
+    {
+      const char *continent;
+      const char *country;
+      const char *currency;       // derived or per manual override!
+      json_t *user_attributes;
+    } enter_attributes;
+
+    struct
+    {
+      const char *continent;
+      const char *country;
+      const char *currency;
+      json_t *user_attributes;
+
+      struct AuthenticationDetails
+      {
+        enum AuthenticationMethod
+        {
+          SMS,
+          VIDEO,
+          SECQUEST,
+          EMAIL,
+          SNAILMAIL
+        };
+        char *provider_url;
+        union Truth
+        {
+
+          struct
+          {
+            char *phone_number;
+          } sms;
+
+          struct
+          {
+            char *question;
+            char *answer;             // FIXME: Reasonable to store answer in 
clear text here?
+          } secquest;
+
+          struct
+          {
+            char *mailaddress;
+          } email;
+
+          struct
+          {
+            char *full_name;
+            char *street;             // street name + number
+            char *postal_code;
+            char *city;
+            char *country;
+          } snailmail;
+
+          struct
+          {
+            char *path_to_picture;
+          } video;
+        } truth;
+      }*ad;       // array
+      size_t ad_length;
+    } add_authentication;
+    struct
+    {
+      const char *continent;
+      const char *country;
+      const char *currency;
+      json_t *user_attributes;
+
+      struct AuthenticationDetails
+      {
+        enum AuthenticationMethod
+        {
+          SMS,
+          VIDEO,
+          SECQUEST,
+          EMAIL,
+          SNAILMAIL
+        };
+        char *provider_url;
+        union Truth
+        {
+
+          struct
+          {
+            char *phone_number;
+          } sms;
+
+          struct
+          {
+            char *question;
+            char *answer;             // FIXME: Reasonable to store answer in 
clear text here?
+          } secquest;
+
+          struct
+          {
+            char *mailaddress;
+          } email;
+
+          struct
+          {
+            char *full_name;
+            char *street;             // street name + number
+            char *postal_code;
+            char *city;
+            char *country;
+          } snailmail;
+
+          struct
+          {
+            char *path_to_picture;
+          } video;
+        } truth;
+      }*ad;       // array
+      size_t ad_length;
+
+      struct PolicyDetails
+      {
+        struct AuthenticationDetails *ad;         // array
+      }*pd;       // array
+      size_t pd_length;
+    } add_policy;
+    // FIXME: add_payment
+  } details;
 };
 
-/**
- * Defines a state of a policy object.
- */
-struct PolicyState
+struct ANASTASIS_RecoveryState
 {
-  // FIXME add attributes here
+  enum state
+  {
+    ANASTASIS_RS_GET_SELECT_CONTINENT,
+    ANASTASIS_RS_GET_SELECT_COUNTRY,
+    ANASTASIS_RS_GET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_RS_GET_SOLVE_CHALLENGE,
+    ANASTASIS_RS_SET_SELECT_CONTINENT,
+    ANASTASIS_RS_SET_SELECT_COUNTRY,
+    ANASTASIS_RS_SET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_RS_SET_SOLVE_CHALLENGE
+  };
+
+  struct
+  {
+    // empty!
+  } select_continent;
+
+  struct
+  {
+    const char *continent;
+  } select_country;
+
+  struct
+  {
+    const char *continent;
+    const char *country;
+    const char *currency;     // derived or per manual override!
+    json_t *user_attributes;
+  } enter_attributes;
+
+  struct
+  {
+    const char *continent;
+    const char *country;
+    const char *currency;
+    json_t *user_attributes;
+
+    struct ChallengeDetails
+    {
+      enum AuthenticationMethod
+      {
+        SMS,
+        VIDEO,
+        SECQUEST,
+        EMAIL,
+        SNAILMAIL
+      };
+      char *provider_url;
+      union Challenge
+      {
+
+        struct
+        {
+          char *phone_number;
+          char *code;
+        } sms;
+
+        struct
+        {
+          char *question;
+          char *answer;           // FIXME: Reasonable to store answer in 
clear text here?
+        } secquest;
+
+        struct
+        {
+          char *mailaddress;
+          char *code;
+        } email;
+
+        struct
+        {
+          char *full_name;
+          char *street;           // street name + number
+          char *postal_code;
+          char *city;
+          char *country;
+          char *code;
+        } snailmail;
+
+        struct
+        {
+          char *path_to_picture;
+          char *code;
+        } video;
+      } truth;
+    }*cd;     // array
+    size_t cd_length;
+  } solve_challenge;
 };
 
-/**
- * Defines a state of a truth object.
- */
-struct TruthState
+struct ANASTASIS_BackupAction
 {
-  // FIXME add attributes here
+  enum action
+  {
+    ANASTASIS_BA_GET_SELECT_CONTINENT,
+    ANASTASIS_BA_GET_SELECT_COUNTRY,
+    ANASTASIS_BA_GET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_BA_GET_ADD_AUTHENTICATION_METHOD,
+    ANASTASIS_BA_GET_ADD_POLICY,
+    ANASTASIS_BA_GET_PAY,
+    ANASTASIS_BA_SET_SELECT_CONTINENT,
+    ANASTASIS_BA_SET_SELECT_COUNTRY,
+    ANASTASIS_BA_SET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_BA_SET_ADD_AUTHENTICATION_METHOD,
+    ANASTASIS_BA_SET_ADD_POLICY,
+    ANASTASIS_BA_SET_PAY
+  };
 };
 
-/**
- * Defines a state of a challenge object.
- */
-struct ChallengeState
+struct ANASTASIS_RecoveryAction
 {
-  // FIXME add attributes here
+  enum action
+  {
+    ANASTASIS_RS_GET_SELECT_CONTINENT,
+    ANASTASIS_RS_GET_SELECT_COUNTRY,
+    ANASTASIS_RS_GET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_RS_GET_SOLVE_CHALLENGE,
+    ANASTASIS_RS_SET_SELECT_CONTINENT,
+    ANASTASIS_RS_SET_SELECT_COUNTRY,
+    ANASTASIS_RS_SET_ENTER_USER_ATTRIBUTES,
+    ANASTASIS_RS_SET_SOLVE_CHALLENGE
+  };
 };
 
-
-/**
- * Parses the country config file for the country code and
- * returns a json object containing the country-specific
- * attributes needed to create the user identifier.
- *
- * @param conf_filename name of config file
- * @param country_code country code (Alpha-2 code)
- * @return reference to json object containing data of specified country
- */
-json_t *
-ANASTASIS_JSON_get_country_conf (
-  const char *conf_filename,
-  const char *country_code);
-
-
-/**
- * Returns default providers.
- *
- * @param prov_filename filename which contains the default providers
- * @return reference to json object containing the default providers
- */
-json_t *
-ANASTASIS_JSON_get_default_providers (const char *prov_filename);
-
-
-/**
- * Loads user attributes from a json object.
- *
- * @param state_memory json object containing all stored states
- * @return reference to user data
- */
-struct UserData *
-ANASTASIS_JSON_user_deserialize (const json_t *state_memory);
-
-
-/**
- * Stores user attributes into a json object.
- *
- * @param user user data
- * @return json object representing user data
- */
-json_t *
-ANASTASIS_JSON_user_serialize (const struct UserData *user);
-
-
-/**
- * Restores states of policies from a json object.
- * Used during backup process.
- *
- * @param state_memory json object containing all stored states (backup 
process)
- * @return array of policy states
- */
-struct PolicyState **
-ANASTASIS_JSON_policies_deserialize (const json_t *state_memory);
-
-
-/**
- * Stores states of policies into a json object.
- * Used during backup process.
- *
- * @param policy_states array of policy states
- * @return json object containing policy states
- */
-json_t *
-ANASTASIS_JSON_policies_serialize (const struct PolicyState **policy_states);
-
-
-/**
- * Restores states of truths from a json object.
- * Used during backup process.
- *
- * @param state_memory json object containing all stored states (backup 
process)
- * @return array of truth states
- */
-struct TruthState **
-ANASTASIS_JSON_truths_deserialize (const json_t *state_memory);
-
-
-/**
- * Stores states of truths into a json object.
- * Used during backup process.
- *
- * @param truth_states array of truth states
- * @return json object containing all truth states
- */
-json_t *
-ANASTASIS_JSON_truths_serialize (const struct TruthState **truth_states);
-
-
-/**
- * Restores states of challenges from a json object.
- * Used during recovery process.
- *
- * @param state_memory json object containing all stored states (recovery 
process)
- * @return array of truth states
- */
-struct ChallengeState **
-ANASTASIS_JSON_challenges_deserialize (const json_t *state_memory);
-
-
-/**
- * Stores states of challenges into a json object.
- * Used during recovery process.
- *
- * @param challenge_states array of challenge states
- * @return json object containing all truth states
- */
-json_t *
-ANASTASIS_JSON_challenges_serialize (const struct
-                                     ChallengeState **challenge_states);
-
+typedef void
+(*ANASTASIS_BackupApplyActionCallback)(
+  void *cls,
+  const struct ANASTASIS_BackupState *bs,
+  enum ANASTASIS_ErrorCode error);
+
+typedef void
+(*ANASTASIS_RecoveryApplyActionCallback)(
+  void *cls,
+  const struct ANASTASIS_RecoveryState *rs,
+  enum ANASTASIS_ErrorCode error);
+
+struct ANASTASIS_BackupState *
+ANASTASIS_get_initial_backup_state ();
+
+struct ANASTASIS_RecoveryState *
+ANASTASIS_get_initial_recovery_state ();
+
+void
+ANASTASIS_apply_anastasis_backup_action (
+  struct GNUNET_CURL_Context *ctx,
+  struct ANASTASIS_BackupState *bs,
+  struct ANASTASIS_BackupAction *ba,
+  ANASTASIS_BackupApplyActionCallback cb);
+
+void
+ANASTASIS_apply_anastasis_recovery_action (
+  struct GNUNET_CURL_Context *ctx,
+  struct ANASTASIS_RecoveryState *rs,
+  struct ANASTASIS_RecoveryAction *ra,
+  ANASTASIS_RecoveryApplyActionCallback cb);
 
 #endif  /* _ANASTASIS_JSON_H */
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]