| .. | .. |
|---|
| 13 | 13 | import java.security.spec.InvalidKeySpecException; |
|---|
| 14 | 14 | import java.util.Date; |
|---|
| 15 | 15 | import java.util.Map; |
|---|
| 16 | | -import java.util.TreeMap; |
|---|
| 17 | 16 | |
|---|
| 18 | 17 | import net.curisit.securis.beans.LicenseBean; |
|---|
| 19 | 18 | import net.curisit.securis.beans.RequestBean; |
|---|
| .. | .. |
|---|
| 46 | 45 | /** |
|---|
| 47 | 46 | * Generate a license bean with the specified data |
|---|
| 48 | 47 | * |
|---|
| 49 | | - * @param hw |
|---|
| 50 | | - * @param customerCode |
|---|
| 51 | | - * - e.g: "BP" |
|---|
| 52 | | - * @param maxInstances |
|---|
| 53 | | - * @param maxUsers |
|---|
| 54 | | - * @param maxTimeThreshold |
|---|
| 55 | | - * Max time between synchronizations expressed in days |
|---|
| 48 | + * @param req |
|---|
| 49 | + * @param licCode |
|---|
| 50 | + * @param metadata |
|---|
| 51 | + * @param expirationDate |
|---|
| 52 | + * @param licenseCode |
|---|
| 53 | + * @param appName |
|---|
| 56 | 54 | * @return |
|---|
| 57 | 55 | * @throws SeCurisException |
|---|
| 58 | 56 | */ |
|---|
| .. | .. |
|---|
| 61 | 59 | LOG.debug("Generating license: MAC: {}, Customer code: {}, AppName: {}", req.getMacAddresses(), req.getCustomerCode(), appName); |
|---|
| 62 | 60 | LicenseBean license = new LicenseBean(req); |
|---|
| 63 | 61 | license.setAppName(appName); |
|---|
| 62 | + license.setLicenseCode(licenseCode); |
|---|
| 64 | 63 | license.setExpirationDate(expirationDate); |
|---|
| 65 | 64 | license.setMetadata(metadata); |
|---|
| 66 | 65 | sign(license); |
|---|
| .. | .. |
|---|
| 131 | 130 | throw new SeCurisException("License could not be generated"); |
|---|
| 132 | 131 | } |
|---|
| 133 | 132 | |
|---|
| 134 | | - public static void main(String[] args) throws SeCurisException { |
|---|
| 135 | | - |
|---|
| 136 | | - RequestBean req = ReqGenerator.getInstance().loadRequest(new File("/Users/cproberto/Documents/wsCurisIT/SeCurisClient/license.req")); |
|---|
| 137 | | - Map<String, Object> metadata = new TreeMap<>(); |
|---|
| 138 | | - // CurisData parameters: |
|---|
| 139 | | - // metadata.put("maxUsers", 5); |
|---|
| 140 | | - // metadata.put("maxSessionUsers", 100); |
|---|
| 141 | | - // curisIntegrity |
|---|
| 142 | | - metadata.put("maxUsers", 0); |
|---|
| 143 | | - metadata.put("maxInstances", 0); |
|---|
| 144 | | - metadata.put("timeThreshold", 0); |
|---|
| 145 | | - metadata.put("datasetPrefix", "BP"); |
|---|
| 146 | | - metadata.put("extendedMode", true); |
|---|
| 147 | | - |
|---|
| 148 | | - Date expirationDate = new Date(new Date().getTime() + (1000L * 3600 * 24 * 365 * 10)); |
|---|
| 149 | | - LicenseBean lic = LicenseGenerator.getInstance().generateLicense(req, metadata, expirationDate, "CI-01", "LIC-CURISTEC-0001"); |
|---|
| 150 | | - LicenseGenerator.getInstance().save(lic, new File("/Users/cproberto/Desktop/AxelLicCI.lic")); |
|---|
| 151 | | - |
|---|
| 152 | | - System.out.print("License expires at: " + expirationDate.getTime()); |
|---|
| 153 | | - |
|---|
| 154 | | - } |
|---|
| 155 | 133 | } |
|---|