License Registration
Overview
When you buy a commercial version of JSPrintManager you are provided with license information to register the product in your website. The license information you've received includes two values, the License Owner and License Key
There are two ways to setup the license info:
- On the same website that is using JSPrintManager.js file. To register JSPrintManager in your website or project, you must code a page or controller so the license information is returned by this URL: //ORIGIN/jspm where ORIGIN is the one displayed by localhost's origin entry for your website. Here's a sample from our online demo website:
In this case, the license info must be configured under https://jsprintmanager.azurewebsites.net/jspm
Note
Alternatively you could specify a different path to provide the license info but it must be located under the same ORIGIN. For example, based on the website sample, if we decided to return the license info from https://jsprintmanager.azurewebsites.net/licenses/jsprintmanager
, then you must specify it in the Javascript code as follows
JSPM.JSPrintManager.license_url = "https://jsprintmanager.azurewebsites.net/licenses/jsprintmanager";
- On an external sever/URL. License registration requires a web server-side language like PHP, .NET, Java, etc. so if the website that is using JSPrintManager.js does not allow you to use server-side code, then this option allows you to setup the license info on an external URL.
Important
This option requires a special License Owner format where the ORIGIN/DOMAIN (as described above) of the printing website must be specified. You must request this type of license to our sales team after placing an order by specifying the ORIGIN value.
The URL from where the license info must be returned must be specified in Javascript code to JSPM.JSPrintManager.license_url
as shown in the following snipped code:
JSPM.JSPrintManager.license_url = "https://external-server/whatever/get-jspm-license";
JSPM.JSPrintManager.auto_reconnect = true;
JSPM.JSPrintManager.start();
//... more code...
The specified license_url
must be coded in your preferred server-side language as shown in the below templates for most known web technologies languages.
Note
If you cannot create another website to return the license info, then Neodynamic offers you to host your license info at https://neodynamic.com which runs on MS Azure data centers at no extra costs. If this is an option for you, then please contact our Support Team
Template Code for most known Web Platforms
Refer to the following templates based on your Web Platform. If your dev platform is missing, please contact our Support Team
Note
Be aware that inside the following code you must specify the License Owner & License Key values you've received.
For Express.js / Node.js
- Create a new route handler and name it jspm.js; or edit the
license_url
file
Important
It's mandatory that the URL //your-website/jspm or the license_url must be set up to allow ANONYMOUS access
- Then copy/paste the following code:
var express = require('express');
var router = express.Router();
var sha256 = require('sha256');
var uuidv1 = require('uuid/v1');
router.get('/', function(req, res, next){
//SET THE LICENSE INFO
var licence_owner = "YOUR-LICENSE-OWNER-HERE";
var licence_key = "YOUR-LICNESE-KEY-HERE";
//DO NOT MODIFY THE FOLLOWING CODE
var uid = uuidv1();
var licence_hash = sha256(licence_key + uid);
var output = licence_owner + "|" + licence_hash + "|" + uid;
res.send(output);
});
module.exports = router;
For PHP
- Create a new file, name it index.php and place it under //your-website/jspm/; or edit the
license_url
file
Important
It's mandatory that the URL //your-website/jspm/index.php or the license_url must be set up to allow ANONYMOUS access
- Then copy/paste the following code:
<?php
//SET THE LICENSE INFO
$license_owner = 'YOUR-LICENSE-OWNER-HERE';
$license_key = 'YOUR-LICNESE-KEY-HERE';
//DO NOT MODIFY THE FOLLOWING CODE
$uid = uniqid();
$license_hash = hash('sha256', $license_key . $uid, false);
$resp = $license_owner . '|' . $license_hash . '|' . $uid;
ob_start();
ob_clean();
header('Content-type: text/plain');
echo $resp;
ob_end_flush();
exit();
For ASP.NET CORE
- Create a new Controller and name it JSPMController; or edit the
license_url
file
Important
It's mandatory that the URL //your-website/jspm or the license_url must be set up to allow ANONYMOUS access
- Then copy/paste the following code:
public class JSPMController : Controller
{
[AllowAnonymous]
public IActionResult Index()
{
//SET THE LICENSE INFO
string license_owner = "YOUR-LICENSE-OWNER-HERE";
string license_key = "YOUR-LICNESE-KEY-HERE";
//DO NOT MODIFY THE FOLLOWING CODE
string license_hash = "";
string uid = Guid.NewGuid().ToString();
using (System.Security.Cryptography.SHA256 sha256Hash = System.Security.Cryptography.SHA256.Create())
{
license_hash = BitConverter.ToString(sha256Hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(license_key + uid))).Replace("-","").ToLower();
}
return File(System.Text.Encoding.UTF8.GetBytes(license_owner + '|' + license_hash + '|' + uid), "text/plain");
}
}
For ASP.NET MVC
- Create a new Controller and name it JSPMController; or edit the
license_url
file
Important
It's mandatory that the URL //your-website/jspm or the license_url must be set up to allow ANONYMOUS access
- Then copy/paste the following code:
public class JSPMController : Controller
{
[AllowAnonymous]
public void Index()
{
//SET THE LICENSE INFO
string license_owner = "YOUR-LICENSE-OWNER-HERE";
string license_key = "YOUR-LICNESE-KEY-HERE";
//DO NOT MODIFY THE FOLLOWING CODE
string uid = Guid.NewGuid().ToString();
string license_hash = "";
using (System.Security.Cryptography.SHA256 sha256Hash = System.Security.Cryptography.SHA256.Create())
{
license_hash = BitConverter.ToString(sha256Hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(license_key + uid))).Replace("-","").ToLower();
}
System.Web.HttpContext.Current.Response.ContentType = "text/plain";
System.Web.HttpContext.Current.Response.Write(license_owner + '|' + license_hash + '|' + uid);
}
}
For ASP.NET WebForms
- Create a new file, name it default.aspx and place it under //your-website/jspm/; or edit the
license_url
file
Important
It's mandatory that the URL //your-website/jspm/default.aspx or the license_url must be set up to allow ANONYMOUS access
- Then copy/paste the following code:
protected void Page_Load(object sender, EventArgs e)
{
//SET THE LICENSE INFO
string license_owner = "YOUR-LICENSE-OWNER-HERE";
string license_key = "YOUR-LICNESE-KEY-HERE";
//DO NOT MODIFY THE FOLLOWING CODE
string uid = Guid.NewGuid().ToString();
string license_hash = "";
using (System.Security.Cryptography.SHA256 sha256Hash = System.Security.Cryptography.SHA256.Create())
{
license_hash = BitConverter.ToString(sha256Hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(license_key + uid))).Replace("-","").ToLower();
}
Response.ContentType = "text/plain";
Response.Write(license_owner + '|' + license_hash + '|' + uid);
}
For Java Servlet
- Create a new HttpServlet and name it jspm.java; or edit the
license_url
file
Important
It's mandatory that the URL //your-website/jspm or the license_url must be set up to allow ANONYMOUS access
- Then copy/paste the following code:
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// SET THE LICENSE INFO
String license_owner = "YOUR-LICENSE-OWNER-HERE";
String license_key = "YOUR-LICNESE-KEY-HERE";
// DO NOT MODIFY THE FOLLOWING CODE
String license_hash = "";
String uid = java.util.UUID.randomUUID().toString();
license_hash = sha256Hash(license_key + uid);
license_hash = license_hash.replace("-", "").toLowerCase();
response.setContentType("text/plain");
PrintWriter pw = response.getWriter();
pw.write(license_owner + "|" + license_hash + "|" + uid);
pw.close();
}
private static String sha256Hash(String value) {
try{
java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256");
md.update(value.getBytes());
return bytesToHex(md.digest());
} catch(Exception ex){
throw new RuntimeException(ex);
}
}
private static String bytesToHex(byte[] bytes) {
StringBuffer result = new StringBuffer();
for (byte b : bytes) result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
return result.toString();
}