Updated Branches:
  refs/heads/0.1.5 66c804e88 -> 8b85fcfc5

Removed license from application


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/cd2eb3d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/cd2eb3d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/cd2eb3d0

Branch: refs/heads/0.1.5
Commit: cd2eb3d056a4042acc5f370ceff7478fb3d1b820
Parents: 40ac54d
Author: Chris Rohr <[email protected]>
Authored: Sun May 5 11:31:33 2013 -0400
Committer: Chris Rohr <[email protected]>
Committed: Sun May 5 11:31:33 2013 -0400

----------------------------------------------------------------------
 blur-admin/app/assets/stylesheets/navigation.scss  |   12 -
 .../app/controllers/application_controller.rb      |    6 +-
 blur-admin/app/helpers/license_helper.rb           |   34 --
 blur-admin/app/views/layouts/application.html.haml |    9 +-
 .../migrate/20130505151503_drop_licenses_table.rb  |   16 +
 blur-admin/db/schema.rb                            |   11 +-
 .../main/java/com/nearinfinity/agent/Agent.java    |   12 -
 .../com/nearinfinity/license/AgentLicense.java     |  278 ---------------
 .../nearinfinity/license/utils/CryptoServices.java |  161 ---------
 .../license/utils/CryptoServicesException.java     |   21 --
 .../com/nearinfinity/license/utils/IssuingKey.java |   31 --
 .../com/nearinfinity/license/AgentLicenseTest.java |   89 -----
 etc/agent.config.sample                            |    3 -
 13 files changed, 20 insertions(+), 663 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-admin/app/assets/stylesheets/navigation.scss
----------------------------------------------------------------------
diff --git a/blur-admin/app/assets/stylesheets/navigation.scss 
b/blur-admin/app/assets/stylesheets/navigation.scss
index 6529310..ced80ef 100644
--- a/blur-admin/app/assets/stylesheets/navigation.scss
+++ b/blur-admin/app/assets/stylesheets/navigation.scss
@@ -73,19 +73,7 @@ $nav-height: 40px;
   @include box-shadow(0 1px 0 lighten($footer-color, 10%) inset);
   text-align: right;
   z-index: 99;
-  &.expiring_license {
-    background-color: $red-state-color;
-    color: $grey-color;
-    p, p a {
-      color: $grey-color;
-    }
-  }
   
-  #license {
-    float: left;
-    margin-top: 15px;
-    margin-left: 50px;
-  }
   #company-info {
     float: right;
     margin-top: 15px;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-admin/app/controllers/application_controller.rb
----------------------------------------------------------------------
diff --git a/blur-admin/app/controllers/application_controller.rb 
b/blur-admin/app/controllers/application_controller.rb
index d4214a1..89f0464 100644
--- a/blur-admin/app/controllers/application_controller.rb
+++ b/blur-admin/app/controllers/application_controller.rb
@@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
   require 'thrift/blur'
   require 'blur_thrift_client'
 
-  helper_method :license, :current_user
+  helper_method :current_user
 
   enable_authorization do |exception|
     if current_user
@@ -33,10 +33,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def license
-    @license ||= License.first
-  end
-
   # Populates the @current_zookeeper instance variable
   def current_zookeeper
     # Find the zookeeper with the given or the stored session id

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-admin/app/helpers/license_helper.rb
----------------------------------------------------------------------
diff --git a/blur-admin/app/helpers/license_helper.rb 
b/blur-admin/app/helpers/license_helper.rb
deleted file mode 100644
index b6070c9..0000000
--- a/blur-admin/app/helpers/license_helper.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module LicenseHelper 
-  def license_text(license)
-    if license
-      days_left_in_license = (license.expires_date - Date.today).to_i
-      text = "Licensed to: #{license.org} on 
#{license.issued_date.strftime('%d %b %Y')}."
-      if days_left_in_license < 0
-        text << " License is expired."
-      elsif days_left_in_license == 0
-        text << " License expires today."
-      elsif days_left_in_license < 30
-        text << " License expires in #{pluralize(days_left_in_license, 
'day')}."
-      end
-      
-      if license.node_overage > 0
-        text << " There #{pluralize_no_count(license.node_overage, 'is')} 
currently #{pluralize(license.node_overage, 'node')} over the licensed amount."
-        if license.grace_period_days_remain < 0
-          text << " Please contact Near Infinity to upgrade the license."
-        else
-          text << " #{pluralize(license.grace_period_days_remain, 'day')} left 
until a new license is needed."
-        end
-      end
-      if license.cluster_overage > 0
-        text << " There #{pluralize_no_count(license.cluster_overage, 'is')} 
currently #{pluralize(license.cluster_overage, 'cluster')} over the licensed 
amount. Please contact Near Infinity to upgrade the license."
-      end
-      text
-    else
-      "No valid license found."
-    end
-  end
-  
-  def footer_class(license)
-    (license.nil? || (license.expires_date - Date.today).to_i < 30 || 
license.cluster_overage > 0) && 'expiring_license'
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-admin/app/views/layouts/application.html.haml
----------------------------------------------------------------------
diff --git a/blur-admin/app/views/layouts/application.html.haml 
b/blur-admin/app/views/layouts/application.html.haml
index 42011c5..d78b0c8 100644
--- a/blur-admin/app/views/layouts/application.html.haml
+++ b/blur-admin/app/views/layouts/application.html.haml
@@ -75,15 +75,10 @@
                                        .alert.alert-error{:class=>type}= 
