1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
| | package net.curisit.securis.services;
| |
| | import java.io.IOException;
| | import java.util.Date;
| | import java.util.List;
| |
| | import jakarta.inject.Inject;
| | import jakarta.persistence.EntityManager;
| | import jakarta.persistence.NoResultException;
| | import jakarta.ws.rs.Consumes;
| | import jakarta.ws.rs.GET;
| | import jakarta.ws.rs.HeaderParam;
| | import jakarta.ws.rs.POST;
| | import jakarta.ws.rs.Path;
| | import jakarta.ws.rs.Produces;
| | import jakarta.ws.rs.core.Context;
| | import jakarta.ws.rs.core.MediaType;
| | import jakarta.ws.rs.core.Response;
| |
| | import org.apache.commons.lang3.time.DateUtils;
| | import org.apache.logging.log4j.LogManager;
| | import org.apache.logging.log4j.Logger;
| | import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
| |
| | import net.curisit.securis.LicenseGenerator;
| | import net.curisit.securis.LicenseManager;
| | import net.curisit.securis.SeCurisException;
| | import net.curisit.securis.beans.LicenseBean;
| | import net.curisit.securis.beans.RequestBean;
| | import net.curisit.securis.beans.SignedLicenseBean;
| | import net.curisit.securis.beans.StatusBean;
| | import net.curisit.securis.db.BlockedRequest;
| | import net.curisit.securis.db.License;
| | import net.curisit.securis.db.LicenseHistory;
| | import net.curisit.securis.db.LicenseStatus;
| | import net.curisit.securis.db.Pack;
| | import net.curisit.securis.db.PackStatus;
| | import net.curisit.securis.db.User;
| | import net.curisit.securis.db.User.Rol;
| | import net.curisit.securis.ioc.EnsureTransaction;
| | import net.curisit.securis.security.BasicSecurityContext;
| | import net.curisit.securis.security.Securable;
| | import net.curisit.securis.services.exception.SeCurisServiceException;
| | import net.curisit.securis.services.exception.SeCurisServiceException.ErrorCodes;
| | import net.curisit.securis.services.helpers.LicenseHelper;
| | import net.curisit.securis.utils.JsonUtils;
| | import net.curisit.securis.utils.LicUtils;
| | import net.curisit.securis.utils.SignatureHelper;
| | import net.curisit.securis.utils.TokenHelper;
| |
| | /**
| | * External API to be accessed by third parties
| | *
| | * @author roberto <roberto.sanchez@curisit.net>
| | */
| | @Path("/api")
| | public class ApiResource {
| |
| | private static final Logger LOG = LogManager.getLogger(ApiResource.class);
| |
| | @Inject
| | TokenHelper tokenHelper;
| |
| | @Inject
| | private LicenseHelper licenseHelper;
| |
| | @Context
| | EntityManager em;
| |
| | @Inject
| | LicenseGenerator licenseGenerator;
| |
| | public static final String API_CLIENT_USERNAME = "_client";
| |
| | public ApiResource() {
| | }
| |
| | /**
| | *
| | * @return Simple text message to check API status
| | */
| | @GET
| | @Path("/")
| | @Produces({ MediaType.TEXT_PLAIN })
| | public Response index() {
| | return Response.ok("SeCuris API. Date: " + new Date()).build();
| | }
| |
| | /**
| | *
| | * @return Simple text message to check API status
| | */
| | @GET
| | @Path("/ping")
| | @Produces({ MediaType.APPLICATION_JSON })
| | public Response ping() {
| | StatusBean status = new StatusBean();
| | status.setDate(new Date());
| | status.setMessage(LicenseManager.PING_MESSAGE);
| | return Response.ok(status).build();
| | }
| |
| | /**
| | * Request a new license file based in a RequestBean object sent as
| | * parameter
| | *
| | * @param mpfdi
| | * @param bsc
| | * @return
| | * @throws IOException
| | * @throws SeCurisServiceException
| | */
| | @POST
| | @Path("/request")
| | @Consumes(MediaType.APPLICATION_JSON)
| | @Securable(roles = Rol.API_CLIENT)
| | @Produces({ MediaType.APPLICATION_JSON })
| | @EnsureTransaction
| | public Response createFromRequest(RequestBean request, @HeaderParam(LicenseManager.HEADER_LICENSE_NAME_OR_REFERENCE) String nameOrReference,
| | @HeaderParam(LicenseManager.HEADER_LICENSE_EMAIL) String userEmail) throws IOException, SeCurisServiceException, SeCurisException {
| | LOG.info("Request to get license: {}", request);
| | SignedLicenseBean lic = createLicense(request, em, nameOrReference, userEmail);
| |
| | return Response.ok(lic).build();
| | }
| |
| | /**
| | * Returns a License file in JSON format from an uploaded Request file
| | *
| | * @param mpfdi
| | * @param bsc
| | * @return
| | * @throws IOException
| | * @throws SeCurisServiceException
| | * @throws SeCurisException
| | */
| | @POST
| | @Path("/request")
| | @Consumes(MediaType.MULTIPART_FORM_DATA)
| | @Securable(roles = Rol.API_CLIENT)
| | @Produces({ MediaType.APPLICATION_JSON })
| | @EnsureTransaction
| | @SuppressWarnings("unchecked")
| | public Response createFromRequestFile(MultipartFormDataInput mpfdi, @HeaderParam(LicenseManager.HEADER_LICENSE_NAME_OR_REFERENCE) String nameOrReference,
| | @HeaderParam(LicenseManager.HEADER_LICENSE_EMAIL) String userEmail) throws IOException, SeCurisServiceException, SeCurisException {
| | RequestBean req = new RequestBean();
| | req.setAppCode(mpfdi.getFormDataPart("appCode", String.class, null));
| | req.setActivationCode(mpfdi.getFormDataPart("activationCode", String.class, null));
| | req.setPackCode(mpfdi.getFormDataPart("packCode", String.class, null));
| | req.setLicenseTypeCode(mpfdi.getFormDataPart("licenseTypeCode", String.class, null));
| | req.setCustomerCode(mpfdi.getFormDataPart("customerCode", String.class, null));
| | req.setArch(mpfdi.getFormDataPart("arch", String.class, null));
| | req.setCrcLogo(mpfdi.getFormDataPart("crcLogo", String.class, null));
| | req.setMacAddresses(mpfdi.getFormDataPart("macAddresses", List.class, null));
| | req.setOsName(mpfdi.getFormDataPart("osName", String.class, null));
| |
| | return createFromRequest(req, nameOrReference, userEmail);
| | }
| |
| | /**
| | * Create a new License file based in a previous one
| | *
| | * @param request
| | * @param bsc
| | * @return
| | * @throws IOException
| | * @throws SeCurisServiceException
| | * @throws SeCurisException
| | */
| | @POST
| | @Path("/renew")
| | @Consumes(MediaType.APPLICATION_JSON)
| | @Securable(roles = Rol.API_CLIENT)
| | @Produces({ MediaType.APPLICATION_JSON })
| | @EnsureTransaction
| | public Response renewFromPreviousLicense(LicenseBean previousLic, @Context BasicSecurityContext bsc) throws IOException, SeCurisServiceException, SeCurisException {
| | LOG.info("Renew license: {}", previousLic);
| |
| | if (previousLic.getExpirationDate().after(DateUtils.addMonths(new Date(), 1))) {
| | throw new SeCurisServiceException(ErrorCodes.UNNECESSARY_RENEW, "The license is still valid, not ready for renew");
| | }
| |
| | // EntityManager em = emProvider.get();
| | License lic = License.findLicenseByCode(previousLic.getLicenseCode(), em);
| | if (lic == null) {
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_DATA_IS_NOT_VALID, "Current license is missing in DB");
| | }
| |
| | if (lic.getStatus() != LicenseStatus.ACTIVE) {
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_NOT_READY_FOR_RENEW, "Only licenses with status 'Active' can be renew");
| | }
| |
| | SignedLicenseBean signedLic = renewLicense(previousLic, em);
| | LOG.info("Renewed license code: {}, until: {}", signedLic.getLicenseCode(), signedLic.getExpirationDate());
| |
| | return Response.ok(signedLic).build();
| | }
| |
| | /**
| | * License validation on server side, in this case we validate that the
| | * current licenses has not been cancelled and they are still in valid
| | * period. If the pack has reached the end valid period, the license is no
| | * longer valid.
| | *
| | * @param currentLic
| | * @param bsc
| | * @return
| | * @throws IOException
| | * @throws SeCurisServiceException
| | * @throws SeCurisException
| | */
| | @POST
| | @Path("/validate")
| | @Consumes(MediaType.APPLICATION_JSON)
| | @Securable(roles = Rol.API_CLIENT)
| | @Produces({ MediaType.APPLICATION_JSON })
| | @EnsureTransaction
| | public Response validate(LicenseBean currentLic, @Context BasicSecurityContext bsc) throws IOException, SeCurisServiceException, SeCurisException {
| | LOG.info("Validate license: {}", currentLic);
| |
| | if (currentLic.getExpirationDate().before(new Date())) {
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_IS_EXPIRED, "The license is expired");
| | }
| |
| | License existingLic = licenseHelper.getActiveLicenseFromDB(currentLic, em);
| |
| | Pack pack = existingLic.getPack();
| | if (pack.getEndValidDate().before(new Date())) {
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_PACK_IS_NOT_VALID, "The pack end valid date has been reached");
| | }
| | if (pack.getStatus() != PackStatus.ACTIVE) {
| | LOG.error("The Pack {} status is not active, is: {}", pack.getCode(), pack.getStatus());
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_PACK_IS_NOT_VALID, "The pack status is not Active");
| | }
| |
| | try {
| | SignatureHelper.getInstance().validateSignature(currentLic);
| | } catch (SeCurisException ex) {
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_DATA_IS_NOT_VALID, "The license signature is not valid");
| | }
| |
| | return Response.ok(currentLic).build();
| | }
| |
| | /**
| | * Returns a new License file in JSON format based in a previous license
| | * There is 2 /renew services with json input and with upload file
| | *
| | * @param mpfdi
| | * @param bsc
| | * @return
| | * @throws IOException
| | * @throws SeCurisServiceException
| | * @throws SeCurisException
| | */
| | @POST
| | @Path("/renew")
| | @Consumes(MediaType.MULTIPART_FORM_DATA)
| | @Securable(roles = Rol.API_CLIENT)
| | @Produces({ MediaType.APPLICATION_JSON })
| | @EnsureTransaction
| | @SuppressWarnings("unchecked")
| | public Response renewFromLicenseFile(MultipartFormDataInput mpfdi, @Context BasicSecurityContext bsc) throws IOException, SeCurisServiceException, SeCurisException {
| | LicenseBean lic = new LicenseBean();
| |
| | lic.setAppCode(mpfdi.getFormDataPart("appCode", String.class, null));
| | lic.setActivationCode(mpfdi.getFormDataPart("activationName", String.class, null));
| | lic.setAppName(mpfdi.getFormDataPart("appName", String.class, null));
| | lic.setArch(mpfdi.getFormDataPart("arch", String.class, null));
| | lic.setCrcLogo(mpfdi.getFormDataPart("crcLogo", String.class, null));
| | lic.setPackCode(mpfdi.getFormDataPart("packCode", String.class, null));
| | lic.setLicenseTypeCode(mpfdi.getFormDataPart("licenseCode", String.class, null));
| | lic.setCustomerCode(mpfdi.getFormDataPart("customerCode", String.class, null));
| | lic.setMacAddresses(mpfdi.getFormDataPart("macAddresses", List.class, null));
| | lic.setOsName(mpfdi.getFormDataPart("osName", String.class, null));
| | lic.setExpirationDate(mpfdi.getFormDataPart("expirationDate", Date.class, null));
| | LOG.info("Lic expires at: {}", lic.getExpirationDate());
| | if (lic.getExpirationDate().after(DateUtils.addMonths(new Date(), 1))) {
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_NOT_READY_FOR_RENEW, "The license is still valid, not ready for renew");
| | }
| |
| | return renewFromPreviousLicense(lic, bsc);
| | }
| |
| | /**
| | * Creates a new signed license from request data or from previous license
| | * if It's a renew
| | *
| | * @param req
| | * @param em
| | * @param renew
| | * @return
| | * @throws SeCurisServiceException
| | */
| | private SignedLicenseBean createLicense(RequestBean req, EntityManager em, String nameOrReference, String email) throws SeCurisServiceException {
| | License lic = null;
| |
| | if (req.getActivationCode() != null) {
| | lic = License.findLicenseByActivationCode(req.getActivationCode(), em);
| | if (lic == null) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The given activation code is invalid: " + req.getActivationCode());
| | }
| | if (lic.getStatus() == LicenseStatus.ACTIVE) {
| | RequestBean initialRequest;
| | try {
| | initialRequest = JsonUtils.json2object(lic.getRequestData(), RequestBean.class);
| | if (!req.match(initialRequest)) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "There is already an active license for given activation code: " + req.getActivationCode());
| | } else {
| | return JsonUtils.json2object(lic.getLicenseData(), SignedLicenseBean.class);
| | }
| | } catch (SeCurisException e) {
| | LOG.error("Error getting existing license", e);
| | throw new SeCurisServiceException(ErrorCodes.INVALID_FORMAT, "Original request is wrong");
| | }
| | } else {
| | if (req.getAppCode() != null && !req.getAppCode().equals(lic.getPack().getLicenseType().getApplication().getCode())) {
| | LOG.error("Activation code {} belongs to app: {} but was sent by: {}", req.getActivationCode(), lic.getPack().getLicenseType().getApplication().getCode(),
| | req.getAppCode());
| | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The given activation code belongs to a different application: " + req.getActivationCode());
| | }
| | }
| | // We validate if the HW is the same, otherwise an error is
| | // thrown
| | } else {
| | try {
| | lic = License.findValidLicenseByRequestData(JsonUtils.toJSON(req), em);
| | } catch (SeCurisException e1) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_FORMAT, "Request sent is not valid");
| | }
| | if (lic != null) {
| | try {
| | if (lic.getStatus() == LicenseStatus.ACTIVE || lic.getStatus() == LicenseStatus.PRE_ACTIVE) {
| | return JsonUtils.json2object(lic.getLicenseData(), SignedLicenseBean.class);
| | }
| | } catch (SeCurisException e) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_FORMAT, "Error trying to get the license bean from license code: " + lic.getCode());
| | }
| | } else {
| | lic = new License();
| | }
| | }
| |
| | Pack pack;
| | if (lic.getActivationCode() == null) {
| | try {
| | pack = em.createNamedQuery("pack-by-code", Pack.class).setParameter("code", req.getPackCode()).getSingleResult();
| | } catch (NoResultException e) {
| | throw new SeCurisServiceException(ErrorCodes.NOT_FOUND, "No pack found for code: " + req.getPackCode());
| | }
| |
| | if (pack.getNumAvailables() <= 0) {
| | throw new SeCurisServiceException(ErrorCodes.NO_AVAILABLE_LICENSES, "The current pack has no licenses availables");
| | }
| | if (lic.getStatus() == LicenseStatus.REQUESTED && !pack.isLicensePreactivation()) {
| | throw new SeCurisServiceException(ErrorCodes.NO_AVAILABLE_LICENSES, "Current pack doesn't allow license preactivation");
| | }
| |
| | if (!req.getCustomerCode().equals(pack.getOrganization().getCode())) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_LICENSE_REQUEST_DATA, "Customer code is not valid: " + req.getCustomerCode());
| | }
| |
| | if (!req.getLicenseTypeCode().equals(pack.getLicenseTypeCode())) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_LICENSE_REQUEST_DATA, "License type code is not valid: " + req.getLicenseTypeCode());
| | }
| | } else {
| | pack = lic.getPack();
| | }
| | if (pack.getStatus() != PackStatus.ACTIVE) {
| | LOG.error("The Pack {} status is not active, is: {}", pack.getCode(), pack.getStatus());
| | throw new SeCurisServiceException(ErrorCodes.LICENSE_DATA_IS_NOT_VALID, "The pack status is not Active");
| | }
| | SignedLicenseBean signedLicense;
| | try {
| | String licCode;
| | if (lic.getCode() == null) {
| | licCode = LicUtils.getLicenseCode(pack.getCode(), licenseHelper.getNextCodeSuffix(pack.getId(), em));
| | } else {
| | licCode = lic.getCode();
| | }
| | Date expirationDate = licenseHelper.getExpirationDateFromPack(pack, lic.getActivationCode() == null);
| |
| | LicenseBean lb = licenseGenerator.generateLicense(req, licenseHelper.extractPackMetadata(pack.getMetadata()), expirationDate, licCode, pack.getAppName());
| | signedLicense = new SignedLicenseBean(lb);
| | } catch (SeCurisException e) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_LICENSE_REQUEST_DATA, "Error generating license: " + e.toString());
| | }
| | try {
| | lic.setRequestData(JsonUtils.toJSON(req));
| | if (BlockedRequest.isRequestBlocked(lic.getRequestData(), em)) {
| | throw new SeCurisServiceException(ErrorCodes.BLOCKED_REQUEST_DATA, "Given request data is blocked and cannot be activated");
| | }
| | lic.setLicenseData(JsonUtils.toJSON(signedLicense));
| | } catch (SeCurisException e) {
| | LOG.error("Error generating license JSON", e);
| | throw new SeCurisServiceException(ErrorCodes.INVALID_FORMAT, "Error generating license JSON");
| | }
| |
| | lic.setModificationTimestamp(new Date());
| | lic.setExpirationDate(signedLicense.getExpirationDate());
| | User user = em.find(User.class, API_CLIENT_USERNAME);
| | if (lic.getStatus() != LicenseStatus.REQUESTED) {
| | lic.setPack(pack);
| | lic.setCreatedBy(user);
| | lic.setCreationTimestamp(new Date());
| | if (lic.getActivationCode() != null) {
| | lic.setStatus(LicenseStatus.ACTIVE);
| | } else {
| | lic.setStatus(pack.isLicensePreactivation() ? LicenseStatus.PRE_ACTIVE : LicenseStatus.REQUESTED);
| | }
| | lic.setCode(signedLicense.getLicenseCode());
| | lic.setCodeSuffix(LicUtils.getLicenseCodeSuffix(signedLicense.getLicenseCode()));
| | if (lic.getEmail() == null || "".equals(lic.getEmail())) {
| | lic.setEmail(email);
| | }
| | if (lic.getFullName() == null || "".equals(lic.getFullName())) {
| | lic.setFullName(nameOrReference);
| | }
| | if (lic.getId() != null) {
| | em.merge(lic);
| | } else {
| | em.persist(lic);
| | }
| | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.CREATE));
| | if (lic.getActivationCode() != null) {
| | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.ACTIVATE, "Activated by code on creation"));
| | } else {
| | if (pack.isLicensePreactivation()) {
| | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.PRE_ACTIVATE, "Pre-activated on creation"));
| | } else {
| | LOG.warn("License ({}) created, but the pack doesn't allow preactivation", lic.getCode());
| | throw new SeCurisServiceException(ErrorCodes.NO_AVAILABLE_LICENSES, "Current pack doesn't allow license preactivation");
| | }
| | }
| | } else {
| | lic.setStatus(LicenseStatus.PRE_ACTIVE);
| | em.merge(lic);
| | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.PRE_ACTIVATE, "Pre-activated after request"));
| | }
| |
| | return signedLicense;
| | }
| |
| | /**
| | * Creates a new signed license from request data or from previous license
| | * if It's a renew
| | *
| | * @param req
| | * @param em
| | * @param renew
| | * @return
| | * @throws SeCurisServiceException
| | */
| | private SignedLicenseBean renewLicense(LicenseBean previousLicenseBean, EntityManager em) throws SeCurisServiceException {
| |
| | License lic = License.findLicenseByCode(previousLicenseBean.getLicenseCode(), em);
| | if (lic.getStatus() != LicenseStatus.ACTIVE && lic.getStatus() != LicenseStatus.PRE_ACTIVE) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The current license has been cancelled");
| | }
| |
| | Pack pack = lic.getPack();
| | SignedLicenseBean signedLicense;
| | try {
| | String licCode = lic.getCode();
| | Date expirationDate = licenseHelper.getExpirationDateFromPack(pack, false);
| |
| | LicenseBean lb = licenseGenerator.generateLicense(previousLicenseBean, licenseHelper.extractPackMetadata(pack.getMetadata()), expirationDate, licCode,
| | pack.getAppName());
| | signedLicense = new SignedLicenseBean(lb);
| | } catch (SeCurisException e) {
| | throw new SeCurisServiceException(ErrorCodes.INVALID_LICENSE_REQUEST_DATA, "Error generating license: " + e.toString());
| | }
| | try {
| | lic.setRequestData(JsonUtils.toJSON(signedLicense, RequestBean.class));
| | if (BlockedRequest.isRequestBlocked(lic.getRequestData(), em)) {
| | throw new SeCurisServiceException(ErrorCodes.BLOCKED_REQUEST_DATA, "Given request data is blocked and cannot be activated");
| | }
| | lic.setLicenseData(JsonUtils.toJSON(signedLicense));
| | } catch (SeCurisException e) {
| | LOG.error("Error generating license JSON", e);
| | throw new SeCurisServiceException(ErrorCodes.INVALID_FORMAT, "Error generating license JSON");
| | }
| |
| | lic.setModificationTimestamp(new Date());
| | lic.setExpirationDate(signedLicense.getExpirationDate());
| | User user = em.find(User.class, API_CLIENT_USERNAME);
| |
| | lic.setStatus(LicenseStatus.ACTIVE);
| | em.merge(lic);
| | em.persist(licenseHelper.createLicenseHistoryAction(lic, user, LicenseHistory.Actions.RENEW));
| |
| | return signedLicense;
| | }
| | }
|
|