auth.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "api_auth.h"
  2. #include <api/service/services.h>
  3. #include "../nu/PtrMap.h"
  4. #include "XMLString.h"
  5. #include "../xml/obj_xml.h"
  6. class OpenAuthParser
  7. {
  8. public:
  9. void RegisterCallbacks(obj_xml *parser);
  10. void UnregisterCallbacks(obj_xml *parser);
  11. XMLString statusCode, statusText, statusDetailCode;
  12. XMLString token;
  13. XMLString expire;
  14. XMLString session_secret;
  15. XMLString context;
  16. };
  17. class Auth : public api_auth
  18. {
  19. public:
  20. static const char *getServiceName() { return "Authorization API"; }
  21. static FOURCC getServiceType() { return WaSvc::UNIQUE; }
  22. void Init();
  23. void Quit();
  24. Auth();
  25. int Login(const wchar_t *username, const wchar_t *password, AuthResults *results, ifc_authcallback *callback);
  26. int LoginSecurID(const wchar_t *username, const wchar_t *password, const char *context, const wchar_t *securid, AuthResults *results, ifc_authcallback *callback);
  27. const char *GetDevID();
  28. int SetCredentials(GUID realm, const char *session_key, const char *token, const wchar_t *username, __time64_t expire);
  29. int GetCredentials(GUID realm, char *session_key, size_t session_key_len, char *token, size_t token_len, wchar_t *username, size_t username_len, __time64_t *expire);
  30. int ClientToWeb(GUID realm, const wchar_t *destination_url, wchar_t *url, size_t urlcch);
  31. HWND CreateLoginWindow(GUID realm, HWND owner, UINT style);
  32. INT_PTR LoginBox(GUID realm, HWND owner, UINT style);
  33. int GetUserName(GUID realm, wchar_t *username, size_t username_len);
  34. private:
  35. static int SetupLogin(OpenAuthParser &authParser, waServiceFactory *&parserFactory, obj_xml *&parser);
  36. static int ParseAuth(const wchar_t *password, OpenAuthParser &authParser, AuthResults *results);
  37. char *inifile;
  38. protected:
  39. RECVS_DISPATCH;
  40. };