message
                                -else
                                        .alert.alert-info{:class=>type}= message
-       #ft{:class => footer_class(license)}
-               #license
-                       %p
-                               = license_text(license)
+       #ft
                #company-info
                        %p
                                - if !@current_user.nil?
-                                       %a#page-help{:href => ''} Help  |
-                               Developed by 
-                               %a{:href => "http://www.nearinfinity.com"} Near 
Infinity
+                                       %a#page-help{:href => ''} Help
                                | Version 1.4.2
 #help-menu{:style => 'display: none', "data-controller" => 
params[:controller], "data-action" => params[:action]}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-admin/db/migrate/20130505151503_drop_licenses_table.rb
----------------------------------------------------------------------
diff --git a/blur-admin/db/migrate/20130505151503_drop_licenses_table.rb 
b/blur-admin/db/migrate/20130505151503_drop_licenses_table.rb
new file mode 100644
index 0000000..7659f14
--- /dev/null
+++ b/blur-admin/db/migrate/20130505151503_drop_licenses_table.rb
@@ -0,0 +1,16 @@
+class DropLicensesTable < ActiveRecord::Migration
+  def up
+    drop_table :licenses
+  end
+
+  def down
+    create_table "licenses", :id => false, :force => true do |t|
+      t.string  "org"
+      t.date    "issued_date"
+      t.date    "expires_date"
+      t.integer "node_overage"
+      t.integer "grace_period_days_remain"
+      t.integer "cluster_overage"
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-admin/db/schema.rb
----------------------------------------------------------------------
diff --git a/blur-admin/db/schema.rb b/blur-admin/db/schema.rb
index 41eba90..c8de443 100644
--- a/blur-admin/db/schema.rb
+++ b/blur-admin/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control 
system.
 
-ActiveRecord::Schema.define(:version => 20130106191159) do
+ActiveRecord::Schema.define(:version => 20130505151503) do
 
   create_table "admin_settings", :force => true do |t|
     t.string   "setting",    :null => false
@@ -129,15 +129,6 @@ ActiveRecord::Schema.define(:version => 20130106191159) do
 
   add_index "hdfs_stats", ["hdfs_id"], :name => "index_hdfs_stats_on_hdfs_id"
 
-  create_table "licenses", :id => false, :force => true do |t|
-    t.string  "org"
-    t.date    "issued_date"
-    t.date    "expires_date"
-    t.integer "node_overage"
-    t.integer "grace_period_days_remain"
-    t.integer "cluster_overage"
-  end
-
   create_table "preferences", :force => true do |t|
     t.string   "name"
     t.string   "pref_type"

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-agent/src/main/java/com/nearinfinity/agent/Agent.java
----------------------------------------------------------------------
diff --git a/blur-agent/src/main/java/com/nearinfinity/agent/Agent.java 
b/blur-agent/src/main/java/com/nearinfinity/agent/Agent.java
index 1509872..2c8e253 100644
--- a/blur-agent/src/main/java/com/nearinfinity/agent/Agent.java
+++ b/blur-agent/src/main/java/com/nearinfinity/agent/Agent.java
@@ -28,10 +28,7 @@ import 
com.nearinfinity.agent.connections.cleaners.CleanerDatabaseConnection;
 import com.nearinfinity.agent.connections.hdfs.HdfsDatabaseConnection;
 import 
com.nearinfinity.agent.connections.zookeeper.ZookeeperDatabaseConnection;
 import com.nearinfinity.agent.exceptions.HdfsThreadException;
-import com.nearinfinity.agent.exceptions.InvalidLicenseException;
-import com.nearinfinity.agent.monitor.ThreadController;
 import com.nearinfinity.agent.notifications.Notifier;
