rsanchez
2015-09-02 58c478551bb9480fdfa7d02edc6e1d941239f810
securis/src/main/java/net/curisit/securis/services/ApiResource.java
....@@ -239,6 +239,7 @@
239239
240240 /**
241241 * Returns a new License file in JSON format based in a previous license
242
+ * There is 2 /renew services with json input and with upload file
242243 *
243244 * @param mpfdi
244245 * @param bsc
....@@ -301,9 +302,7 @@
301302 if (lic.getStatus() != LicenseStatus.ACTIVE && lic.getStatus() != LicenseStatus.PRE_ACTIVE) {
302303 throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The current license has been cancelled");
303304 }
304
- }
305
-
306
- if (!renew) {
305
+ } else {
307306 try {
308307 lic = License.findValidLicenseByRequestData(JsonUtils.toJSON(req), em);
309308 } catch (SeCurisException e1) {
....@@ -334,6 +333,14 @@
334333 }
335334 if (!renew && lic.getStatus() == LicenseStatus.REQUESTED && !pack.isLicensePreactivation()) {
336335 throw new SeCurisServiceException(ErrorCodes.NO_AVAILABLE_LICENSES, "Current pack doesn't allow license preactivation");
336
+ }
337
+
338
+ if (!req.getCustomerCode().equals(pack.getOrganization().getCode())) {
339
+ throw new SeCurisServiceException(ErrorCodes.INVALID_LICENSE_REQUEST_DATA, "Customer code is not valid: " + req.getCustomerCode());
340
+ }
341
+
342
+ if (!req.getLicenseTypeCode().equals(pack.getLicenseTypeCode())) {
343
+ throw new SeCurisServiceException(ErrorCodes.INVALID_LICENSE_REQUEST_DATA, "License type code is not valid: " + req.getLicenseTypeCode());
337344 }
338345
339346 SignedLicenseBean signedLicense;
....@@ -399,5 +406,4 @@
399406
400407 return signedLicense;
401408 }
402
-
403409 }