bin_PROGRAMS = src/moonshot
+
AM_CFLAGS =
AM_CPPFLAGS = \
nodist_src_moonshot_SOURCES = \
libmoonshot/moonshot-msrpc_s.c
-bin_PROGRAMS += src/msrpc-client
-
-nodist_src_msrpc_client_SOURCES = \
- src/msrpc-client.vala \
- src/moonshot-msrpc.vapi \
- libmoonshot/moonshot-msrpc_c.c
-
-src_msrpc_client_LDADD = $(moonshot_LIBS)
-
endif
if IPC_DBUS
libmoonshot_libmoonshot_la_SOURCES += libmoonshot/libmoonshot-dbus.c
-bin_PROGRAMS += src/dbus-client
-
-src_dbus_client_SOURCES = src/dbus-client.vala
-src_dbus_client_CPPFLAGS = $(moonshot_CFLAGS) $(AM_CPPFLAGS)
-src_dbus_client_LDADD = $(moonshot_LIBS)
-
CLEANFILES = $(dbusservice_DATA)
EXTRA_DIST = $(dbusservice_in_files)
endif
-noinst_PROGRAMS = tests/basic
+noinst_PROGRAMS = \
+ examples/client \
+ tests/basic
+
+examples_client_SOURCES = examples/client.c
+examples_client_CPPFLAGS = $(libmoonshot_CFLAGS) $(AM_CPPFLAGS)
+examples_client_LDADD = ${top_builddir}/libmoonshot/libmoonshot.la
tests_basic_SOURCES = tests/basic.c
tests_basic_CPPFLAGS = $(libmoonshot_CFLAGS) $(AM_CPPFLAGS)
-tests_basic_LDADD = ${top_builddir}/libmoonshot/libmoonshot.la
+tests_basic_LDADD = ${top_builddir}/libmoonshot/libmoonshot.la $(moonshot_LIBS)
if OS_WIN32
--- /dev/null
+#include <libmoonshot.h>
+
+#include <stdio.h>
+
+int main (int argc,
+ char **argv[])
+{
+ MoonshotError *error = NULL;
+ int success;
+
+ char *nai,
+ *password,
+ *server_certificate_hash,
+ *ca_certificate,
+ *subject_name_constraint,
+ *subject_alt_name_constraint;
+
+ success = moonshot_get_default_identity (&nai,
+ &password,
+ &server_certificate_hash,
+ &ca_certificate,
+ &subject_name_constraint,
+ &subject_alt_name_constraint,
+ &error);
+
+ if (success) {
+ printf ("Got identity: %s %s %s\n", nai, password, server_certificate_hash);
+ return 0;
+ } else {
+ printf ("Error: %s\n", error->message);
+ return 1;
+ }
+}
&key);
if (status != 0) {
- *error = _moonshot_error_new (MOONSHOT_ERROR_OS_ERROR,
- "Unable to read registry key HKLM\\%s",
- MOONSHOT_INSTALL_PATH_KEY);
+ *error = moonshot_error_new (MOONSHOT_ERROR_OS_ERROR,
+ "Unable to read registry key HKLM\\%s",
+ MOONSHOT_INSTALL_PATH_KEY);
return;
}
status = RegQueryValueEx (key, NULL, NULL, &value_type, exe_path, &length);
if (value_type != REG_SZ) {
- *error = _moonshot_error_new (MOONSHOT_ERROR_OS_ERROR,
- "Value of registry key HKLM\\%s is invalid. "
- "Please set it to point to the location of "
- "moonshot.exe",
- MOONSHOT_INSTALL_PATH_KEY);
+ *error = moonshot_error_new (MOONSHOT_ERROR_OS_ERROR,
+ "Value of registry key HKLM\\%s is invalid. "
+ "Please set it to point to the location of "
+ "moonshot.exe",
+ MOONSHOT_INSTALL_PATH_KEY);
return;
}
if (status != 0) {
- *error = _moonshot_error_new (MOONSHOT_ERROR_OS_ERROR,
- "Unable to read value of registry key HKLM\\%s",
- MOONSHOT_INSTALL_PATH_KEY);
+ *error = moonshot_error_new (MOONSHOT_ERROR_OS_ERROR,
+ "Unable to read value of registry key HKLM\\%s",
+ MOONSHOT_INSTALL_PATH_KEY);
return;
}
&startup_info, &process_info);
if (status != 0) {
- *error = _moonshot_error_new (MOONSHOT_ERROR_UNABLE_TO_START_SERVICE,
- "Unable to spawn the moonshot server at '%s'",
- exe_path);
+ *error = moonshot_error_new (MOONSHOT_ERROR_UNABLE_TO_START_SERVICE,
+ "Unable to spawn the moonshot server at '%s'",
+ exe_path);
return;
}
}
}*/
- /**
- * Returns the default identity - most recently used.
- *
- * @param nai_out NAI stored in the ID card
- * @param password_out Password stored in the ID card
- *
- * @return true on success, false if no identities are stored
- */
+int moonshot_get_default_identity (char **nai_out,
+ char **password_out,
+ char **server_certificate_hash_out,
+ char **ca_certificate_out,
+ char **subject_name_constraint_out,
+ char **subject_alt_name_constraint_out,
+ MoonshotError **error)
+{
+ int status;
+
+ status = rpc_client_bind (&moonshot_binding_handle,
+ MOONSHOT_ENDPOINT_NAME,
+ RPC_PER_USER);
+
+ printf ("RPC status: %i\n", status);
+};
+++ /dev/null
-[DBus (name = "org.janet.Moonshot")]
-interface Moonshot : Object {
- public abstract bool get_identity (string nai, string password, string service,
- out string nai_out, out string password_out,
- out string server_certificate_hash, out string ca_certificate, out string subject_name_constraint, out string subject_alt_name_constraint) throws DBus.Error;
- public abstract bool get_default_identity (out string nai_out, out string password_out,
- out string server_certificate_hash, out string ca_certificate, out string subject_name_constraint, out string subject_alt_name_constraint) throws DBus.Error;
-}
-
-void main () {
- try {
- string nai_out, password_out, certificate_out;
- string a, b, c;
-
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- var demo = (Moonshot) conn.get_object ("org.janet.Moonshot",
- "/org/janet/moonshot");
-
-
- if (demo.get_default_identity (out nai_out,
- out password_out,
- out certificate_out,
- out a,
- out b,
- out c))
- {
- stdout.printf ("default identity: %s %s\n", nai_out, password_out);
- }
- else
- {
- stdout.printf ("Unable to get default identity.\n");
- }
-
-
- if (demo.get_identity ("username@issuer",
- "pass",
- "",
- out nai_out,
- out password_out,
- out certificate_out,
- out a,
- out b,
- out c))
- {
- stdout.printf ("%s %s %s\n", nai_out, password_out, certificate_out);
- }
- else
- {
- stdout.printf ("The nai, password or service doesnt match the selected id_card\n");
- }
-
- } catch (DBus.Error e) {
- stderr.printf ("%s\n", e.message);
- }
-}
+++ /dev/null
-using Rpc;
-using MoonshotRpcInterface;
-
-void main () {
- Rpc.client_bind (ref MoonshotRpcInterface.binding_handle,
- "/org/janet/Moonshot",
- Rpc.Flags.PER_USER);
-
- string nai = null, password = null, certificate = null;
- string a = null, b = null, c = null;
- bool result = false;
-
- /* Get default identity */
- Rpc.AsyncCall call = Rpc.AsyncCall();
- get_default_identity (call, ref nai, ref password);
- result = call.complete_bool ();
-
- if (result == false)
- error ("Unable to get default identity");
- else
- stdout.printf ("default: %s %s\n", nai, password);
-
- /* Prompt for identity */
- call = Rpc.AsyncCall();
- get_identity (call,
- "username@issuer",
- "pass",
- "service",
- ref nai,
- ref password,
- ref certificate,
- ref a,
- ref b,
- ref c);
- result = call.complete_bool ();
-
- if (result == false)
- error ("The nai, password or service does not match the selected identity\n");
- else
- stdout.printf ("%s %s %s\n", nai, password, certificate);
-
- Rpc.client_unbind (ref MoonshotRpcInterface.binding_handle);
-}