NSDP Unlike CMCC, NSDP is a lightweight portal Server solution. The portal server is completely a standard Web server. Therefore, this example program uses PHP to demonstrate. The following is the source of index.php, the entire portal only two files, one is the first page of PHP, one is to support the asynchronous submission of the JS code. Two files are in the attachment.
<! DOCTYPE html>
<TITLE>NSDPProtocol Presentation portal Page </title>
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>
<script src= "Jquery-1.7.2.js" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (' #go '). Click (function () {
var name=$ (' #username '). Val ();
varpwd=$ (' #userpasswd '). Val ();
var search =location.search;
if (Search.indexof ("?")!=-1) {
var query = search.substring (Search.indexof ("?") +1);
var datas=query+ "&" + "Username=" + name + "&" + "userpasswd=" + pwd;
} else{
var datas= "Username=" + name + "&" + "userpasswd=" + pwd;
}
$.ajax ({
Type: "POST",
URL: "http://<?php echo $_get[' Wlanapip '];? >:14150/action/auth ",
Data:datas,
DataType: "JSON",
Success:function (msg) {
Alert (msg);
var code = Msg.code;
Code = CODE*1;
Switch (code) {
Case 0:
msg = "Successful authentication";
Case 1:
msg = "User name or password error";
Case 2:
msg = "Authentication timeout";
Case 3:
msg = "User is in Authentication";
CASE4:
msg = "User authenticated";
Default:
msg = "Unknown return code!" "; break;
}
Alert (msg);
}
});
});
});
</script>
<body>
<div style= "width:100px;margin-left:35%;margin-right:auto;margin-top:15%" >
<fieldset border:2pxstyle= "Width:300px;hight:auto;border-color: #0000CD" >
<legend> User Login </legend>
Account No. <input type= "text" id= "username" name= "username" maxlength= "18" Autofocus Required/> <br/>
Secret code <input type= "password" id= "userpasswd" name= "userpasswd" maxlength= " "Required style=" margin-top:5px "/> <br/>
<button type= "button" id= "Go" style= "width:60px;hight:30px;margin-top:10px;margin-left:150px;" > & amp;nbsp, recording </button>
</fieldset>
</div>
</body>
As you can see, NSDP simplifies to only one page, and the functionality is not weak. After the client submits the request, the distributed AP Authentication Frontend Returns a JSON, in the following format:
{
"Ver": "string",
" Sessid": "Int32 " ,
"Code": "Int32",
"MSG": "String",
"Username": [
{"User-name": "string"},// User name
{"Session-timeout": "u_int32_t"},// remaining online duration
{"Framed-ip-address": "string"},
{"Nas-ip-address": "String"},
......
}
Code Field Description:
Code = 0 , which means the authentication succeeds and carries the username attribute.
Code = 1 , which indicates that the user name or password is incorrect;
Code = 2 , which indicates the authentication timeout;
Code = 3 , indicating that the user is in the authentication;
Code = 4 , indicating that the user has been authenticated;
In HTTP authentication, if the HTTP authentication server has an exception (the return code is not 200), the Code field returns an HTTP return code.
This "cross-domain Commit" mode also lays a good foundation for app support. The app can initiate authentication directly to the AP! This greatly simplifies the process of app authentication.
NSDP Protocol Portal Server source code file please download in Ossh forum.
Key words: NSDP, Ossh
NSDP Protocol Portal Server source code