use of org.voltdb.licensetool.LicenseApi in project voltdb by VoltDB.
the class MockVoltDB method getLicenseApi.
@Override
public LicenseApi getLicenseApi() {
return new LicenseApi() {
@Override
public boolean initializeFromFile(File license) {
return true;
}
@Override
public boolean isAnyKindOfTrial() {
return false;
}
@Override
public boolean isProTrial() {
return false;
}
@Override
public boolean isEnterpriseTrial() {
return false;
}
@Override
public int maxHostcount() {
return Integer.MAX_VALUE;
}
@Override
public Calendar expires() {
Calendar result = Calendar.getInstance();
// good enough?
result.add(Calendar.YEAR, 20);
return result;
}
@Override
public boolean verify() {
return true;
}
@Override
public boolean isDrReplicationAllowed() {
// hardcoded to false, too.
return false;
}
@Override
public boolean isDrActiveActiveAllowed() {
// zmq ports for the DR replicator.
return false;
}
@Override
public boolean isCommandLoggingAllowed() {
return true;
}
@Override
public boolean isAWSMarketplace() {
return false;
}
@Override
public boolean isEnterprise() {
return false;
}
@Override
public boolean isPro() {
return false;
}
@Override
public String licensee() {
return null;
}
@Override
public Calendar issued() {
return null;
}
@Override
public String note() {
return null;
}
@Override
public boolean hardExpiration() {
return false;
}
@Override
public boolean secondaryInitialization() {
return true;
}
};
}
use of org.voltdb.licensetool.LicenseApi in project voltdb by VoltDB.
the class MiscUtils method licenseApiFactory.
/**
* Instantiate the license api impl based on enterprise/community editions
* For enterprise edition, look in default locations ./, ~/, jar file directory
* @return a valid API for community and pro editions, or null on error.
*/
public static LicenseApi licenseApiFactory() {
String licensePath = System.getProperty("user.dir") + "/" + licenseFileName;
LicenseApi licenseApi = MiscUtils.licenseApiFactory(licensePath);
if (licenseApi == null) {
try {
// Get location of jar file
String jarLoc = VoltDB.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
// Strip of file name
int lastSlashOff = jarLoc.lastIndexOf("/");
if (lastSlashOff == -1) {
// Jar is at root directory
licensePath = "/" + licenseFileName;
} else {
licensePath = jarLoc.substring(0, lastSlashOff + 1) + licenseFileName;
}
licenseApi = MiscUtils.licenseApiFactory(licensePath);
} catch (URISyntaxException e) {
}
}
if (licenseApi == null) {
licensePath = System.getProperty("user.home") + "/" + licenseFileName;
licenseApi = MiscUtils.licenseApiFactory(licensePath);
}
if (licenseApi != null) {
hostLog.info("Searching for license file located " + licensePath);
}
return licenseApi;
}
use of org.voltdb.licensetool.LicenseApi in project voltdb by VoltDB.
the class MiscUtils method licenseApiFactory.
/**
* Instantiate the license api impl based on enterprise/community editions
* @return a valid API for community and pro editions, or null on error.
*/
public static LicenseApi licenseApiFactory(String pathToLicense) {
if (MiscUtils.isPro() == false) {
return new LicenseApi() {
@Override
public boolean initializeFromFile(File license) {
return true;
}
@Override
public boolean isAnyKindOfTrial() {
return false;
}
@Override
public boolean isProTrial() {
return false;
}
@Override
public boolean isEnterpriseTrial() {
return false;
}
@Override
public int maxHostcount() {
return Integer.MAX_VALUE;
}
@Override
public Calendar expires() {
Calendar result = Calendar.getInstance();
// good enough?
result.add(Calendar.YEAR, 20);
return result;
}
@Override
public boolean verify() {
return true;
}
@Override
public boolean isDrReplicationAllowed() {
return false;
}
@Override
public boolean isDrActiveActiveAllowed() {
return false;
}
@Override
public boolean isCommandLoggingAllowed() {
return false;
}
@Override
public boolean isAWSMarketplace() {
return false;
}
@Override
public boolean isEnterprise() {
return false;
}
@Override
public boolean isPro() {
return false;
}
@Override
public String licensee() {
return "VoltDB Community Edition User";
}
@Override
public Calendar issued() {
Calendar result = Calendar.getInstance();
return result;
}
@Override
public String note() {
return "";
}
@Override
public boolean hardExpiration() {
return false;
}
@Override
public boolean secondaryInitialization() {
return true;
}
};
}
// boilerplate to create a license api interface
LicenseApi licenseApi = null;
Class<?> licApiKlass = MiscUtils.loadProClass("org.voltdb.licensetool.LicenseApiImpl", "License API", false);
if (licApiKlass != null) {
try {
licenseApi = (LicenseApi) licApiKlass.newInstance();
} catch (InstantiationException e) {
hostLog.fatal("Unable to process license file: could not create license API.");
return null;
} catch (IllegalAccessException e) {
hostLog.fatal("Unable to process license file: could not create license API.");
return null;
}
}
if (licenseApi == null) {
hostLog.fatal("Unable to load license file: could not create License API.");
return null;
}
// verify the license file exists.
File licenseFile = new File(pathToLicense);
if (licenseFile.exists() == false) {
return null;
}
hostLog.info("Found VoltDB license file at path: " + pathToLicense);
// Initialize the API. This parses the file but does NOT verify signatures.
if (licenseApi.initializeFromFile(licenseFile) == false) {
hostLog.fatal("Unable to load license file: could not parse license.");
return null;
}
// Perform signature verification - detect modified files
try {
if (licenseApi.verify() == false) {
hostLog.fatal("Unable to load license file: could not verify license signature.");
return null;
}
} catch (LicenseException lex) {
hostLog.fatal(lex.getMessage());
return null;
}
return licenseApi;
}
Aggregations