00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _VOMS_API_H
00019 #define _VOMS_API_H
00020
00021 #include <string>
00022 #include <vector>
00023
00024 extern "C" {
00025 #include <openssl/x509.h>
00026 #include <sys/types.h>
00027 #include "newformat.h"
00028 }
00029
00032 struct data {
00033 std::string group;
00034 std::string role;
00035 std::string cap;
00036 };
00037
00040 enum data_type {
00041 TYPE_NODATA,
00042 TYPE_STD,
00043 TYPE_CUSTOM
00044 };
00045
00046 struct contactdata {
00050 std::string nick;
00051 std::string host;
00052 std::string contact;
00053 std::string vo;
00054 int port;
00055 };
00056
00057 struct voms {
00058 friend class vomsdata;
00059 int version;
00060 int siglen;
00061 std::string signature;
00062 std::string user;
00063 std::string userca;
00064 std::string server;
00065 std::string serverca;
00066 std::string voname;
00067 std::string uri;
00068 std::string date1;
00069 std::string date2;
00070 data_type type;
00071 std::vector<data> std;
00072 std::string custom;
00073
00074 std::vector<std::string> fqan;
00075 std::string serial;
00076
00077 private:
00078 AC *ac;
00079 X509 *holder;
00080 public:
00081 voms(const voms &);
00082 voms();
00083 voms &operator=(const voms &);
00084 ~voms();
00085 };
00086
00087 enum recurse_type {
00088 RECURSE_CHAIN,
00089 RECURSE_NONE
00090 };
00091
00092 enum verify_type {
00093 VERIFY_FULL = 0xffffffff,
00094 VERIFY_NONE = 0x00000000,
00095 VERIFY_DATE = 0x00000001,
00096 VERIFY_TARGET = 0x00000002,
00097 VERIFY_KEY = 0x00000004,
00098 VERIFY_SIGN = 0x00000008,
00099 VERIFY_ORDER = 0x00000010,
00100 VERIFY_ID = 0x00000020
00101 };
00102
00105 enum verror_type {
00106 VERR_NONE,
00107 VERR_NOSOCKET,
00108 VERR_NOIDENT,
00109 VERR_COMM,
00110 VERR_PARAM,
00111 VERR_NOEXT,
00112 VERR_NOINIT,
00113 VERR_TIME,
00114 VERR_IDCHECK,
00115 VERR_EXTRAINFO,
00116 VERR_FORMAT,
00117 VERR_NODATA,
00118 VERR_PARSE,
00119 VERR_DIR,
00120 VERR_SIGN,
00121 VERR_SERVER,
00122 VERR_MEM,
00123 VERR_VERIFY,
00124
00125 VERR_TYPE,
00126 VERR_ORDER,
00127 VERR_SERVERCODE
00128 };
00129
00130
00131 typedef bool (*check_sig)(X509 *, void *, verror_type &);
00132
00133 struct vomsdata {
00134 private:
00135 class Initializer {
00136 public:
00137 Initializer();
00138 private:
00139 Initializer(Initializer &);
00140 };
00141
00142 private:
00143 static Initializer init;
00144 std::string ca_cert_dir;
00145 std::string voms_cert_dir;
00146 int duration;
00147 std::string ordering;
00148 std::vector<contactdata> servers;
00149 std::vector<std::string> targets;
00150
00151 public:
00152 verror_type error;
00154 vomsdata(std::string voms_dir = "",
00155 std::string cert_dir = "");
00166 bool LoadSystemContacts(std::string dir = "");
00173 bool LoadUserContacts(std::string dir = "");
00183 std::vector<contactdata> FindByAlias(std::string alias);
00191 std::vector<contactdata> FindByVO(std::string vo);
00199 void Order(std::string att);
00206 void ResetOrder(void);
00208 void AddTarget(std::string target);
00213 std::vector<std::string> ListTargets(void);
00215 void ResetTargets(void);
00216 std::string ServerErrors(void);
00218 bool Retrieve(X509 *cert, STACK_OF(X509) *chain,
00219 recurse_type how = RECURSE_CHAIN);
00228 bool Contact(std::string hostname, int port,
00229 std::string servsubject,
00230 std::string command);
00241 bool ContactRaw(std::string hostname, int port,
00242 std::string servsubject,
00243 std::string command,
00244 std::string &raw, int &version);
00250 void SetVerificationType(verify_type how);
00255 void SetLifetime(int lifetime);
00259 bool Import(std::string buffer);
00266 bool Export(std::string &data);
00273 bool DefaultData(voms &);
00276 std::vector<voms> data;
00279 std::string workvo;
00280 std::string extra_data;
00289 private:
00290 bool loadfile(std::string, uid_t uid, gid_t gid);
00291 bool loadfile0(std::string, uid_t uid, gid_t gid);
00292 bool verifydata(std::string &message, std::string subject, std::string ca,
00293 X509 *holder, voms &v);
00294 bool verifyold(std::string &message, std::string subject, std::string ca,
00295 X509 *holder, voms &v);
00296 bool verifynew(std::string &message, std::string subject, std::string ca,
00297 X509 *holder, voms &v);
00298 X509 *check(check_sig f, void *data);
00299 bool check_cert(X509 *cert);
00300 bool retrieve(X509 *cert, STACK_OF(X509) *chain, recurse_type how,
00301 std::string &bufferold, AC_SEQ **listnew, BIGNUM **bn,
00302 std::string &subject, std::string &ca, X509 **holder);
00303 verify_type ver_type;
00304 std::string serverrors;
00305 };
00306
00307
00308 int getMajorVersionNumber(void);
00309 int getMinorVersionNumber(void);
00310 int getPatchVersionNumber(void);
00311
00312 #endif