2
2
3
3
Nan::Persistent<v8::Function> KerberosClientContext::constructor;
4
4
NAN_MODULE_INIT (KerberosClientContext::Init) {
5
- v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New );
5
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>();
6
6
tpl->SetClassName (Nan::New (" KerberosClientContext" ).ToLocalChecked ());
7
7
8
8
v8::Local<v8::ObjectTemplate> itpl = tpl->InstanceTemplate ();
@@ -16,6 +16,15 @@ NAN_MODULE_INIT(KerberosClientContext::Init) {
16
16
Nan::Set (target, Nan::New (" KerberosClientContext" ).ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ());
17
17
}
18
18
19
+ v8::Local<v8::Object> KerberosClientContext::NewInstance (gss_client_state* state) {
20
+ Nan::EscapableHandleScope scope;
21
+ v8::Local<v8::Function> ctor = Nan::New<v8::Function>(KerberosClientContext::constructor);
22
+ v8::Local<v8::Object> object = Nan::NewInstance (ctor).ToLocalChecked ();
23
+ KerberosClientContext *class_instance = new KerberosClientContext (state);
24
+ class_instance->Wrap (object);
25
+ return scope.Escape (object);
26
+ }
27
+
19
28
KerberosClientContext::KerberosClientContext (gss_client_state* state)
20
29
: _state(state)
21
30
{}
@@ -29,39 +38,52 @@ NAN_GETTER(KerberosClientContext::UserNameGetter) {
29
38
KerberosClientContext* context =
30
39
Nan::ObjectWrap::Unwrap<KerberosClientContext>(info.Holder ());
31
40
32
- info.GetReturnValue ().Set (Nan::New (context->_state ->username ).ToLocalChecked ());
41
+ (context->_state ->username == NULL ) ?
42
+ info.GetReturnValue ().Set (Nan::Null ()) :
43
+ info.GetReturnValue ().Set (Nan::New (context->_state ->username ).ToLocalChecked ());
33
44
}
34
45
35
46
NAN_GETTER (KerberosClientContext::ResponseGetter) {
36
47
KerberosClientContext* context =
37
48
Nan::ObjectWrap::Unwrap<KerberosClientContext>(info.Holder ());
38
49
39
- info.GetReturnValue ().Set (Nan::New (context->_state ->response ).ToLocalChecked ());
50
+ (context->_state ->response == NULL ) ?
51
+ info.GetReturnValue ().Set (Nan::Null ()) :
52
+ info.GetReturnValue ().Set (Nan::New (context->_state ->response ).ToLocalChecked ());
40
53
}
41
54
42
55
NAN_GETTER (KerberosClientContext::ResponseConfGetter) {
43
56
KerberosClientContext* context =
44
57
Nan::ObjectWrap::Unwrap<KerberosClientContext>(info.Holder ());
45
58
46
- info.GetReturnValue ().Set (Nan::New (context->_state ->responseConf ). ToLocalChecked () );
59
+ info.GetReturnValue ().Set (Nan::New (context->_state ->responseConf ));
47
60
}
48
61
49
62
Nan::Persistent<v8::Function> KerberosServerContext::constructor;
50
- NAN_MODULE_INIT (KerberosClientContext ::Init) {
51
- v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New );
63
+ NAN_MODULE_INIT (KerberosServerContext ::Init) {
64
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>();
52
65
tpl->SetClassName (Nan::New (" KerberosServerContext" ).ToLocalChecked ());
53
66
54
67
v8::Local<v8::ObjectTemplate> itpl = tpl->InstanceTemplate ();
55
68
itpl->SetInternalFieldCount (1 );
56
69
57
70
Nan::SetAccessor (itpl, Nan::New (" username" ).ToLocalChecked (), KerberosServerContext::UserNameGetter);
58
71
Nan::SetAccessor (itpl, Nan::New (" response" ).ToLocalChecked (), KerberosServerContext::ResponseGetter);
59
- Nan::SetAccessor (itpl, Nan::New (" targetName" ).ToLocalChecked (), KerberosServerContext::ResponseConfGetter );
72
+ Nan::SetAccessor (itpl, Nan::New (" targetName" ).ToLocalChecked (), KerberosServerContext::TargetNameGetter );
60
73
61
74
constructor.Reset (Nan::GetFunction (tpl).ToLocalChecked ());
62
75
Nan::Set (target, Nan::New (" KerberosServerContext" ).ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ());
63
76
}
64
77
78
+ v8::Local<v8::Object> KerberosServerContext::NewInstance (gss_server_state* state) {
79
+ Nan::EscapableHandleScope scope;
80
+ v8::Local<v8::Function> ctor = Nan::New<v8::Function>(KerberosServerContext::constructor);
81
+ v8::Local<v8::Object> object = Nan::NewInstance (ctor).ToLocalChecked ();
82
+ KerberosServerContext *class_instance = new KerberosServerContext (state);
83
+ class_instance->Wrap (object);
84
+ return scope.Escape (object);
85
+ }
86
+
65
87
KerberosServerContext::KerberosServerContext (gss_server_state* state)
66
88
: _state(state)
67
89
{}
@@ -75,19 +97,25 @@ NAN_GETTER(KerberosServerContext::UserNameGetter) {
75
97
KerberosServerContext* context =
76
98
Nan::ObjectWrap::Unwrap<KerberosServerContext>(info.Holder ());
77
99
78
- info.GetReturnValue ().Set (Nan::New (context->_state ->username ).ToLocalChecked ());
100
+ (context->_state ->username == NULL ) ?
101
+ info.GetReturnValue ().Set (Nan::Null ()) :
102
+ info.GetReturnValue ().Set (Nan::New (context->_state ->username ).ToLocalChecked ());
79
103
}
80
104
81
105
NAN_GETTER (KerberosServerContext::ResponseGetter) {
82
106
KerberosServerContext* context =
83
107
Nan::ObjectWrap::Unwrap<KerberosServerContext>(info.Holder ());
84
108
85
- info.GetReturnValue ().Set (Nan::New (context->_state ->response ).ToLocalChecked ());
109
+ (context->_state ->response == NULL ) ?
110
+ info.GetReturnValue ().Set (Nan::Null ()) :
111
+ info.GetReturnValue ().Set (Nan::New (context->_state ->response ).ToLocalChecked ());
86
112
}
87
113
88
- NAN_GETTER (KerberosServerContext::ResponseConfGetter ) {
114
+ NAN_GETTER (KerberosServerContext::TargetNameGetter ) {
89
115
KerberosServerContext* context =
90
116
Nan::ObjectWrap::Unwrap<KerberosServerContext>(info.Holder ());
91
117
92
- info.GetReturnValue ().Set (Nan::New (context->_state ->responseConf ).ToLocalChecked ());
118
+ (context->_state ->targetname == NULL ) ?
119
+ info.GetReturnValue ().Set (Nan::Null ()) :
120
+ info.GetReturnValue ().Set (Nan::New (context->_state ->targetname ).ToLocalChecked ());
93
121
}
0 commit comments