blob: 7ab0e02912968baaad0d3ecde61e104dca95703f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<%
/*
* Copyright (C) Rafal Szczesniak 2007
*/
/* JSON-RPC mappings to the libnet functions */
jsonrpc_include("resources.esp");
function _NetContext(params, error)
{
if (params.length < 1)
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"too few parameters(usage: [ <credentials ])");
return error;
}
var creds = params[0];
if (creds == undefined)
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"credentials parameter is undefined");
return error;
}
if (creds.domain == undefined ||
typeof(creds.domain) != "string")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"a valid string is expected in credentials.domain");
return error;
}
if (creds.username == undefined ||
typeof(creds.username) != "string")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"a valid string is expected in credentials.username");
return error;
}
if (creds.password == undefined ||
typeof(creds.username) != "string")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"a valid string is expected in credentials.password");
return error;
}
var credentials = credentials_init();
credentials.set_domain(creds.domain);
credentials.set_username(creds.username);
credentials.set_password(creds.password);
var netCtx = NetContext(credentials);
return session.resources.set(netCtx, "netCtx", error);
}
jsonrpc.method.NetContext = _NetContext;
/*
* Local Variables:
* mode: c
* End:
*/
%>
|