kerberos.cc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "kerberos.h"
  2. #include <stdlib.h>
  3. #include <tchar.h>
  4. #include "base64.h"
  5. #include "wrappers/security_buffer.h"
  6. #include "wrappers/security_buffer_descriptor.h"
  7. #include "wrappers/security_context.h"
  8. #include "wrappers/security_credentials.h"
  9. Nan::Persistent<FunctionTemplate> Kerberos::constructor_template;
  10. Kerberos::Kerberos() : Nan::ObjectWrap() {
  11. }
  12. void Kerberos::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
  13. // Grab the scope of the call from Node
  14. Nan::HandleScope scope;
  15. // Define a new function template
  16. Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
  17. t->InstanceTemplate()->SetInternalFieldCount(1);
  18. t->SetClassName(Nan::New<String>("Kerberos").ToLocalChecked());
  19. // Set persistent
  20. constructor_template.Reset(t);
  21. // Set the symbol
  22. Nan::Set(target, Nan::New<String>("Kerberos").ToLocalChecked(), t->GetFunction());
  23. }
  24. NAN_METHOD(Kerberos::New) {
  25. // Load the security.dll library
  26. load_library();
  27. // Create a Kerberos instance
  28. Kerberos *kerberos = new Kerberos();
  29. // Return the kerberos object
  30. kerberos->Wrap(info.This());
  31. // Return the object
  32. info.GetReturnValue().Set(info.This());
  33. }
  34. // Exporting function
  35. NAN_MODULE_INIT(init) {
  36. Kerberos::Initialize(target);
  37. SecurityContext::Initialize(target);
  38. SecurityBuffer::Initialize(target);
  39. SecurityBufferDescriptor::Initialize(target);
  40. SecurityCredentials::Initialize(target);
  41. }
  42. NODE_MODULE(kerberos, init);