security_context.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef SECURITY_CONTEXT_H
  2. #define SECURITY_CONTEXT_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 "security_credentials.h"
  12. #include "../worker.h"
  13. #include <nan.h>
  14. extern "C" {
  15. #include "../kerberos_sspi.h"
  16. #include "../base64.h"
  17. }
  18. using namespace v8;
  19. using namespace node;
  20. class SecurityContext : public Nan::ObjectWrap {
  21. public:
  22. SecurityContext();
  23. ~SecurityContext();
  24. // Security info package
  25. PSecPkgInfo m_PkgInfo;
  26. // Do we have a context
  27. bool hasContext;
  28. // Reference to security credentials
  29. SecurityCredentials *security_credentials;
  30. // Security context
  31. CtxtHandle m_Context;
  32. // Attributes
  33. DWORD CtxtAttr;
  34. // Expiry time for ticket
  35. TimeStamp Expiration;
  36. // Payload
  37. char *payload;
  38. // Has instance check
  39. static inline bool HasInstance(Local<Value> val) {
  40. if (!val->IsObject()) return false;
  41. Local<Object> obj = val->ToObject();
  42. return Nan::New(constructor_template)->HasInstance(obj);
  43. };
  44. // Functions available from V8
  45. static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
  46. static NAN_METHOD(InitializeContext);
  47. static NAN_METHOD(InitalizeStep);
  48. static NAN_METHOD(DecryptMessage);
  49. static NAN_METHOD(QueryContextAttributes);
  50. static NAN_METHOD(EncryptMessage);
  51. // Payload getter
  52. static NAN_GETTER(PayloadGetter);
  53. // hasContext getter
  54. static NAN_GETTER(HasContextGetter);
  55. // Constructor used for creating new Long objects from C++
  56. static Nan::Persistent<FunctionTemplate> constructor_template;
  57. // private:
  58. // Create a new instance
  59. static NAN_METHOD(New);
  60. };
  61. #endif