Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
UpnDB.hpp
1 //
2 // BEGIN_DOUGLAS_MARK_ROYER_COPYRIGHT
3 //
4 // Copyright (C) 1993-2018 Douglas Mark Royer, All Rights Reserved.
5 //
6 // NOTICE:
7 //
8 // THIS SOURCE CODE BELONGS TO DOUGLAS MARK ROYER
9 // THIS CODE IS CONSIDERED A
10 // TRADE SECRET AND IS NOT TO BE DIVULGED OR USED BY PARTIES WHO HAVE
11 // NOT RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER.
12 //
13 // THIS PROGRAM IS AN UNPUBLISHED WORK FULLY PROTECTED BY THE UNITED
14 // STATES COPYRIGHT LAWS AND IS CONSIDERED A TRADE SECRET BELONGING
15 // TO THE COPYRIGHT HOLDER.
16 //
17 // THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
18 // COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
19 // AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
20 // OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
21 // BE SUBJECT TO CIVIL LIABILITY.
22 //
23 // THIS NOTICE AND THE ABOVE COPYRIGHT NOTICE MUST REMAIN IN ALL
24 // COPIES AND ANY DERIVED WORK.
25 //
26 // ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
27 //
28 // THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN IS
29 // PROVIDED ON AN "AS IS" BASIS AND INET-CONSULTING.COM, INC.
30 // DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
31 // NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
32 // HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
33 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
34 // PURPOSE. ANY SERVICE CONTRACT WILL BE UNDER A SEPARATE
35 // LICENSE.
36 //
37 // END_DOUGLAS_MARK_ROYER_COPYRIGHT
38 //
39 
40 #ifndef DOUGLAS_MARK_ROYER_LIBPCUSERDB_UPNDB_HPP__
41 #define DOUGLAS_MARK_ROYER_LIBPCUSERDB_UPNDB_HPP__
42 
43 #include <SaS/Sql/SQL.hpp>
44 
45 #ifdef BUILDING_SAS_UPNDB_LIBRARY
46 #include "UpnDbTypedefs.hpp"
47 #include "Change.hpp"
48 #include "UpnDbRecord.hpp"
49 #include "UpnDbApplicationRecord.hpp"
50 #include "UpnDbSpokenRecord.hpp"
51 #include "UpnDbPhotoRecord.hpp"
52 #include "UpnDbBinaryRecord.hpp"
53 #include "UpnDbUpnRecord.hpp"
54 #include "UpnDbCountryCodeRecord.hpp"
55 #include "UpnDbStateRecord.hpp"
56 #include "UpnDbUserPersonalRecord.hpp"
57 #include "UpnDbUserRecord.hpp"
58 #include "UpnDbResourceRecord.hpp"
59 #include "UpnDbAddressRecord.hpp"
60 #include "UpnDbEmailRecord.hpp"
61 #include "UpnDbCcRecord.hpp"
62 #include "UpnDbPrefRecord.hpp"
63 #include "UpnDbCustomerRecord.hpp"
64 #include "UpnDbCompanyRecord.hpp"
65 #include "UpnDbContactRecord.hpp"
66 #include "UpnDbSite.hpp"
67 #include "UpnDbCertRecord.hpp"
68 #include "UpnDbMembershipRecord.hpp"
69 #else
70 #include <SaS/UpnDb/UpnDbTypedefs.hpp>
71 #include <SaS/UpnDb/Change.hpp>
72 #include <SaS/UpnDb/UpnDbRecord.hpp>
73 #include <SaS/UpnDb/UpnDbApplicationRecord.hpp>
74 #include <SaS/UpnDb/UpnDbSpokenRecord.hpp>
75 #include <SaS/UpnDb/UpnDbPhotoRecord.hpp>
76 #include <SaS/UpnDb/UpnDbBinaryRecord.hpp>
77 #include <SaS/UpnDb/UpnDbUpnRecord.hpp>
78 #include <SaS/UpnDb/UpnDbCountryCodeRecord.hpp>
79 #include <SaS/UpnDb/UpnDbStateRecord.hpp>
80 #include <SaS/UpnDb/UpnDbUserPersonalRecord.hpp>
81 #include <SaS/UpnDb/UpnDbUserRecord.hpp>
82 #include <SaS/UpnDb/UpnDbResourceRecord.hpp>
83 #include <SaS/UpnDb/UpnDbAddressRecord.hpp>
84 #include <SaS/UpnDb/UpnDbEmailRecord.hpp>
85 #include <SaS/UpnDb/UpnDbCcRecord.hpp>
86 #include <SaS/UpnDb/UpnDbPrefRecord.hpp>
87 #include <SaS/UpnDb/UpnDbCustomerRecord.hpp>
88 #include <SaS/UpnDb/UpnDbCompanyRecord.hpp>
89 #include <SaS/UpnDb/UpnDbContactRecord.hpp>
90 #include <SaS/UpnDb/UpnDbSite.hpp>
91 #include <SaS/UpnDb/UpnDbCertRecord.hpp>
92 #include <SaS/UpnDb/UpnDbMembershipRecord.hpp>
93 #endif
94 
95 #include <vector>
96 #include <map>
97 
98 #ifdef BUILDING_SAS_UPNDB_LIBRARY
99 #define EXPORT_UPN EXPORT_OUT
100 #else
101 #define EXPORT_UPN EXPORT_IN
102 #endif
103 
106 
107 namespace SoftwareAndServices
108 {
109  namespace Library
110  {
111  namespace UPN
112  {
113 
114  extern const char * True_s;
115  extern const char * False_s;
116 
125  extern void time_t2Sql(time_t In, String & Results);
126 
130  struct OrderByName
131  {
141  bool operator()(const char * One,
142  const char * Two) const;
143  };
144 
149  {
159  bool operator()(const char * One,
160  const char * Two) const;
161  };
162 
168  class EXPORT_UPN UpnDB
169  : public instance<UpnDB>
170  {
171 
172  public:
173 
180  class EXPORT_UPN Realm
181  : public instance<Realm>
182  {
183  public:
184 
189  Realm();
190 
195  virtual ~Realm();
196 
203  Realm * Parent() const;
204 
211  void Parent(Realm * NewParent);
212 
218  std::map<const char*, Realm*,OrderByName> & Children();
219 
226  void AddChild(Realm & NewChild);
227 
234  void RemoveChild(Realm & OldChild);
235 
241  UpnDbRealmRecord & RealmData();
242 
243  private:
244 
249  Realm * _Parent;
250 
255  std::map<const char*, Realm*,OrderByName> * _Children;
256 
261  UpnDbRealmRecord * _Data;
262 
263  };
264 
265 
269  UpnDB();
270 
274  virtual ~UpnDB();
275 
364  static bool CreateSqlDatabase(const char * DatabaseHost,
365  const char * DatabaseName,
366  const char * DatabaseUserName,
367  const char * DatabaseUserPassword,
368  unsigned short DatabasePort,
369  const char * DatabaseUpnDbPrefix,
370  const char * RuntimeUsername,
371  const char * RuntimePassword,
372  const char * DatabaseType,
373  const char * InitFiles,
374  String & ErrorMessages);
375 
404  UpnDbAuthHandle_t AppLogin(const String & GUID,
405  const String & password,
406  const String & appGUID,
407  const String & appPassword,
408  const String & host,
409  const String & db);
410 
411 
439  UpnDbAuthHandle_t AppLogin(const char * GUID,
440  const char * password,
441  const char * appGUID,
442  const char * appPassword,
443  const char * host,
444  const char * db);
445 
446 
497  UpnDbAuthHandle_t
498  Authenticate(X509_STORE_CTX * Store,
499  const char * const Upn,
500  const char * const Realm,
501  const char * const RemoteHost = nullptr,
502  int16_t RemotePort = 0);
503 
523  UpnDbAuthHandle_t Authenticate(UpnDbRealmId_t realm,
524  const String & upn,
525  const String & pw);
526 
527 
547  UpnDbAuthHandle_t Authenticate(UpnDbRealmId_t realm,
548  const char * upn,
549  const char * pw);
550 
551 
565  bool VerifyPassword(UpnDbAuthHandle_t AuthHandle,
566  const char * Password);
583  bool VerifyPassword(UpnDbAuthHandle_t AuthHandle,
584  UpnDbUpnId_t ForUpnId,
585  const char * Password);
586 
593  void Logout(UpnDbAuthHandle_t AuthHandle);
594 
603  bool GetGUID(String & Results) const;
604 
625  bool GetResourceId(UpnDbAuthHandle_t AuthHandle,
626  const char * Name,
627  UpnDbResourceId_t & Results) const;
628 
648  bool GetResource(UpnDbAuthHandle_t AuthHandle,
649  UpnDbResourceId_t Id,
650  String & Name) const;
651 
679  UpnDbResourceId_t
680  AddResourceId(UpnDbAuthHandle_t AuthHandle,
681  UpnDbResourceId_t System,
682  const char * Name);
683 
696  bool DeleteResourceId(UpnDbAuthHandle_t AuthHandle,
697  UpnDbResourceId_t ResourceId);
698 
716  bool RenameResourceId(UpnDbAuthHandle_t AuthHandle,
717  UpnDbResourceId_t ResourceId,
718  const char * NewName);
719 
730  bool CanHaveChildren(UpnDbAuthHandle_t AuthHandle,
731  UpnDbRealmId_t RealmId);
732 
764  UpnDbRealmId_t AddRealm(UpnDbAuthHandle_t AuthHandle,
765  UpnDbRealmId_t ParentRealm,
766  const String & NewRealm,
767  const String & Description,
768  bool CanHaveChild = true,
769  bool CanHaveUpns = true,
770  bool CanRemove = true,
771  bool Disabled = false);
772 
804  UpnDbRealmId_t AddRealm(UpnDbAuthHandle_t AuthHandle,
805  UpnDbRealmId_t ParentRealm,
806  const char * NewRealm,
807  const char * Description,
808  bool CanHaveChild = true,
809  bool CanHaveUpns = true,
810  bool CanRemove = true,
811  bool Disabled = false);
812 
813 
829  bool IsMember(UpnDbAuthHandle_t AuthHandle,
830  UpnDbMembershipId_t listId,
831  UpnDbUpnId_t upnId,
832  String & expireTime);
833 
847  UpnDbMembershipId_t AddMembership(UpnDbAuthHandle_t AuthHandle,
848  UpnDbRealmId_t realm,
849  const String & name);
850 
851 
863  bool RemoveMembership(UpnDbAuthHandle_t AuthHandle,
864  UpnDbMembershipId_t listId);
865 
880  UpnDbMembershipId_t
881  GetMembershipId(UpnDbAuthHandle_t AuthHandle,
882  UpnDbRealmId_t realmId,
883  const String & listName) const;
884 
899  bool RemoveUpnFromList(UpnDbAuthHandle_t AuthHandle,
900  UpnDbMembershipId_t list,
901  UpnDbUpnId_t upn);
902 
920  bool UpdateUpnInList(UpnDbAuthHandle_t AuthHandle,
921  UpnDbMembershipId_t list,
922  UpnDbUpnId_t upn,
923  const String & expire);
924 
925 
944  bool AddUpnToList(UpnDbAuthHandle_t AuthHandle,
945  UpnDbMembershipId_t list,
946  UpnDbUpnId_t upn,
947  const String & expire);
948 
949 
971  bool RemoveRealm(UpnDbAuthHandle_t AuthHandle,
972  UpnDbRealmId_t realmToRemove,
973  bool force = false);
974 
1002  bool
1003  UpdateRealmChild(UpnDbAuthHandle_t AuthHandle,
1004  UpnDbRealmId_t toUpdateId,
1005  bool canHaveChild,
1006  bool force = false);
1007 
1008 
1024  bool ReparentRealm(UpnDbAuthHandle_t AuthHandle,
1025  UpnDbRealmId_t realm,
1026  UpnDbRealmId_t newParent);
1027 
1045  bool
1046  GetUserRecord(UpnDbAuthHandle_t Auth,
1047  std::map<UpnDbUserId_t,UpnDbUserRecord *> & RecResults,
1048  UpnDbUpnId_t TheUpnId) const;
1049 
1060  UpnDbRealmId_t GetRealmId(UpnDbAuthHandle_t AuthHandle) const;
1061 
1070  const char * GetRealmName(UpnDbRealmId_t Rid) const;
1071 
1082  UpnDbRealmId_t GetUpnRealm(UpnDbUpnId_t upnId) const;
1083 
1094  UpnDbRealmId_t GetAddressRealm(UpnDbAddressId_t addrId) const;
1095 
1106  UpnDbRealmId_t GetListRealm(UpnDbMembershipId_t listId) const;
1107 
1121  bool IsDecendantRealm(UpnDbAuthHandle_t id,
1122  UpnDbRealmId_t ParentRealm,
1123  UpnDbRealmId_t ChildRealm);
1124 
1133  UpnDbUpnId_t GetAddressUpnId(UpnDbAddressId_t addrId) const;
1134 
1143  UpnDbRealmId_t GetRealmId(const String & realm) const;
1144 
1153  UpnDbRealmId_t GetRealmId(const char * realm) const;
1154 
1169  static UpnDbRealmId_t GetRealmId(const String & realm,
1170  SQL * sql,
1171  const char * Prefix);
1172 
1187  static UpnDbRealmId_t GetRealmId(const char * realm,
1188  SQL * sql,
1189  const char * Prefix);
1190 
1191 
1207  std::list<const char*> *
1208  GetRealmsForUpn(UpnDbAuthHandle_t AuthHandle,
1209  const char * Upn) const;
1210 
1225  bool GetRealms(UpnDbAuthHandle_t AuthHandle,
1226  std::vector<UpnDbRealmRecord*> & Results) const;
1227 
1243  bool GetRealms(UpnDbAuthHandle_t AuthHandle,
1244  std::map<const char *,Realm*> & Results) const;
1245 
1259  bool IsAdminForUpn(UpnDbUpnId_t upn1,
1260  UpnDbUpnId_t upn2) const;
1261 
1273  bool IsAdmin(UpnDbRealmId_t realm,
1274  UpnDbUpnId_t upn) const;
1275 
1285  bool IsAdmin(UpnDbAuthHandle_t AuthHandle) const;
1286 
1295  bool IsSiteAdmin(UpnDbUpnId_t upn) const;
1296 
1306  bool IsSiteAdmin(UpnDbAuthHandle_t AuthHandle) const;
1307 
1308 
1333  bool UpdateUpn(UpnDbAuthHandle_t AuthHandle,
1334  UpnDbUpnId_t upnId,
1335  const String & namePrefix,
1336  const String & nameFirst,
1337  const String & nameMiddle,
1338  const String & nameLast,
1339  const String & nameSuffix);
1340 
1365  bool UpdateUpn(UpnDbAuthHandle_t AuthHandle,
1366  UpnDbUpnId_t upnId,
1367  const char * namePrefix,
1368  const char * nameFirst,
1369  const char * nameMiddle,
1370  const char * nameLast,
1371  const char * nameSuffix);
1372 
1373 
1392  bool AddRealmAdmin(UpnDbAuthHandle_t AuthHandle,
1393  UpnDbRealmId_t realm,
1394  UpnDbUpnId_t upnId);
1395 
1414  bool RemoveRealmAdmin(UpnDbAuthHandle_t AuthHandle,
1415  UpnDbRealmId_t realm,
1416  UpnDbUpnId_t upnId);
1417 
1445  UpnDbAddressId_t AddAddress(UpnDbAuthHandle_t AuthHandle,
1446  UpnDbUpnId_t upnId,
1447  UpnDbResourceId_t addressType,
1448  const String & street1,
1449  const String & street2,
1450  const String & city,
1451  const String & state,
1452  const String & zip,
1453  const String & country);
1454 
1482  UpnDbAddressId_t AddAddress(UpnDbAuthHandle_t AuthHandle,
1483  UpnDbUpnId_t UpnId,
1484  UpnDbResourceId_t AddressType,
1485  const String & Street1,
1486  const String & Street2,
1487  const String & City,
1488  const String & State,
1489  const String & Zip,
1490  UpnDbCountryCodeId_t Country);
1491 
1520  bool
1521  UpdateAddress(UpnDbAuthHandle_t AuthHandle,
1522  UpnDbAddressId_t AddrId,
1523  UpnDbResourceId_t AddressType,
1524  const String & Street1,
1525  const String & Street2,
1526  const String & City,
1527  const String & State,
1528  const String & Zip,
1529  UpnDbCountryCodeId_t Country);
1530 
1543  bool RemoveAddress(UpnDbAuthHandle_t AuthHandle,
1544  UpnDbAddressId_t addrId);
1545 
1574  bool GetAddress(UpnDbAuthHandle_t AuthHandle,
1575  UpnDbUpnId_t UpnId,
1576  std::map<const char *,
1578  OrderByIName> & Results) const;
1579 
1587  void SetMxHost(const String & mxHost);
1588 
1609  UpnDbEmailId_t AddEmail(UpnDbAuthHandle_t AuthHandle,
1610  UpnDbUpnId_t upnId,
1611  UpnDbResourceId_t ResourceType,
1612  const String & Email,
1613  const String & Name);
1614 
1629  bool RemoveEmail(UpnDbAuthHandle_t AuthHandle,
1630  UpnDbUpnId_t upnId,
1631  UpnDbEmailId_t emailId);
1632 
1647  bool GetEmailAddress(UpnDbAuthHandle_t AuthHandle,
1648  std::vector<String*> * Results,
1649  UpnDbUpnId_t upnId) const;
1650 
1651 
1670  bool GetEmail(UpnDbAuthHandle_t AuthHandle,
1671  String & Results,
1672  UpnDbUpnId_t upnId,
1673  unsigned int Nth) const;
1674 
1743  unsigned int SendEmail(UpnDbAuthHandle_t AuthHandle,
1744  UpnDbRealmId_t authRealmId,
1745  UpnDbUpnId_t fromUpnDbUpnId,
1746  const String & toListEmail,
1747  const String & toListNames,
1748  const String & ccListEmail,
1749  const String & ccListNames,
1750  const String & bccListEmail,
1751  const String & bccListNames,
1752  const String & errorsToList,
1753  const String & subject,
1754  const std::vector<String*> & otherHeaders,
1755  const String & body,
1756  const std::vector<String*> & attachments,
1757  const std::vector<String*> & attachMimeType);
1758 
1789  UpnDbCcId_t AddCc(UpnDbAuthHandle_t AuthHandle,
1790  UpnDbUpnId_t upnId,
1791  UpnDbAddressId_t addrId,
1792  const String & number,
1793  unsigned char expireMonth, // 0-11
1794  unsigned short expireYear, // YYYY
1795  const String & back,
1796  const char type,
1797  const String & cardHoldersName);
1798 
1813  bool RemoveCc(UpnDbAuthHandle_t AuthHandle,
1814  UpnDbUpnId_t upnId,
1815  UpnDbCcId_t cc);
1816 
1832  UpnDbCcId_t GetCc(UpnDbAuthHandle_t AuthHandle,
1833  UpnDbUpnId_t upnId,
1834  unsigned int Nth) const;
1835 
1851  char * GetCcLast4(UpnDbAuthHandle_t AuthHandle,
1852  UpnDbCcId_t cc) const;
1853 
1872  bool GetCcExpire(UpnDbAuthHandle_t AuthHandle,
1873  String & Results,
1874  UpnDbCcId_t cc) const;
1875 
1896  bool ChargeCc(UpnDbAuthHandle_t AuthHandle,
1897  UpnDbCcId_t cc,
1898  const String & partNumber,
1899  const String & description,
1900  const String & amount);
1901 
1920  bool ChargeCcMonthly(UpnDbAuthHandle_t AuthHandle,
1921  UpnDbCcId_t cc,
1922  const String & partNumber,
1923  const String & description,
1924  const String & amount);
1925 
1944  bool ChargeCcYearly(UpnDbAuthHandle_t AuthHandle,
1945  UpnDbCcId_t cc,
1946  const String & partNumber,
1947  const String & description,
1948  const String & amount);
1949 
1960  unsigned int UrlViewed(UpnDbUpnId_t upnId,
1961  const String & urlVisited);
1962 
1971  unsigned int PointsTotal(UpnDbUpnId_t upnId);
1972 
1983  void SetSQL(SQL * sql,
1984  const char * Prefix = NULL);
1985 
1991  SQL * GetSQL() const {
1992  return(_Sql);
1993  };
1994 
2012  bool Connect(const String & host,
2013  const String & dbName,
2014  const String & dbUser,
2015  const String & dbPassword,
2016  const String & sqlinterface);
2017 
2035  bool Connect(const char * host,
2036  const char * dbName,
2037  const char * dbUser,
2038  const char * dbPassword,
2039  const char * sqlinterface = NULL);
2040 
2046  void Disconnect();
2047 
2053  void SetLDAP(/*LDAP * ldap*/);
2054 
2063  unsigned int GetErrorCode() const;
2064 
2072  void GetErrorMessage(String & Results) const;
2073 
2090  bool GetRealmRecord(UpnDbAuthHandle_t AuthHandle,
2091  UpnDbRealmRecord & Results,
2092  UpnDbRealmId_t AuthRealmId,
2093  const String & Realm) const;
2094 
2095 
2140  bool UpdateRealm(UpnDbAuthHandle_t AuthHandle,
2141  UpnDbRealmRecord & Rec);
2142 
2158  bool GetRealmRecord(UpnDbAuthHandle_t AuthHandle,
2159  UpnDbRealmId_t RealmToFind,
2160  UpnDbRealmRecord & Results);
2161 
2182  bool GetSpoken(UpnDbAuthHandle_t AuthHandle,
2183  UpnDbUpnId_t upnId,
2184  String & FileName,
2185  String & MimeType,
2186  String & Extension) const;
2187 
2205  bool SetSpoken(UpnDbAuthHandle_t AuthHandle,
2206  UpnDbUpnId_t upnId,
2207  String & FileName,
2208  String & MimeType,
2209  String & Extension);
2210 
2247  UpnDbPrefId_t AddPref(UpnDbAuthHandle_t AppAuth,
2248  UpnDbAuthHandle_t UpnAuth,
2249  const char * PrefKey,
2250  UpnDbPrefValueTypeId_t PrefType,
2251  const char * PrefValue,
2252  unsigned int Index = 0);
2253 
2278  bool GetPref(UpnDbAuthHandle_t AppAuth,
2279  UpnDbAuthHandle_t UpnAuth,
2280  char * & Results,
2281  const char * Key,
2282  UpnDbPrefValueTypeId_t & PrefType,
2283  unsigned int Index) const;
2284 
2302  UpnDbPrefId_t GetPrefId(UpnDbAuthHandle_t AppAuth,
2303  UpnDbAuthHandle_t UpnAuth,
2304  const char * Key,
2305  unsigned int Index) const;
2306 
2324  bool UpdatePref(UpnDbAuthHandle_t AppAuth,
2325  UpnDbAuthHandle_t UpnAuth,
2326  UpnDbPrefId_t PrefId,
2327  const char * PrefValue);
2328 
2344  bool RemovePref(UpnDbAuthHandle_t AppAuth,
2345  UpnDbAuthHandle_t UpnAuth,
2346  UpnDbPrefId_t prefId);
2347 
2348 
2358  static UpnDB * GetUpnDb(UpnDbAuthHandle_t AuthHandle);
2359 
2381  bool GetLicense(UpnDbAuthHandle_t AuthHandle,
2382  String & Results,
2383  UpnDbRealmId_t authRealmId,
2384  const String & licenseType,
2385  const String & requestCode) const;
2410  UpnDbLicenseId_t GetLicenseInfo(UpnDbAuthHandle_t AuthHandle,
2411  UpnDbRealmId_t authRealmId,
2412  UpnDbUpnId_t upnId,
2413  const String & requestCode,
2414  const String & licenseKey,
2415  const String & product,
2416  const String & version,
2417  bool & emailSent) const;
2418 
2443  UpnDbLicenseId_t SaveLicenseInfo(UpnDbAuthHandle_t AuthHandle,
2444  UpnDbRealmId_t authRealmId,
2445  UpnDbUpnId_t upnId,
2446  const String & requestCode,
2447  const String & licenseKey,
2448  const String & product,
2449  const String & version,
2450  bool emailSent);
2451 
2460  void SetError(SQL * Sql,
2461  SQL::SqlQueryId_t qId = 0) const;
2462 
2471  void SetError(unsigned int code, const char * msg) const;
2472 
2482  bool ValidAuthHandle(UpnDbAuthHandle_t AuthHandle) const;
2483 
2491  UpnDbUpnId_t GetUpnId(UpnDbAuthHandle_t Handle) const;
2492 
2493  protected:
2494 
2503  UpnDbRealmId_t _GetCcRealm(UpnDbCcId_t id) const;
2504 
2513  UpnDbUpnId_t _GetCcUpn(UpnDbCcId_t id) const;
2514 
2519 
2523  bool _OurSql;
2524 
2528  const char * _Prefix; // In StringCache.
2529 
2533  static const char * _GUID;
2534 
2535  // If not ZERO, the id of an already authenticated UPN and
2536  // the matching realm.
2537  //
2541  UpnDbUpnId_t _Upn;
2542 
2546  UpnDbRealmId_t _Realm;
2547 
2551  mutable unsigned int _ErrorCode;
2552 
2556  mutable const char * _ErrorMessage;
2557 
2558  private:
2559 
2560 #ifdef USE_POSTGRES
2561 
2647  static bool
2648  _CreateSqlDatabasePg(const char * DatabaseHost,
2649  const char * DatabaseName,
2650  const char * DatabaseUserName,
2651  const char * DatabaseUserPassword,
2652  unsigned short DatabasePort,
2653  const char * DatabaseUpnDbPrefix,
2654  const char * RuntimeUsername,
2655  const char * RuntimePassword,
2656  const char * DatabaseType,
2657  const char * InitFile,
2658  String & ErrorMessages);
2659 
2692  static bool
2693  _CreateSqlDatabasePg(const char * DatabaseName,
2694  const char * DatabaseUpnDbPrefix,
2695  const char * RuntimeUsername,
2696  const char * RuntimePassword,
2697  std::vector<String*> & Results);
2698 
2699 #endif // USE_POSTGRES
2700 
2701 #ifdef USE_MYSQL
2702 
2789  static bool
2790  _CreateSqlDatabaseMySql(const char * DatabaseHost,
2791  const char * DatabaseName,
2792  const char * DatabaseUserName,
2793  const char * DatabaseUserPassword,
2794  unsigned short DatabasePort,
2795  const char * DatabaseUpnDbPrefix,
2796  const char * RuntimeUsername,
2797  const char * RuntimePassword,
2798  const char * DatabaseType,
2799  const char * InitFile,
2800  String & ErrorMessages);
2801 
2835  static bool
2836  _CreateSqlDatabaseMySql(const char * DatabaseName,
2837  const char * DatabaseUpnDbPrefix,
2838  const char * RuntimeUsername,
2839  const char * RuntimePassword,
2840  std::vector<String*> & Results);
2841 
2842 #endif // USE_MYSQL
2843 
2862  UpnDbAuthHandle_t _Authenticate(UpnDbRealmId_t realm,
2863  const String & upn,
2864  const String & pw);
2865 
2871  enum _emailValid_t {
2872  \
2874  unknown_t = 0,
2875 
2877  isValid_t,
2878 
2880  isInValid_t
2881  };
2882 
2894  bool _EmailValid(UpnDbEmailId_t emailId,
2895  unsigned int code);
2896 
2899  mutable int _InTransaction;
2900 
2903  mutable UpnDbUpnId_t _LastAuthenticatedUpnId;
2904 
2907  mutable UpnDbRealmId_t _LastAuthenticatedRealmId;
2908 
2911  mutable bool _LastAuthenticatedUpnIsRealmAdmin;
2912 
2915  mutable bool _LastAuthenticatedUpnIsSiteAdmin;
2916 
2919  mutable const char * _LastAuthenticatedUpn;
2920 
2923  mutable const char * _LastAuthenticatedPw;
2924 
2928  mutable const char * _MxHostToUse; // StringCache
2929 
2930  };
2931 
2932  }
2933  }
2934 }
2935 
2936 #endif // DOUGLAS_MARK_ROYER_LIBPCUSERDB_UPNDB_HPP__
A class to order by name - case insensitive.
Definition: UpnDB.hpp:148
An object that contains a realm and all sub realms, in an ordered tree.
Definition: UpnDB.hpp:180
Registration of application and library identifiers.
Definition: Guid.hpp:83
The SQL class is a pure virtual interface class for SQL access.
Definition: SQL.hpp:128
SQL * _Sql
The SQL handle to the database being used.
Definition: UpnDB.hpp:2518
bool _OurSql
If we allocated the _sql variable this will be TRUE.
Definition: UpnDB.hpp:2523
UPN (user) database objects.
Definition: UpnDB.hpp:168
static const char * _GUID
The GUID for the currently authenticated application.
Definition: UpnDB.hpp:2533
const char * _Prefix
The database object prefix to use for all SQL objects.
Definition: UpnDB.hpp:2528
Instance counting and tracking.
Definition: instance.hpp:90
SQL * GetSQL() const
Get the associated SQL handle.
Definition: UpnDB.hpp:1991
This is a class that allows:
Definition: String.hpp:114
UpnDbRealmId_t _Realm
REALM ID of the last authenticated UPN.
Definition: UpnDB.hpp:2546
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
UpnDbUpnId_t _Upn
ID of the last authenticated UPN.
Definition: UpnDB.hpp:2541
An opaque object that separates the authentication implementation details from calling applications...
const char * _ErrorMessage
The last error message.
Definition: UpnDB.hpp:2556
unsigned int _ErrorCode
The last error code.
Definition: UpnDB.hpp:2551