00001
00002 #include "TPSocket.h"
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 int authclient(const char *host = "up://localhost:3000", int sz = 0)
00026 {
00027 Int_t par = (sz > 1) ? 1 : 0;
00028
00029
00030 TString proto(TUrl(host).GetProtocol());
00031 TString protosave = proto;
00032
00033
00034 TString asfx = proto;
00035 if (proto.EndsWith("up") || proto.EndsWith("ug")) {
00036 asfx.Remove(0,proto.Length()-2);
00037 proto.Resize(proto.Length()-2);
00038 } else if (proto.EndsWith("s") || proto.EndsWith("k") ||
00039 proto.EndsWith("g") || proto.EndsWith("h")) {
00040 asfx.Remove(0,proto.Length()-1);
00041 proto.Resize(proto.Length()-1);
00042 }
00043
00044
00045 TString newurl = "p" + asfx;
00046 newurl += "://";
00047 if (strlen(TUrl(host).GetUser())) {
00048 newurl += TUrl(host).GetUser();
00049 newurl += "@";
00050 }
00051 newurl += TUrl(host).GetHost();
00052 newurl += ":";
00053 newurl += TUrl(host).GetPort();
00054
00055 cout << "authclient: starting a (parallel) authenticated socket at "
00056 << newurl.Data() << " (size: " << sz << ")" << endl;
00057
00058 TSocket *s = TSocket::CreateAuthSocket(newurl.Data(),sz);
00059
00060
00061 if (s)
00062 if (s->IsAuthenticated())
00063 cout << "authclient: auth socket: OK" << endl;
00064 else
00065 cout << "authclient: auth socket: failed" << endl;
00066
00067
00068 if (s) {
00069
00070
00071 s->GetSecContext()->DeActivate("R");
00072 delete s;
00073 }
00074 }
00075
00076