security_credentials.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SECURITY_CREDENTIALS_H
  2. #define SECURITY_CREDENTIALS_H
  3. #include <node.h>
  4. #include <node_object_wrap.h>
  5. #include <v8.h>
  6. #define SECURITY_WIN32 1
  7. #include <WinSock2.h>
  8. #include <windows.h>
  9. #include <sspi.h>
  10. #include <tchar.h>
  11. #include <nan.h>
  12. #include "../worker.h"
  13. #include <uv.h>
  14. extern "C" {
  15. #include "../kerberos_sspi.h"
  16. }
  17. // SEC_WINNT_AUTH_IDENTITY makes it unusually hard
  18. // to compile for both Unicode and ansi, so I use this macro:
  19. #ifdef _UNICODE
  20. #define USTR(str) (str)
  21. #else
  22. #define USTR(str) ((unsigned char*)(str))
  23. #endif
  24. using namespace v8;
  25. using namespace node;
  26. class SecurityCredentials : public Nan::ObjectWrap {
  27. public:
  28. SecurityCredentials();
  29. ~SecurityCredentials();
  30. // Pointer to context object
  31. SEC_WINNT_AUTH_IDENTITY m_Identity;
  32. // credentials
  33. CredHandle m_Credentials;
  34. // Expiry time for ticket
  35. TimeStamp Expiration;
  36. // Has instance check
  37. static inline bool HasInstance(Local<Value> val) {
  38. if (!val->IsObject()) return false;
  39. Local<Object> obj = val->ToObject();
  40. return Nan::New(constructor_template)->HasInstance(obj);
  41. };
  42. // Functions available from V8
  43. static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
  44. static NAN_METHOD(Acquire);
  45. // Constructor used for creating new Long objects from C++
  46. static Nan::Persistent<FunctionTemplate> constructor_template;
  47. private:
  48. // Create a new instance
  49. static NAN_METHOD(New);
  50. // Handles the uv calls
  51. static void Process(uv_work_t* work_req);
  52. // Called after work is done
  53. static void After(uv_work_t* work_req);
  54. };
  55. #endif