| .. | .. |
|---|
| 1 | +package net.curisit.securis; |
|---|
| 2 | + |
|---|
| 3 | +import java.util.Date; |
|---|
| 4 | +import java.util.HashMap; |
|---|
| 5 | +import java.util.Map; |
|---|
| 6 | + |
|---|
| 7 | +import net.curisit.securis.beans.LicenseBean; |
|---|
| 8 | +import net.curisit.securis.beans.RequestBean; |
|---|
| 9 | +import net.curisit.securis.beans.SignedLicenseBean; |
|---|
| 10 | +import net.curisit.securis.utils.JsonUtils; |
|---|
| 11 | + |
|---|
| 12 | +public class FreeLicenseGenerator { |
|---|
| 13 | + |
|---|
| 14 | + public static final String FREE_LICENSE_TYPE = "FREE"; |
|---|
| 15 | + |
|---|
| 16 | + public static SignedLicenseBean generateLicense(String appName, String licCode, Map<String, Object> metadata) throws SeCurisException { |
|---|
| 17 | + SignedLicenseBean sl = null; |
|---|
| 18 | + RequestBean rb = new RequestBean(); |
|---|
| 19 | + rb.setLicenseTypeCode(FREE_LICENSE_TYPE); |
|---|
| 20 | + LicenseGenerator licenseGenerator = LicenseGenerator.getInstance(); |
|---|
| 21 | + |
|---|
| 22 | + LicenseBean lb = licenseGenerator.generateLicense(rb, metadata, new Date(-1), licCode, appName); |
|---|
| 23 | + sl = new SignedLicenseBean(lb); |
|---|
| 24 | + return sl; |
|---|
| 25 | + } |
|---|
| 26 | + |
|---|
| 27 | + public static void main(String[] args) throws SeCurisException { |
|---|
| 28 | + Map<String, Object> metadata = new HashMap<>(); |
|---|
| 29 | + metadata.put("max_docs", 200); |
|---|
| 30 | + metadata.put("max_size", 1024*1024*1024); |
|---|
| 31 | + SignedLicenseBean lic = generateLicense("Doxr", "DOXR-FREE-01", metadata); |
|---|
| 32 | + |
|---|
| 33 | + System.out.println(JsonUtils.toPrettyJSON(lic)); |
|---|
| 34 | + } |
|---|
| 35 | +} |
|---|