Added hostname to configuration and example code.
[trust_router.git] / gsscon / test / gsscon_server.c
index c4170c0..be56372 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, JANET(UK)
+ * Copyright (c) 2012, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  */
 
 #include <gsscon.h>
+#include <assert.h>
 
+static int cb_print_names(gss_name_t clientName,
+                         gss_buffer_t displayName,
+                         void *data)
+{
+  assert(clientName != NULL);
+  assert(data == NULL);
+  printf("Gss name: %-*s\n",
+        displayName->length, displayName->value);
+  return 0;
+}
+
+  
 /* --------------------------------------------------------------------------- */
 
 static int SetupListeningSocket (int  inPort, 
@@ -119,7 +132,8 @@ int main (int argc, const char *argv[])
     int listenFD = -1;
     gss_ctx_id_t gssContext = GSS_C_NO_CONTEXT;
     int i = 0;
-        
+    gss_buffer_desc nameBuffer = {0, "trustidentity"};
+
     for (i = 1; (i < argc) && !err; i++) {
         if ((strcmp (argv[i], "--port") == 0) && (i < (argc - 1))) {
             port = strtol (argv[++i], NULL, 0);
@@ -144,6 +158,7 @@ int main (int argc, const char *argv[])
         int authorizationError = 0;
         
         connectionFD = accept (listenFD, NULL, NULL);
+
         if (connectionFD < 0) {
             if (errno != EINTR) { 
                 err = errno;
@@ -152,7 +167,8 @@ int main (int argc, const char *argv[])
         }
         
         printf ("Accepting new connection...\n");
-        connectionErr = gsscon_passive_authenticate (connectionFD, &gssContext);
+        connectionErr = gsscon_passive_authenticate (connectionFD, nameBuffer, &gssContext,
+                                                    cb_print_names, NULL);
         
         if (!connectionErr) {
             connectionErr = gsscon_authorize (gssContext,