ROOT logo
//--------------------------------------------------
#include "TPSocket.h"

//
// This macro should be run together with authserv.C to test
// authentication between two remote ROOT sessions. 
// Run first the authserv.C within a ROOT session on the server
// machine, eg. "srv.machi.ne":
//
//          root[] .x authserv.C(3000)
//
// authserv accepts as argument the port wher it starts listening
// (default 3000).
// You can then run authclient.c in a ROOT session on the client
// machine:
//          root[] .x authclient.C("srv.machi.ne:3000")
//
// and you should get prompted for the credentials, if the case.
// To start a parallel socket of size, for example, 5, enter the
// size as second argument, ie
//
//          root[] .x authclient.C("srv.machi.ne:3000",5)
//

int authclient(const char *host = "up://localhost:3000", int sz = 0)
{
   Int_t par = (sz > 1) ? 1 : 0;

   // Parse protocol, if any
   TString proto(TUrl(host).GetProtocol());
   TString protosave = proto;

   // Get rid of authentication suffix
   TString asfx = proto;
   if (proto.EndsWith("up") || proto.EndsWith("ug")) {
      asfx.Remove(0,proto.Length()-2);
      proto.Resize(proto.Length()-2);
   } else if (proto.EndsWith("s") || proto.EndsWith("k") ||
              proto.EndsWith("g") || proto.EndsWith("h")) {
      asfx.Remove(0,proto.Length()-1);
      proto.Resize(proto.Length()-1);
   }

   // Force parallel (even of size 1)
   TString newurl = "p" + asfx;
   newurl += "://";
   if (strlen(TUrl(host).GetUser())) {
      newurl += TUrl(host).GetUser();
      newurl += "@";
   }
   newurl += TUrl(host).GetHost();
   newurl += ":";
   newurl += TUrl(host).GetPort();

   cout << "authclient: starting a (parallel) authenticated socket at "
        << newurl.Data() << " (size: " << sz << ")" << endl;

   TSocket *s = TSocket::CreateAuthSocket(newurl.Data(),sz);

   // Print out;
   if (s) 
      if (s->IsAuthenticated()) 
         cout << "authclient: auth socket: OK" << endl;
      else
         cout << "authclient: auth socket: failed" << endl;

   // Cleanup
   if (s) {
      // Remove this authentication from the token list to avoid
      // later warnings
      s->GetSecContext()->DeActivate("R");
      delete s;
   }
}
//--------------------------------------------------

 authclient.C:1
 authclient.C:2
 authclient.C:3
 authclient.C:4
 authclient.C:5
 authclient.C:6
 authclient.C:7
 authclient.C:8
 authclient.C:9
 authclient.C:10
 authclient.C:11
 authclient.C:12
 authclient.C:13
 authclient.C:14
 authclient.C:15
 authclient.C:16
 authclient.C:17
 authclient.C:18
 authclient.C:19
 authclient.C:20
 authclient.C:21
 authclient.C:22
 authclient.C:23
 authclient.C:24
 authclient.C:25
 authclient.C:26
 authclient.C:27
 authclient.C:28
 authclient.C:29
 authclient.C:30
 authclient.C:31
 authclient.C:32
 authclient.C:33
 authclient.C:34
 authclient.C:35
 authclient.C:36
 authclient.C:37
 authclient.C:38
 authclient.C:39
 authclient.C:40
 authclient.C:41
 authclient.C:42
 authclient.C:43
 authclient.C:44
 authclient.C:45
 authclient.C:46
 authclient.C:47
 authclient.C:48
 authclient.C:49
 authclient.C:50
 authclient.C:51
 authclient.C:52
 authclient.C:53
 authclient.C:54
 authclient.C:55
 authclient.C:56
 authclient.C:57
 authclient.C:58
 authclient.C:59
 authclient.C:60
 authclient.C:61
 authclient.C:62
 authclient.C:63
 authclient.C:64
 authclient.C:65
 authclient.C:66
 authclient.C:67
 authclient.C:68
 authclient.C:69
 authclient.C:70
 authclient.C:71
 authclient.C:72
 authclient.C:73
 authclient.C:74
 authclient.C:75
 authclient.C:76
 authclient.C:77