| .. | .. |
|---|
| 4 | 4 | import java.io.InputStream; |
|---|
| 5 | 5 | import java.io.UnsupportedEncodingException; |
|---|
| 6 | 6 | |
|---|
| 7 | +import net.curisit.securis.beans.RequestBean; |
|---|
| 8 | +import net.curisit.securis.utils.JsonUtils; |
|---|
| 7 | 9 | import net.curisit.securis.utils.LicUtils; |
|---|
| 8 | 10 | |
|---|
| 9 | 11 | import org.apache.commons.io.IOUtils; |
|---|
| 10 | 12 | |
|---|
| 11 | 13 | public class LicenseValidator { |
|---|
| 12 | 14 | |
|---|
| 15 | + public static LicenseValidator singleton = new LicenseValidator(); |
|---|
| 13 | 16 | private byte[] LOGO_SECRET; |
|---|
| 14 | 17 | |
|---|
| 15 | | - public LicenseValidator() { |
|---|
| 18 | + private LicenseValidator() { |
|---|
| 16 | 19 | try { |
|---|
| 17 | 20 | LOGO_SECRET = "Logo ipsum s3cr3t test áíóú".getBytes("utf-8"); |
|---|
| 18 | 21 | } catch (UnsupportedEncodingException e) { |
|---|
| 19 | 22 | e.printStackTrace(); |
|---|
| 20 | 23 | } |
|---|
| 24 | + } |
|---|
| 25 | + |
|---|
| 26 | + public static LicenseValidator getInstance() { |
|---|
| 27 | + return singleton; |
|---|
| 21 | 28 | } |
|---|
| 22 | 29 | |
|---|
| 23 | 30 | /** |
|---|
| .. | .. |
|---|
| 33 | 40 | return null; |
|---|
| 34 | 41 | } |
|---|
| 35 | 42 | } |
|---|
| 43 | + |
|---|
| 44 | + public void validateLogo(RequestBean reqBean) throws SeCurisException { |
|---|
| 45 | + String currentCRC = getCrcLogo(); |
|---|
| 46 | + if (!currentCRC.equals(reqBean.getCrcLogo())) |
|---|
| 47 | + throw new SeCurisException("License logo validation failed for request data: " + JsonUtils.toJSON(reqBean)); |
|---|
| 48 | + } |
|---|
| 49 | + |
|---|
| 50 | + public void validateHW(RequestBean reqBean, String appCode, String customerCode) throws SeCurisException { |
|---|
| 51 | + RequestBean currentHW = ReqGenerator.getInstance().createRequest(appCode, customerCode); |
|---|
| 52 | + if (!currentHW.match(reqBean)) |
|---|
| 53 | + throw new SeCurisException("Current System info mismatch the License System info: " + JsonUtils.toJSON(reqBean)); |
|---|
| 54 | + } |
|---|
| 55 | + |
|---|
| 36 | 56 | } |
|---|