From: Schanzenbach, Martin Date: Sun, 9 Jul 2017 13:32:55 +0000 (+0200) Subject: -add CLI X-Git-Tag: gnunet-0.11.0rc0~24^2~72 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=271f13592c0c5213c7056b252882c467a791a1e5;p=oweals%2Fgnunet.git -add CLI --- diff --git a/src/identity-provider/Makefile.am b/src/identity-provider/Makefile.am index cc9692a9a..5355b1221 100644 --- a/src/identity-provider/Makefile.am +++ b/src/identity-provider/Makefile.am @@ -25,7 +25,8 @@ plugin_LTLIBRARIES = \ libgnunet_plugin_rest_identity_provider.la bin_PROGRAMS = \ - gnunet-identity-token + gnunet-identity-token \ + gnunet-idp libexec_PROGRAMS = \ gnunet-service-identity-provider @@ -68,6 +69,14 @@ libgnunet_plugin_rest_identity_provider_la_LDFLAGS = \ $(GN_PLUGIN_LDFLAGS) +gnunet_idp_SOURCES = \ + gnunet-idp.c +gnunet_idp_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la \ + $(top_builddir)/src/identity/libgnunetidentity.la \ + $(GN_LIBINTL) + gnunet_identity_token_SOURCES = \ gnunet-identity-token.c gnunet_identity_token_LDADD = \ diff --git a/src/identity-provider/gnunet-idp.c b/src/identity-provider/gnunet-idp.c new file mode 100644 index 000000000..0dd565da6 --- /dev/null +++ b/src/identity-provider/gnunet-idp.c @@ -0,0 +1,220 @@ +/* + This file is part of GNUnet. + Copyright (C) 2012-2015 GNUnet e.V. + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ +/** + * @author Martin Schanzenbach + * @file src/identity-provider/gnunet-idp.c + * @brief Identity Provider utility + * + */ + +#include "platform.h" +#include "gnunet_util_lib.h" +#include "gnunet_namestore_service.h" +#include "gnunet_identity_service.h" +#include "gnunet_signatures.h" + +/** + * The attribute + */ +static char* attr_name; + +/** + * Attribute value + */ +static char* attr_value; + +/** + * Ego name + */ +static char* ego_name; + +/** + * Identity handle + */ +static struct GNUNET_IDENTITY_Handle *identity_handle; + +/** + * Namestore handle + */ +static struct GNUNET_NAMESTORE_Handle *namestore_handle; + +/** + * Namestore queue + */ +static struct GNUNET_NAMESTORE_QueueEntry *ns_qe; + +/** + * Master ABE key + */ +static struct GNUNET_CRYPTO_AbeMasterKey *abe_key; + +static void +do_cleanup(void *cls) +{ + if (NULL != ns_qe) + GNUNET_NAMESTORE_cancel (ns_qe); + if (NULL != namestore_handle) + GNUNET_NAMESTORE_disconnect (namestore_handle); + if (NULL != identity_handle) + GNUNET_IDENTITY_disconnect (identity_handle); + if (NULL != abe_key) + GNUNET_free (abe_key); +} + +static void +ns_error_cb (void *cls) +{ + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + "Failed."); + do_cleanup(NULL); + return; +} + +static void +store_attr_cont (void *cls, + int32_t success, + const char*emsg) +{ + if (GNUNET_SYSERR == success) { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%s\n", emsg); + } else { + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + "Sucessfully added identity attribute %s=%s\n", + attr_name, attr_value); + } + GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); +} + +static void +abe_lookup_cb (void *cls, + const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, + const char *label, + unsigned int rd_count, + const struct GNUNET_GNSRECORD_Data *rd) +{ + struct GNUNET_GNSRECORD_Data new_record; + int i; + ssize_t size; + + for (i=0;i