|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.common.sys.entity.license; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import de.schlichtherle.license.*; | 
|---|
|  |  |  | import de.schlichtherle.xml.GenericCertificate; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //2. 然后校验自定义的License参数 | 
|---|
|  |  |  | //License中可被允许的参数信息 | 
|---|
|  |  |  | LicenseCheck expectedCheckModel = (LicenseCheck) content.getExtra(); | 
|---|
|  |  |  | //        LicenseCheck expectedCheckModel = (LicenseCheck) content.getExtra(); | 
|---|
|  |  |  | LicenseCheck expectedCheckModel = JSON.parseObject(content.getExtra().toString(), LicenseCheck.class); | 
|---|
|  |  |  | //当前服务器真实的参数信息 | 
|---|
|  |  |  | LicenseCheck serverCheckModel = getServerInfos(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(expectedCheckModel != null && serverCheckModel != null){ | 
|---|
|  |  |  | //校验IP地址 | 
|---|
|  |  |  | if(!checkIpAddress(expectedCheckModel.getIpAddress(),serverCheckModel.getIpAddress())){ | 
|---|
|  |  |  | throw new LicenseContentException("当前服务器的IP没在授权范围内"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //校验Mac地址 | 
|---|
|  |  |  | if(!checkIpAddress(expectedCheckModel.getMacAddress(),serverCheckModel.getMacAddress())){ | 
|---|
|  |  |  | throw new LicenseContentException("当前服务器的Mac地址没在授权范围内"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //校验主板序列号 | 
|---|
|  |  |  | if(!checkSerial(expectedCheckModel.getMainBoardSerial(),serverCheckModel.getMainBoardSerial())){ | 
|---|
|  |  |  | throw new LicenseContentException("当前服务器的主板序列号没在授权范围内"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //校验CPU序列号 | 
|---|
|  |  |  | if(!checkSerial(expectedCheckModel.getCpuSerial(),serverCheckModel.getCpuSerial())){ | 
|---|
|  |  |  | throw new LicenseContentException("当前服务器的CPU序列号没在授权范围内"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            if(!checkIpAddress(expectedCheckModel.getIpAddress(),serverCheckModel.getIpAddress())){ | 
|---|
|  |  |  | //                throw new LicenseContentException("当前服务器的IP没在授权范围内"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            //校验Mac地址 | 
|---|
|  |  |  | //            if(!checkIpAddress(expectedCheckModel.getMacAddress(),serverCheckModel.getMacAddress())){ | 
|---|
|  |  |  | //                throw new LicenseContentException("当前服务器的Mac地址没在授权范围内"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            //校验主板序列号 | 
|---|
|  |  |  | //            if(!checkSerial(expectedCheckModel.getMainBoardSerial(),serverCheckModel.getMainBoardSerial())){ | 
|---|
|  |  |  | //                throw new LicenseContentException("当前服务器的主板序列号没在授权范围内"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            //校验CPU序列号 | 
|---|
|  |  |  | //            if(!checkSerial(expectedCheckModel.getCpuSerial(),serverCheckModel.getCpuSerial())){ | 
|---|
|  |  |  | //                throw new LicenseContentException("当前服务器的CPU序列号没在授权范围内"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //            throw new LicenseContentException("不能获取服务器硬件信息"); | 
|---|
|  |  |  | } | 
|---|