kerberos_context.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef KERBEROS_CONTEXT_H
  2. #define KERBEROS_CONTEXT_H
  3. #include <node.h>
  4. #include <gssapi/gssapi.h>
  5. #include <gssapi/gssapi_generic.h>
  6. #include <gssapi/gssapi_krb5.h>
  7. #include "nan.h"
  8. #include <node_object_wrap.h>
  9. #include <v8.h>
  10. extern "C" {
  11. #include "kerberosgss.h"
  12. }
  13. using namespace v8;
  14. using namespace node;
  15. class KerberosContext : public Nan::ObjectWrap {
  16. public:
  17. KerberosContext();
  18. ~KerberosContext();
  19. static inline bool HasInstance(Local<Value> val) {
  20. if (!val->IsObject()) return false;
  21. Local<Object> obj = val->ToObject();
  22. return Nan::New(constructor_template)->HasInstance(obj);
  23. };
  24. inline bool IsClientInstance() {
  25. return state != NULL;
  26. }
  27. inline bool IsServerInstance() {
  28. return server_state != NULL;
  29. }
  30. // Constructor used for creating new Kerberos objects from C++
  31. static Nan::Persistent<FunctionTemplate> constructor_template;
  32. // Initialize function for the object
  33. static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
  34. // Public constructor
  35. static KerberosContext* New();
  36. // Handle to the kerberos client context
  37. gss_client_state *state;
  38. // Handle to the kerberos server context
  39. gss_server_state *server_state;
  40. private:
  41. static NAN_METHOD(New);
  42. // In either client state or server state
  43. static NAN_GETTER(ResponseGetter);
  44. static NAN_GETTER(UsernameGetter);
  45. // Only in the "server_state"
  46. static NAN_GETTER(TargetnameGetter);
  47. static NAN_GETTER(DelegatedCredentialsCacheGetter);
  48. };
  49. #endif