Skip to content

Commit

Permalink
Added license for EC2
Browse files Browse the repository at this point in the history
  • Loading branch information
skavanagh committed Dec 13, 2018
1 parent a2d45e7 commit 2367151
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/io/bastillion/common/db/DBInitServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
package io.bastillion.common.db;

import io.bastillion.common.util.AppConfig;
import io.bastillion.manage.db.LicenseDB;
import io.bastillion.manage.model.Auth;
import io.bastillion.manage.util.DBUtils;
import io.bastillion.manage.util.EncryptionUtil;
import io.bastillion.manage.util.LicenseUtil;
import io.bastillion.manage.util.SSHUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.RandomStringUtils;
Expand Down Expand Up @@ -140,6 +142,7 @@ public void init(ServletConfig config) throws ServletException {
if(StringUtils.isNotEmpty(str)) {
defaultPassword = EncryptionUtil.hash(str.trim() + salt);
}
LicenseDB.saveLicense(LicenseUtil.generateForEC2());
}

//insert default admin user
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/bastillion/manage/util/LicenseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class LicenseUtil {

Expand Down Expand Up @@ -54,6 +55,7 @@ public static boolean isValid(String license) {

/**
* returns the license expiration
*
* @param license encrypted license string
* @return license expiration
*/
Expand All @@ -70,4 +72,19 @@ public static String getExpirationDt(String license) {
}
return null;
}

/**
* returns the license for running in ec2
*
* @return license text
*/
public static String generateForEC2() {
Calendar cal = new GregorianCalendar();
cal.add(Calendar.YEAR, 50);
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

return EncryptionUtil.encrypt(k, "[email protected]" + sdf.format(cal.getTime()));

}

}

0 comments on commit 2367151

Please sign in to comment.