blob: 15b6b9b907b7c6e644bf087ea2025b8236e4487a (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<%
/*
* Copyright (C) Rafal Szczesniak 2007
*/
/* JSON-RPC mappings to the libnet functions */
jsonrpc_include("resources.esp");
function _NetContext(params, error)
{
var credParams, credentials;
var resName;
if (params.length < 1)
{
/* create default NetContext based on already provided credentials */
credentials = session.authinfo.credentials;
resName = "netCtx";
}
else
{
/* create user specified credentials object */
credParams = params[0];
if (typeof(credParams) != "object")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"credentials parameter is expected to be an object");
return error;
}
if (typeof(credParams.domain) != "string")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"a valid string is expected in credentials.domain");
return error;
}
if (typeof(credParams.username) != "string")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"a valid string is expected in credentials.username");
return error;
}
if (typeof(credParams.username) != "string")
{
error.setError(jsonrpc.Constant.ServerError.ParameterMismatch,
"a valid string is expected in credentials.password");
return error;
}
credentials = credentials_init();
credentials.set_domain(credParams.domain);
credentials.set_username(credParams.username);
credentials.set_password(credParams.password);
resName = "netCtx[" + credParams.domain + "/" + credParams.username + "]";
}
/* was this NetContext created yet ? */
var resId = session.resources.find(key, error);
if (resId != undefined)
{
/* yes, return its resource id */
return resId;
}
/* no, create the new context and assign it a resource id */
var netCtx = NetContext(credentials);
resId = session.resources.set(netCtx, resName, error);
return resId;
}
jsonrpc.method.NetContext = _NetContext;
/*
* Local Variables:
* mode: c
* End:
*/
%>
|