Remote API through HTTP
You may want to create operators from your own site and update NxCloud DB automatically. You can build your own API set for
dealing with your operators remotely using DAO and Data classes of NxCloud.
For more information about DAO and Data classes, read DAO and Data classes
Example API set
We have an example API set in /nxfilter/webapps/example/remoteapi.jsp. You can call this JSP page remotely through HTTP protocol.
In the JSP page, there are these actions are defined,
- createOperator
You can create an operator with this action. It takes 2 parameters.
One is 'opName' for an operator name. The other one is 'opType' for the type of the operator you want to create,
set 1 for an business type operator and set 2 for an home type operator. On success, it returns '/OK' and on error, it returns '/ERR'.
ex) http://localhost/example/remoteapi.jsp?action=createOperator&opName=testname&opType=1
- selectOperator
You can fetch an operator's information with this action. It takes 'opName' parameter for an operator name.
On success, it returns a JSON array containing the information of the operator.
On error, it returns '/ERR'.
ex) http://localhost/example/remoteapi.jsp?action=selectOperator&opName=testname
- setExpDate
This is for setting an expiration date for an operator. It takes 2 parameters.
One is 'opName' for an operator name. The other one is 'expDate' that is an 'yyyyMMdd' format string for the expiration
date you want to set for filtering service. On success, it returns '/OK' and on error, it returns '/ERR'.
ex) http://localhost/example/remoteapi.jsp?action=setExpDate&opName=testname&expDate=20191231
At default, the example JSP page only accepts the calls from 127.0.0.1 or localhost. You have to modify the restriction part of the JPS page to accept the requests from other hosts.
// Only localhost access allowed.
if(!request.getRemoteAddr().startsWith("127.0.0.1")){
out.println(request.getRemoteAddr());
return;
}
To make these remote API functions, we only used NxFilter DAO and Data classes. So it's possible for you to build even more complicated ones.
You can have an IP based ACL for your JSP pages by 'System > Allowed IP > Allowed IP To GUI'.