| .. | .. |
|---|
| 34 | 34 | import net.curisit.securis.db.LicenseHistory; |
|---|
| 35 | 35 | import net.curisit.securis.db.LicenseStatus; |
|---|
| 36 | 36 | import net.curisit.securis.db.Pack; |
|---|
| 37 | +import net.curisit.securis.db.PackStatus; |
|---|
| 37 | 38 | import net.curisit.securis.db.User; |
|---|
| 38 | 39 | import net.curisit.securis.db.User.Rol; |
|---|
| 39 | 40 | import net.curisit.securis.ioc.EnsureTransaction; |
|---|
| .. | .. |
|---|
| 197 | 198 | |
|---|
| 198 | 199 | /** |
|---|
| 199 | 200 | * License validation on server side, in this case we validate that the |
|---|
| 200 | | - * current licenses has not been cancelled. |
|---|
| 201 | + * current licenses has not been cancelled and they are still in valid |
|---|
| 202 | + * period. If the pack has reached the end valid period, the license is no |
|---|
| 203 | + * longer valid. |
|---|
| 201 | 204 | * |
|---|
| 202 | 205 | * @param currentLic |
|---|
| 203 | 206 | * @param bsc |
|---|
| .. | .. |
|---|
| 219 | 222 | throw new SeCurisServiceException(ErrorCodes.LICENSE_IS_EXPIRED, "The license is expired"); |
|---|
| 220 | 223 | } |
|---|
| 221 | 224 | |
|---|
| 225 | + License existingLic = licenseHelper.getActiveLicenseFromDB(currentLic, em); |
|---|
| 226 | + |
|---|
| 227 | + Pack pack = existingLic.getPack(); |
|---|
| 228 | + if (pack.getEndValidDate().before(new Date())) { |
|---|
| 229 | + throw new SeCurisServiceException(ErrorCodes.LICENSE_PACK_IS_NOT_VALID, "The pack end valid date has been reached"); |
|---|
| 230 | + } |
|---|
| 231 | + if (pack.getStatus() != PackStatus.ACTIVE) { |
|---|
| 232 | + LOG.error("The Pack {} status is not active, is: {}", pack.getCode(), pack.getStatus()); |
|---|
| 233 | + throw new SeCurisServiceException(ErrorCodes.LICENSE_PACK_IS_NOT_VALID, "The pack status is not Active"); |
|---|
| 234 | + } |
|---|
| 235 | + |
|---|
| 222 | 236 | try { |
|---|
| 223 | 237 | SignatureHelper.getInstance().validateSignature(currentLic); |
|---|
| 224 | 238 | } catch (SeCurisException ex) { |
|---|
| 225 | 239 | throw new SeCurisServiceException(ErrorCodes.LICENSE_DATA_IS_NOT_VALID, "The license signature is not valid"); |
|---|
| 226 | 240 | } |
|---|
| 227 | | - licenseHelper.assertLicenseStatusIsActive(currentLic, em); |
|---|
| 228 | 241 | |
|---|
| 229 | 242 | return Response.ok(currentLic).build(); |
|---|
| 230 | 243 | } |
|---|
| .. | .. |
|---|
| 353 | 366 | } else { |
|---|
| 354 | 367 | pack = lic.getPack(); |
|---|
| 355 | 368 | } |
|---|
| 369 | + if (pack.getStatus() != PackStatus.ACTIVE) { |
|---|
| 370 | + LOG.error("The Pack {} status is not active, is: {}", pack.getCode(), pack.getStatus()); |
|---|
| 371 | + throw new SeCurisServiceException(ErrorCodes.LICENSE_DATA_IS_NOT_VALID, "The pack status is not Active"); |
|---|
| 372 | + } |
|---|
| 356 | 373 | SignedLicenseBean signedLicense; |
|---|
| 357 | 374 | try { |
|---|
| 358 | 375 | String licCode; |
|---|