-import com.nearinfinity.license.AgentLicense;
 
 public class Agent {
        public static final long COLLECTOR_SLEEP_TIME = 
TimeUnit.SECONDS.toMillis(15);
@@ -47,15 +44,6 @@ public class Agent {
                // Setup the notifier
                Notifier.getNotifier(props, true);
 
-               // Verify valid License
-               try {
-                       AgentLicense.verifyLicense(props, jdbc);
-               } catch (InvalidLicenseException e) {
-                       log.fatal(e.getMessage() + " Exiting.");
-                       ThreadController.stopAllThreads();
-                       return;
-               }
-
                List<String> activeCollectors = 
props.containsKey("active.collectors") ? new 
ArrayList<String>(Arrays.asList(props.getProperty(
                                "active.collectors").split("\\|"))) : new 
ArrayList<String>();
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-agent/src/main/java/com/nearinfinity/license/AgentLicense.java
----------------------------------------------------------------------
diff --git 
a/blur-agent/src/main/java/com/nearinfinity/license/AgentLicense.java 
b/blur-agent/src/main/java/com/nearinfinity/license/AgentLicense.java
deleted file mode 100644
index c8521ec..0000000
--- a/blur-agent/src/main/java/com/nearinfinity/license/AgentLicense.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package com.nearinfinity.license;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-import com.nearinfinity.agent.exceptions.InvalidLicenseException;
-import com.nearinfinity.agent.monitor.ThreadController;
-import com.nearinfinity.license.utils.CryptoServices;
-import com.nearinfinity.license.utils.CryptoServicesException;
-import com.nearinfinity.license.utils.IssuingKey;
-
-public class AgentLicense {
-       private static final Log log = LogFactory.getLog(AgentLicense.class);
-       private static final String PUBLIC_KEY = 
"MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAr70Zcg1WlzllR6xuxJEBuaETSbgAHY6IuZ9lqLWPEdj1I8cQdk28NONmsqMj0jHBjDmqby1YYIsj3+kxib6Ow2rxL/r2EXsdzZxXTdVCDzJMX1JqVSKLqXmbYB7gy9xLqxxDYCVZwTmhAQmhU1KN1PA6IzvyNFcPfG11qyzrfwqAJ+8rA4556KtEe9EbWBPh3PEEqcuq7lQAFXrrr32cvluSVgqgTF2eLYaRyyPxgvBTkFSg4OkdzT2gP+ggiL9SBXA9y6yLZZR2ehMxS5GhS+96n95wLF5CIbg4onefQzZ65/VGwaSeWbPM/8RBUcK/jRC99rNcF6phywJCiKMgJ+u9cj1ThuIBm5LhSs2FreCuDNtUkna4ernk0Ndy1vSpTu0+h5IiMbz2cbfDJq++w8Os7J/Pt3XfgON2cHcJyEEbkzsJ71Z8+lebMydzX/al95FyXDrobuUuUfOVNrXWKqFB+BRIHPTVJo2tP9FGjcxhmj5vHQkGEAh/0n9b93cCBN6e//ft9TP/yELT+lSFJIeJOHj8gUvSFT5JfilTjZLHvLweMR9ZVlfseq1NC8EoYWgpa6PQcUh2PzuTBgoCyRCG4/mIqw45ICuLeS/MwGERJqWpxWPKRpSbklWDrFObOrfaPb+bvKzsPvbf0Q1x+Azqr9d4OSm7DunNAtV85aUCAwEAAQ==";
-       private static final String PRIVATE_KEY = 
"MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQCvvRlyDVaXOWVHrG7EkQG5oRNJuAAdjoi5n2WotY8R2PUjxxB2Tbw042ayoyPS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H44O2is1jLAXq8d1aYuMOz4HYQch7uDrAOrH6C8K8S4ejAdCPbHe58HE+Nhls88LGfRH2yzNYA7LXNp11cCn6q75QIz1Z0tw1pxCm+8W6tfesJKcN9lT4t+iKwAqcfeshRMHuRAZirxJxf3+cd6B9CZj3g9ct4gdCVkzC5VKOL3rSnSbpoCV8mALGwMnIgc3vbvyfaapId44cilEEFbBnYWGo0CggEAMUiH9VJ/Wwdy+JjCpJxWg52BTlnbgqA3rp6v9K3y709/AJZpAzg3zUPvhepgS3/zYgoDquh66tHlVyjcqkImxWMW+/5vLHiel4jba2MQM2UM8VX5s+OlAUGADpJxmsTtqgJ2M3Vr8YM+7/s5TW5Lp1dk6NNZiGdxleILo24PM9qCDLFCuvOmIqfr0StocbAXX8kuU9dv2hekJ4136wuOmDrBgDvJxGPtM80OUYENxoZekeGDqeB71ed8as+9H2plcvR6hKfY12bOzQA5oxXdPQQENlzVmX7HGEx8RPglbSvBVSaWnk/x0zP4zOEKAUd5SrFDdvOcxoyWKbtlHUs6oQKCAQArWk2aj58HPfro+NCgbEm1EFrfnMBVD+oiyiAMJ6st2FNu92VGnHD7sfVhlVjZ0zjqdtSYDKSAisGGHo33oTdYBqCJSESKuQrsiqUgD4U2eY4+jdZ+hBjtKNgSWOZ
 
nd359PtRMjjmdoPFZtVZhS4VoEluEl1uhKE1Dw33E6x36rBKoJOahIHRIgGyX/ItuZYb6wjsEEU3e9Jsc8h5aBuD+AuCltLr3ZCoAxZ0JfTLGA+6xJrChuF+VQjAwPqJoTiFzubL3JP4HBGdDOw6LIl9GXtNl0LvwImdsn4fuKIuGZGSxxBgPyXe22y17Q71DKKQICRC4aZrps2c1DrWIPvzT";
-
-       public static void verifyLicense(Properties props, JdbcTemplate jdbc) 
throws InvalidLicenseException {
-               List<String> licenseFileLines = readLicenseFile(props);
-               String licenseType = licenseFileLines.get(3);
-               verifyLicenseIntegrity(licenseFileLines, licenseType);
-               verifyLicenseValidity(licenseFileLines, licenseType, jdbc, 
props);
-               if ("NODE_YEARLY".equals(licenseType)) {
-                       monitorNodeCount(licenseFileLines, props, jdbc);
-               } else if ("CLUSTER_YEARLY".equals(licenseType)) {
-                       monitorClusterCount(licenseFileLines, jdbc);
-               }
-       }
-
-       private static List<String> readLicenseFile(Properties props) throws 
InvalidLicenseException {
-               String licenseFilePath = props.getProperty("license.file");
-
-               if (StringUtils.isBlank(licenseFilePath)) {
-                       throw new InvalidLicenseException("Missing license.file 
configuration property.");
-               }
-
-               File licenseFile = new File(licenseFilePath);
-               List<String> licenseFileLines = null;
-               try {
-                       licenseFileLines = IOUtils.readLines(new 
FileInputStream(licenseFile));
-               } catch (FileNotFoundException e) {
-                       throw new InvalidLicenseException("Unable to find 
license file (" + licenseFile.getAbsolutePath() + ").");
-               } catch (IOException e) {
-                       throw new InvalidLicenseException("There was a problem 
reading the license file: " + e.getMessage() + ".");
-               }
-               return licenseFileLines;
-       }
-
-       private static void verifyLicenseIntegrity(List<String> 
licenseFileLines, String licenseType) throws InvalidLicenseException {
-               String licenseData = null;
-               String signature = null;
-               if ("YEARLY".equals(licenseType)) {
-                       licenseData = 
StringUtils.join(licenseFileLines.subList(1, 7), "\n");
-                       signature = 
StringUtils.join(licenseFileLines.subList(7, licenseFileLines.size() - 1), 
"\n");
-               } else if ("NODE_YEARLY".equals(licenseType)) {
-                       licenseData = 
StringUtils.join(licenseFileLines.subList(1, 8), "\n");
-                       signature = 
StringUtils.join(licenseFileLines.subList(8, licenseFileLines.size() - 1), 
"\n");
-               } else if ("CLUSTER_YEARLY".equals(licenseType)) {
-                       licenseData = 
StringUtils.join(licenseFileLines.subList(1, 8), "\n");
-                       signature = 
StringUtils.join(licenseFileLines.subList(8, licenseFileLines.size() - 1), 
"\n");
-               } else {
-                       throw new InvalidLicenseException("Invalid license type 
[" + licenseType + "].");
-               }
-
-               CryptoServices cryptoServices = 
CryptoServices.getCryptoServices();
-               IssuingKey issuingKey = new IssuingKey();
-               issuingKey.setDescription("Main");
-               
issuingKey.setPrivateKey(CryptoServices.getCryptoServices().decodeBase64(PRIVATE_KEY));
-               
issuingKey.setPublicKey(CryptoServices.getCryptoServices().decodeBase64(PUBLIC_KEY));
-
-               try {
-                       if 
(!cryptoServices.verify(licenseData.toString().getBytes(), 
cryptoServices.decodeBase64(signature),
-                                       
cryptoServices.getPublicKey(issuingKey.getPublicKey()))) {
-                               throw new InvalidLicenseException("Invalid 
license.");
-                       }
-               } catch (CryptoServicesException e) {
-                       throw new InvalidLicenseException("There was a problem 
decrypting license.");
-               }
-       }
-
-       private static void verifyLicenseValidity(List<String> 
licenseFileLines, String licenseType, JdbcTemplate jdbc, Properties props)
-                       throws InvalidLicenseException {
-               SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-
-               Date expires = null;
-               try {
-                       expires = sdf.parse(licenseFileLines.get(5));
-               } catch (ParseException e) {
-                       throw new InvalidLicenseException("Unable to parse 
expires date.", e);
-               }
-
-               if (StringUtils.endsWith(licenseType, "YEARLY") && 
expires.getTime() < System.currentTimeMillis()) {
-                       throw new InvalidLicenseException("License has 
expired.");
-               }
-
-               jdbc.update("delete from licenses");
-               try {
-                       jdbc.update(
-                                       "insert into licenses (org, 
issued_date, expires_date, node_overage, grace_period_days_remain, 
cluster_overage) values (?,?,?,?,?,?)",
-                                       licenseFileLines.get(1), 
sdf.parse(licenseFileLines.get(4)), expires, 0, 60, 0);
-               } catch (Exception e) {
-                       throw new InvalidLicenseException("Unable to insert 
license into DB.", e);
-               }
-
-               if ("NODE_YEARLY".equals(licenseType)) {
-                       updateNodeOverageInfo(jdbc, licenseFileLines, props);
-               } else if ("CLUSTER_YEARLY".equals(licenseType)) {
-                       updateClusterOverageInfo(jdbc, licenseFileLines);
-               }
-       }
-
-       private static void monitorNodeCount(final List<String> 
licenseFileLines, final Properties props, final JdbcTemplate jdbc) {
-               Thread monitorThread = new Thread(new Runnable() {
-                       @Override
-                       public void run() {
-                               while (true) {
-                                       try {
-                                               
Thread.sleep(TimeUnit.HOURS.toMillis(1));
-                                       } catch (InterruptedException e) {
-                                               break;
-                                       }
-                                       try {
-                                               updateNodeOverageInfo(jdbc, 
licenseFileLines, props);
-                                       } catch (InvalidLicenseException e) {
-                                               log.fatal(e.getMessage() + " 
Stopping node count monitor.");
-                                               
ThreadController.stopAllThreads();
-                                               break;
-                                       }
-                               }
-                       }
-               }, "Node Count Monitor");
-               monitorThread.start();
-               ThreadController.registerThread(monitorThread);
-       }
-
-       private static void monitorClusterCount(final List<String> 
licenseFileLines, final JdbcTemplate jdbc) {
-               Thread monitorThread = new Thread(new Runnable() {
-                       @Override
-                       public void run() {
-                               while (true) {
-                                       try {
-                                               
Thread.sleep(TimeUnit.HOURS.toMillis(1));
-                                       } catch (InterruptedException e) {
-                                               break;
-                                       }
-                                       try {
-                                               updateClusterOverageInfo(jdbc, 
licenseFileLines);
-                                       } catch (InvalidLicenseException e) {
-                                               log.fatal(e.getMessage() + " 
Stopping cluster count monitor.");
-                                               
ThreadController.stopAllThreads();
-                                               break;
-                                       }
-                               }
-                       }
-               }, "Cluster Count Monitor");
-               monitorThread.start();
-               ThreadController.registerThread(monitorThread);
-       }
-
-       private static void updateClusterOverageInfo(JdbcTemplate jdbc, 
List<String> licenseFileLines) throws InvalidLicenseException {
-               int totalClusters = jdbc.queryForInt("select count(1) from 
clusters");
-               int allowedClusters = Integer.parseInt(licenseFileLines.get(7));
-
-               if (totalClusters > allowedClusters) {
-                       jdbc.update("update licenses set cluster_overage=?", 
totalClusters - allowedClusters);
-                       throw new InvalidLicenseException("Too many clusters 
for license.  Request new license to continue collecting information.");
-               }
-       }
-
-       private static void updateNodeOverageInfo(JdbcTemplate jdbc, 
List<String> licenseFileLines, Properties props)
-                       throws InvalidLicenseException {
-               int totalNodes = jdbc
-                               .queryForInt("select a.nodes + b.nodes from 
(select count(1) as nodes from controllers) a, (select count(1) as nodes from 
shards) b");
-               int allowedNodes = Integer.parseInt(licenseFileLines.get(7));
-               Set<String> dates = loadGracePeriodDates(props);
-
-               if (totalNodes > allowedNodes) {
-                       Set<String> newDates = new HashSet<String>(dates);
-                       newDates.add(new 
SimpleDateFormat("yyyyMMdd").format(new Date()));
-
-                       int overage = totalNodes > allowedNodes ? totalNodes - 
allowedNodes : 0;
-                       int graceDays = 60 - dates.size();
-                       jdbc.update("update licenses set node_overage=?, 
grace_period_days_remain=?", overage, graceDays);
-
-                       if (newDates.size() > dates.size()) {
-                               writeGracePeriodDates(props, newDates);
-                       }
-
-                       if (newDates.size() > 60) {
-                               throw new InvalidLicenseException(
-                                               "Too many nodes for license and 
60 day grace period is up.  Request new license to continue collecting 
information.");
-                       }
-               }
-       }
-
-       private static void writeGracePeriodDates(Properties props, Set<String> 
dates) throws InvalidLicenseException {
-               String licenseFilePath = props.getProperty("license.file");
-               File licenseFile = new File(licenseFilePath);
-
-               File graceFile = new File(licenseFile.getParentFile(), 
licenseFile.getName().replace(".lic", ".grc"));
-
-               CryptoServices cryptoServices = 
CryptoServices.getCryptoServices();
-               IssuingKey issuingKey = new IssuingKey();
-               issuingKey.setDescription("Main");
-               
issuingKey.setPrivateKey(CryptoServices.getCryptoServices().decodeBase64(PRIVATE_KEY));
-               
issuingKey.setPublicKey(CryptoServices.getCryptoServices().decodeBase64(PUBLIC_KEY));
-
-               byte[] sig = null;
-               try {
-                       sig = cryptoServices.sign(StringUtils.join(dates, 
',').getBytes(), cryptoServices.getPrivateKey(issuingKey.getPrivateKey()));
-               } catch (CryptoServicesException e) {
-                       throw new InvalidLicenseException("Unable to sign grace 
file contents.", e);
-               }
-               String fileContent = StringUtils.join(dates, ',') + "\n" + 
WordUtils.wrap(cryptoServices.encodeBase64(sig), 50, null, true);
-
-               try {
-                       IOUtils.write(fileContent, new 
FileOutputStream(graceFile));
-               } catch (Exception e) {
-                       throw new InvalidLicenseException("Unable to write 
grace file.", e);
-               }
-       }
-
-       private static Set<String> loadGracePeriodDates(Properties props) 
throws InvalidLicenseException {
-               String licenseFilePath = props.getProperty("license.file");
-               File licenseFile = new File(licenseFilePath);
-
-               File graceFile = new File(licenseFile.getParentFile(), 
licenseFile.getName().replace(".lic", ".grc"));
-               List<String> graceFileLines = null;
-               try {
-                       graceFileLines = IOUtils.readLines(new 
FileInputStream(graceFile));
-               } catch (FileNotFoundException e) {
-                       throw new InvalidLicenseException("Unable to find grace 
period file (" + graceFile.getAbsolutePath() + ").");
-               } catch (IOException e) {
-                       throw new InvalidLicenseException("There was a problem 
reading the grace period file: " + e.getMessage() + ".");
-               }
-
-               if (graceFileLines.isEmpty()) {
-                       throw new InvalidLicenseException("Grace period file 
can not be empty.");
-               }
-
-               CryptoServices cryptoServices = 
CryptoServices.getCryptoServices();
-               IssuingKey issuingKey = new IssuingKey();
-               issuingKey.setDescription("Main");
-               
issuingKey.setPrivateKey(CryptoServices.getCryptoServices().decodeBase64(PRIVATE_KEY));
-               
issuingKey.setPublicKey(CryptoServices.getCryptoServices().decodeBase64(PUBLIC_KEY));
-
-               String dates = graceFileLines.get(0);
-               String signature = StringUtils.join(graceFileLines.subList(1, 
graceFileLines.size()), "\n");
-               try {
-                       if (!cryptoServices.verify(dates.getBytes(), 
cryptoServices.decodeBase64(signature),
-                                       
cryptoServices.getPublicKey(issuingKey.getPublicKey()))) {
-                               throw new InvalidLicenseException("Invalid 
grace period file.");
-                       }
-               } catch (CryptoServicesException e) {
-                       throw new InvalidLicenseException("There was a problem 
decrypting grace period file.");
-               }
-
-               return new 
HashSet<String>(Arrays.asList(StringUtils.split(dates, ",")));
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServices.java
----------------------------------------------------------------------
diff --git 
a/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServices.java 
b/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServices.java
deleted file mode 100644
index e95065c..0000000
--- 
a/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServices.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.nearinfinity.license.utils;
-
-import org.apache.commons.codec.binary.Base64;
-
-import javax.crypto.*;
-import javax.crypto.spec.PBEKeySpec;
-import java.security.*;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.X509EncodedKeySpec;
-import java.security.spec.PKCS8EncodedKeySpec;
-
-public class CryptoServices {
-       public static final String PRIVATE_KEY = "cm_priv";
-       public static final String PRIVATE_KEY_FILE = PRIVATE_KEY + ".key";
-       public static final String PUBLIC_KEY = "cm_pub";
-       public static final String PUBLIC_KEY_FILE = PUBLIC_KEY + ".key";
-
-       public static final String PBE_ALG = "PBEWithSHA1AndDESede";
-
-       public static final String KEY_ALG = "RSA";
-       public static final String SIGN_ALG = "SHA512withRSA";
-
-       public static final String ALG_MODE = "ECB";
-       public static final String ALG_PADDING = "PKCS1Padding";
-
-       public static final String CIPHER_ALG = KEY_ALG + "/" + ALG_MODE + "/" 
+ ALG_PADDING;
-
-       private KeyFactory keyFactory;
-       private Signature signature;
-       private Cipher cipher;
-
-       public static CryptoServices INSTANCE = new CryptoServices();
-
-       public static CryptoServices getCryptoServices() {
-               return INSTANCE;
-       }
-
-       public String encodeBase64(byte[] b) {
-               return new String(Base64.encodeBase64(b));
-       }
-
-       public byte[] decodeBase64(String s) {
-               return Base64.decodeBase64(s.getBytes());
-       }
-
-       public byte[] decrypt(byte[] data, Key key) throws 
CryptoServicesException {
-               try {
-                       getCipher().init(Cipher.DECRYPT_MODE, key);
-                       return cipher.doFinal(data);
-               } catch (InvalidKeyException e) {
-                       throw new CryptoServicesException(e);
-               } catch (BadPaddingException e) {
-                       throw new CryptoServicesException(e);
-               } catch (IllegalBlockSizeException e) {
-                       throw new CryptoServicesException(e);
-               } catch (NoSuchAlgorithmException e) {
-                       throw new CryptoServicesException(e);
-               } catch (NoSuchPaddingException e) {
-                       throw new CryptoServicesException(e);
-               }
-       }
-
-       public byte[] sign(byte[] data, PrivateKey key) throws 
CryptoServicesException {
-               try {
-                       getSignature().initSign(key);
-                       signature.update(data);
-                       return signature.sign();
-               } catch (InvalidKeyException e) {
-                       throw new CryptoServicesException(e);
-               } catch (SignatureException e) {
-                       throw new CryptoServicesException(e);
-               } catch (NoSuchAlgorithmException e) {
-                       throw new CryptoServicesException(e);
-               }
-       }
-
-       public boolean verify(byte[] data, byte[] sig, PublicKey key) throws 
CryptoServicesException {
-               try {
-                       getSignature().initVerify(key);
-                       signature.update(data);
-                       return signature.verify(sig);
-               } catch (InvalidKeyException e) {
-                       throw new CryptoServicesException(e);
-               } catch (SignatureException e) {
-                       throw new CryptoServicesException(e);
-               } catch (NoSuchAlgorithmException e) {
-                       throw new CryptoServicesException(e);
-               }
-       }
-
-       private KeyFactory getKeyFactory() throws NoSuchAlgorithmException {
-               if (keyFactory == null) {
-                       keyFactory = KeyFactory.getInstance(KEY_ALG);
-               }
-               return keyFactory;
-       }
-
-       private Signature getSignature() throws NoSuchAlgorithmException {
-               if (signature == null) {
-                       signature = Signature.getInstance(SIGN_ALG);
-               }
-               return signature;
-       }
-
-       public SecretKey generatePBESecretKey(char[] password, byte[] salt) 
throws CryptoServicesException {
-
-               PBEKeySpec pbeKeySpec = new PBEKeySpec(password);
-               SecretKeyFactory secretKeyFactory = null;
-               try {
-                       secretKeyFactory = 
SecretKeyFactory.getInstance(PBE_ALG);
-                       return secretKeyFactory.generateSecret(pbeKeySpec);
-               } catch (NoSuchAlgorithmException e) {
-                       throw new CryptoServicesException(e);
-               } catch (InvalidKeySpecException e) {
-                       throw new CryptoServicesException(e);
-               }
-       }
-
-       private Cipher getCipher() throws NoSuchAlgorithmException, 
NoSuchPaddingException {
-               cipher = Cipher.getInstance(CIPHER_ALG);
-               return cipher;
-       }
-
-       public final PublicKey getPublicKey(byte[] keyBytes) throws 
CryptoServicesException {
-               X509EncodedKeySpec publicKeySpec = new 
X509EncodedKeySpec(keyBytes);
-               PublicKey publicKey = null;
-               try {
-                       publicKey = 
getKeyFactory().generatePublic(publicKeySpec);
-               } catch (InvalidKeySpecException e) {
-                       throw new CryptoServicesException(e);
-               } catch (NoSuchAlgorithmException e) {
-                       throw new CryptoServicesException(e);
-               }
-               return publicKey;
-
-       }
-
-       public final PrivateKey getPrivateKey(byte[] keyBytes) throws 
CryptoServicesException {
-               PKCS8EncodedKeySpec privateKeySpec = new 
PKCS8EncodedKeySpec(keyBytes);
-               PrivateKey privateKey = null;
-               try {
-                       privateKey = 
getKeyFactory().generatePrivate(privateKeySpec);
-               } catch (InvalidKeySpecException e) {
-                       throw new CryptoServicesException(e);
-               } catch (NoSuchAlgorithmException e) {
-                       throw new CryptoServicesException(e);
-               }
-               return privateKey;
-
-       }
-
-       public KeyPair generateKeyPair() throws NoSuchAlgorithmException {
-               SecureRandom secureRandom = 
SecureRandom.getInstance("SHA1PRNG");
-               KeyPairGenerator kpg = KeyPairGenerator.getInstance(KEY_ALG);
-               kpg.initialize(4096, secureRandom);
-
-               KeyPair keyPair = kpg.generateKeyPair();
-
-               return keyPair;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServicesException.java
----------------------------------------------------------------------
diff --git 
a/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServicesException.java
 
b/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServicesException.java
deleted file mode 100644
index aab6ae7..0000000
--- 
a/blur-agent/src/main/java/com/nearinfinity/license/utils/CryptoServicesException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.nearinfinity.license.utils;
-
-public class CryptoServicesException extends Exception {
-       private static final long serialVersionUID = 5526634448227766102L;
-
-       public CryptoServicesException() {
-               super();
-       }
-
-       public CryptoServicesException(String message) {
-               super(message);
-       }
-
-       public CryptoServicesException(String message, Throwable cause) {
-               super(message, cause);
-       }
-
-       public CryptoServicesException(Throwable cause) {
-               super(cause);
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-agent/src/main/java/com/nearinfinity/license/utils/IssuingKey.java
----------------------------------------------------------------------
diff --git 
a/blur-agent/src/main/java/com/nearinfinity/license/utils/IssuingKey.java 
b/blur-agent/src/main/java/com/nearinfinity/license/utils/IssuingKey.java
deleted file mode 100644
index 00da92d..0000000
--- a/blur-agent/src/main/java/com/nearinfinity/license/utils/IssuingKey.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.nearinfinity.license.utils;
-
-public class IssuingKey {
-       private byte[] privateKey;
-       private byte[] publicKey;
-       private String description;
-
-       public byte[] getPrivateKey() {
-               return privateKey;
-       }
-
-       public void setPrivateKey(byte[] privateKey) {
-               this.privateKey = privateKey;
-       }
-
-       public byte[] getPublicKey() {
-               return publicKey;
-       }
-
-       public void setPublicKey(byte[] publicKey) {
-               this.publicKey = publicKey;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/blur-agent/src/test/java/com/nearinfinity/license/AgentLicenseTest.java
----------------------------------------------------------------------
diff --git 
a/blur-agent/src/test/java/com/nearinfinity/license/AgentLicenseTest.java 
b/blur-agent/src/test/java/com/nearinfinity/license/AgentLicenseTest.java
deleted file mode 100644
index d681e12..0000000
--- a/blur-agent/src/test/java/com/nearinfinity/license/AgentLicenseTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.nearinfinity.license;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.core.io.ClassPathResource;
-
-import com.nearinfinity.AgentBaseTestClass;
-import com.nearinfinity.agent.exceptions.InvalidLicenseException;
-import com.nearinfinity.agent.monitor.ThreadController;
-
-public class AgentLicenseTest extends AgentBaseTestClass {
-       @Before
-       public void setup() {
-               ThreadController.exitOnStop = false;
-       }
-
-       @Test
-       public void testMissingLicenseLocation() {
-               try {
-                       AgentLicense.verifyLicense(new Properties(), jdbc);
-                       fail("Missing file, this should have failed");
-               } catch (InvalidLicenseException e) {
-                       assertEquals("Missing license.file configuration 
property.", e.getMessage());
-               }
-       }
-
-       @Test
-       public void testMissingLicenseFile() {
-               try {
-                       Properties props = new Properties();
-                       props.setProperty("license.file", new 
File("bad.lic").getAbsolutePath());
-                       AgentLicense.verifyLicense(props, jdbc);
-                       fail("Missing file, this should have failed");
-               } catch (InvalidLicenseException e) {
-                       assertEquals("Unable to find license file (" + new 
File("bad.lic").getAbsolutePath() + ").", e.getMessage());
-               }
-       }
-
-       @Test
-       public void testBadLicenseType() {
-               try {
-                       Properties props = new Properties();
-                       props.setProperty("license.file", 
getLicensePath("./invalid_type.lic"));
-                       AgentLicense.verifyLicense(props, jdbc);
-                       fail("Missing file, this should have failed");
-               } catch (InvalidLicenseException e) {
-                       assertEquals("Invalid license type [UNKNOWN].", 
e.getMessage());
-               }
-       }
-
-       @Test
-       public void testInvalidLicense() {
-               try {
-                       Properties props = new Properties();
-                       props.setProperty("license.file", 
getLicensePath("./invalid_matching.lic"));
-                       AgentLicense.verifyLicense(props, jdbc);
-                       fail("Missing file, this should have failed");
-               } catch (InvalidLicenseException e) {
-                       assertEquals("Invalid license.", e.getMessage());
-               }
-       }
-
-//     @Test
-//     public void testInvalidLicenseType() throws InvalidLicenseException {
-//             Properties props = new Properties();
-//             props.setProperty("license.file", 
"/Users/crohr/Projects/nic/blur-tools/license-maker/licenses/NIC-Testing/blur_tools_2011-12-31.lic");
-//
-//             AgentLicense.verifyLicense(props, jdbc);
-//             // AgentLicense.verifyLicense(null, null);
-//     }
-
-
-       private String getLicensePath(String license) {
-               String file = null;
-               try {
-                       file = new 
ClassPathResource(license).getFile().getAbsolutePath();
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               }
-               return file;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/cd2eb3d0/etc/agent.config.sample
----------------------------------------------------------------------
diff --git a/etc/agent.config.sample b/etc/agent.config.sample
index 45acb9d..ca9983d 100644
--- a/etc/agent.config.sample
+++ b/etc/agent.config.sample
@@ -1,6 +1,3 @@
-# License Key
-#license.file=
-
 # Mysql connection information
 #store.url=
 #store.user=

Reply via email to