00001 #ifndef __XRD_GSIOPTS_H__
00002 #define __XRD_GSIOPTS_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 namespace
00033 {
00034
00035
00036
00037
00038 #define WARN(x) std::cerr <<"Secgsi warning: " << x <<'\n' <<std::flush
00039
00040 #define OTINIT(a,b,x) {a, b, sizeof(x)/sizeof(x [0]), x}
00041
00042 #define LIB_XRDVOMS "libXrdVoms.so"
00043
00044 struct OptsMap
00045 {const char *optKey;
00046 int optVal;
00047 };
00048
00049 struct OptsTab
00050 {const char *opName;
00051 int opDflt;
00052 int numMap;
00053 struct OptsMap *mapOpts;
00054 };
00055
00056
00057
00058
00059
00060 static const int azAlways = 1;
00061 static const int azNoVoms = 0;
00062
00063 OptsMap azCallKV[] = {{"always", 1},
00064 {"novoms", 0}
00065 };
00066
00067 OptsTab azCallOpts = OTINIT("-authzcall",1,azCallKV);
00068
00069
00070
00071
00072
00073 static const int azFull = 0;
00074 static const int azLast = 1;
00075 static const int azCred = 1;
00076 static const int azEndo = 2;
00077
00078 OptsMap azPxyKV[] = {{"creds=fullchain", azCred+(10*azFull)},
00079 {"creds=lastcert", azCred+(10*azLast)},
00080 {"endor=fullchain", azEndo+(10*azFull)},
00081 {"endor=lastcert", azEndo+(10*azLast)}
00082 };
00083
00084 OptsTab azPxyOpts = OTINIT("-authz",0,azPxyKV);
00085
00086
00087
00088
00089
00090 static const int caNoVerify = 0;
00091 static const int caVerifyss = 1;
00092 static const int caVerify = 2;
00093
00094 OptsMap caVerKV[] = {{"noverify", caNoVerify},
00095 {"verifyss", caVerifyss},
00096 {"verify", caVerify}
00097 };
00098
00099 OptsTab caVerOpts = OTINIT("-ca",caVerifyss,caVerKV);
00100
00101
00102
00103
00104
00105 static const int crlIgnore = 0;
00106 static const int crlTry = 1;
00107 static const int crlUse = 2;
00108 static const int crlRequire = 3;
00109 static const int crlUpdate = 10;
00110 static const int crlNoUpdt = 0;
00111
00112 OptsMap crl1KV[] = {{"ignore", crlIgnore},
00113 {"try", crlTry},
00114 {"use", crlUse},
00115 {"use,updt", crlUse+crlUpdate},
00116 {"require", crlRequire},
00117 {"require,updt", crlRequire+crlUpdate}
00118 };
00119
00120 OptsTab crlOpts = OTINIT("-crl",crlTry,crl1KV);
00121
00122
00123
00124
00125
00126 static const int dlgIgnore = 0;
00127 static const int dlgReqSign = 1;
00128 static const int dlgSendpxy = 2;
00129
00130 OptsMap sDlgKV[] = {{"ignore", dlgIgnore},
00131 {"request", dlgReqSign}
00132 };
00133
00134 OptsTab sDlgOpts = OTINIT("-dlgpxy",dlgIgnore,sDlgKV);
00135
00136
00137
00138
00139
00140 static const int gmoNoMap = 0;
00141 static const int gmoTryMap = 1;
00142 static const int gmoUseMap = 2;
00143 static const int gmoEntDN = 10;
00144 static const int gmoEntDNHash = 0;
00145
00146 OptsMap gmoKV[] = {{"nomap", gmoNoMap},
00147 {"nomap,usedn", gmoNoMap+gmoEntDN},
00148 {"trymap", gmoTryMap},
00149 {"trymap,usedn", gmoTryMap+gmoEntDN},
00150 {"usemap", gmoUseMap}
00151 };
00152
00153 OptsTab gmoOpts = OTINIT("-gmopts",gmoTryMap,gmoKV);
00154
00155
00156
00157
00158
00159 OptsMap tdnsKV[] = {{"false", 0},
00160 {"true", 1}
00161 };
00162
00163 OptsTab tdnsOpts = OTINIT("-trustdns",0,tdnsKV);
00164
00165
00166
00167
00168
00169 static const int vatIgnore = 0;
00170 static const int vatExtract = 1;
00171 static const int vatRequire = 2;
00172
00173 OptsMap vomsatKV[] = {{"ignore", vatIgnore},
00174 {"extract", vatExtract},
00175 {"require", vatRequire}
00176 };
00177
00178 OptsTab vomsatOpts = OTINIT("-vomsat",vatIgnore,vomsatKV);
00179
00180
00181
00182
00183
00184 const char *getOptName(OptsTab &oTab, int opval)
00185 {
00186 for (int i = 0; i < oTab.numMap; i++)
00187 if (opval == oTab.mapOpts[i].optVal) return oTab.mapOpts[i].optKey;
00188 return "nothing";
00189 }
00190
00191
00192
00193
00194
00195 int getOptVal(OptsTab &oTab, const char *oVal)
00196 {
00197 if (isdigit(*oVal))
00198 {int n = atoi(oVal);
00199 for (int i = 0; i < oTab.numMap; i++)
00200 if (n == oTab.mapOpts[i].optVal) return n;
00201 } else {
00202 for (int i = 0; i < oTab.numMap; i++)
00203 if (!strcmp(oVal, oTab.mapOpts[i].optKey))
00204 return oTab.mapOpts[i].optVal;
00205 }
00206
00207 if (oTab.opDflt >= 0)
00208 {WARN("invalid " <<oTab.opName <<" argument '" <<oVal <<
00209 "'; using '" <<getOptName(oTab, oTab.opDflt) <<"' instead!");
00210 }
00211 return oTab.opDflt;
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 }
00237 #endif