{
boolean returnValue = false;
try {
SettingsInterface settings = Settings.getInstance();
LicenseInstanceVO licenseInstanceVO = new LicenseInstanceVO();
Properties props = new Properties();
props.setProperty(PROPS_MAC_KEY, settings.getMACAddress());
props.setProperty(PROPS_HOST_NAME_KEY, LicenseUtil.getHostName(dataSource));
props.setProperty(PROPS_TIMESTAMP_KEY, String.valueOf(Calendar.getInstance().getTimeInMillis()));
String licenseKey = LicenseUtil.getLicenseKey(dataSource);
if (null == licenseKey) {
props.setProperty(PROPS_LICENSE_KEY, "");
} else {
props.setProperty(PROPS_LICENSE_KEY, licenseKey);
}
HashMap names = LicenseUtil.getEntityNameAndIndividualName(dataSource);
String entityName = "";
String individualName = "";
if (!names.isEmpty()) {
entityName = (String)names.get("entityName");
individualName =(String)names.get("individualName");
}
props.setProperty(PROPS_ENTITY_KEY, entityName);
props.setProperty(PROPS_INDIVIDUAL_KEY, individualName);
props.setProperty(PROPS_CV_VERSION_KEY, CentraViewConfiguration.getVersion());
logger.debug("fetchLicenseFile: ServerProperties being sent: ");
logger.debug(props);
Key blowfishKey = LicenseUtil.generateBlowfishKey();
byte[] encryptedServerData = LicenseUtil.encryptServerData(blowfishKey, props);
byte[] encryptedBlowfishKey = LicenseUtil.encryptBlowfishKey(blowfishKey);
Byte[] byteArrayServerData = (Byte[])LicenseUtil.convertToObjectArray(encryptedServerData);
Byte[] byteArrayKeyData = (Byte[])LicenseUtil.convertToObjectArray(encryptedBlowfishKey);
byte[] encryptedResponse = LicenseUtil.obtainLicenseFile(byteArrayKeyData, byteArrayServerData);
logger.debug("fetchLicenseFile: Response Size: "+encryptedResponse.length+" bytes.");
if (encryptedResponse.length < 1) {
throw new AxisFault(SERVER_DOWN_MESSAGE);
}
logger.debug("fetchLicenseFile: Writing new license to disk.");
File centraViewLicenseFile = LicenseUtil.getCentraViewLicenseFile(dataSource);
LicenseUtil.writeLicenseFileToDisk(encryptedResponse, centraViewLicenseFile);
logger.debug("fetchLicenseFile: Decrpting License.");
byte[] encryptedLicenseFile = LicenseUtil.getLicenseFromLicenseFile(encryptedResponse);
byte[] encryptedKey = LicenseUtil.getKeyFromLicenseFile(encryptedResponse);
Key newBlowfishKey = LicenseUtil.decryptBlowfishKey(encryptedKey);
Properties licenseFile = LicenseUtil.decryptLicenseFile(newBlowfishKey, encryptedLicenseFile);
logger.debug("fetchLicenseFile: The recieved license file:");
logger.debug(licenseFile);
//do SHA to make sure is valid
//save data to database.
licenseInstanceVO.updateLicenseInformation(licenseFile);