IoT CAS Frameworks/IOT_Server/Server_Admin_Framework/source/ConsumerAPI/src/java/license/LicenseServiceImpl.java
public String createLicense(String customerName, String productId,
            String licenseType, String timeStamp, String timeZone, String startDate,
            String endDate, String optionalAttribs) {

        int retVal = FAILURE;
        char sep = ',';

        try {

            System.out.println("In License: " + customerName + " " + productId + " " + licenseType + " " + timeStamp + " " + timeZone + " " + endDate + " " + optionalAttribs);
            LicenseDao licenseDao = new LicenseDao(request);

            if (customerName != null) {
                licenseKey = customerName;
            } else {
                System.out.println("createLicense(): customerName is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            //  System.out.println("In License():1 " + licenseKey);
            if (productId != null) {
                licenseKey = licenseKey.concat(productId);
            } else {
                System.out.println("createLicense(): Product id is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            //   System.out.println("In License():2 " + licenseKey);
            if (licenseType != null) {
                licenseKey = licenseKey.concat(licenseType);
            } else {
                System.out.println("createLicense(): License type is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (timeZone != null) {
                licenseKey = licenseKey.concat(timeZone);
            } else {
                System.out.println("createLicense(): TimeZone is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (startDate != null) {
                licenseKey = licenseKey.concat(startDate);
            } else {
                System.out.println("createLicense(): Start Date is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (endDate != null) {
                licenseKey = licenseKey.concat(endDate);
            } else {
                System.out.println("createLicense(): End Date is null");
                return "" + FAILURE;
            }
            //Optional attributes can be null
            if (optionalAttribs != null) {
                licenseKey += sep;
                licenseKey = licenseKey.concat(optionalAttribs);
            } else {
                System.out.println("createLicense(): Optional attributes are null");
            }
            //  System.out.println("In License: " + licenseKey);

            //Read customerId,  productId values into cusId, and prodId
            String scustName = customerName;
            System.out.println("scustName==>" + scustName);
            String sprodId = productId;
            System.out.println("sprodId===>" + sprodId);
            String tStamp = timeStamp;
            System.out.println("License: tStamp=" + tStamp);

            //Encrypt licenseKey here - 14-Jan-2015
            String encryptedLicenseKey = encryptLicenseKey(scustName, sprodId, licenseKey);
            System.out.println("encryptedLicenseKe==>" + encryptedLicenseKey);

            //Insert customerId, productId, licenseKey into database table CustomerInfo.
            if (encryptedLicenseKey != null) {
                retVal = licenseDao.updateCustomerLicense(customerName, sprodId, tStamp, encryptedLicenseKey);
            } else {
                System.out.println("Encrytped key is null. Returning FAILURE...");
                return "" + FAILURE;
            }
            if (retVal != SUCCESS) {
                System.out.println("Could not add license details");
                return "" + FAILURE;
            }
        } catch (NullPointerException e1) {
            e1.getMessage();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Licenses details added successfully");
        return "" + SUCCESS;
    }
/*
     * Input: Label value pairs
     * Description: Builds licenseKey as comma separated string of label-value pairs and stores in
     * the database table CustomerInfoTable
     * Returns: Success or Failure
     */
Label value pairs
Description: Builds licenseKey as comma separated string of label-value pairs and stores in
the database table CustomerInfoTable
Returns: Success or Failure
Label value pairs Description : Builds licenseKey as comma separated string of label - value pairs and stores in the database table CustomerInfoTable Returns : Success or Failure
public String createLicense(String customerName, String productId,
            String licenseType, String timeStamp, String timeZone, String startDate,
            String endDate, String optionalAttribs) {
        int retVal = FAILURE;
        char sep = ',';
        try {
            System.out.println("In License: " + customerName + " " + productId + " " + licenseType + " " + timeStamp + " " + timeZone + " " + endDate + " " + optionalAttribs);
            LicenseDao licenseDao = new LicenseDao(request);
            if (customerName != null) {
                licenseKey = customerName;
            } else {
                System.out.println("createLicense(): customerName is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (productId != null) {
                licenseKey = licenseKey.concat(productId);
            } else {
                System.out.println("createLicense(): Product id is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (licenseType != null) {
                licenseKey = licenseKey.concat(licenseType);
            } else {
                System.out.println("createLicense(): License type is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (timeZone != null) {
                licenseKey = licenseKey.concat(timeZone);
            } else {
                System.out.println("createLicense(): TimeZone is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (startDate != null) {
                licenseKey = licenseKey.concat(startDate);
            } else {
                System.out.println("createLicense(): Start Date is null");
                return "" + FAILURE;
            }
            licenseKey += sep;
            if (endDate != null) {
                licenseKey = licenseKey.concat(endDate);
            } else {
                System.out.println("createLicense(): End Date is null");
                return "" + FAILURE;
            }
            if (optionalAttribs != null) {
                licenseKey += sep;
                licenseKey = licenseKey.concat(optionalAttribs);
            } else {
                System.out.println("createLicense(): Optional attributes are null");
            }
            String scustName = customerName;
            System.out.println("scustName==>" + scustName);
            String sprodId = productId;
            System.out.println("sprodId===>" + sprodId);
            String tStamp = timeStamp;
            System.out.println("License: tStamp=" + tStamp);
            String encryptedLicenseKey = encryptLicenseKey(scustName, sprodId, licenseKey);
            System.out.println("encryptedLicenseKe==>" + encryptedLicenseKey);
            if (encryptedLicenseKey != null) {
                retVal = licenseDao.updateCustomerLicense(customerName, sprodId, tStamp, encryptedLicenseKey);
            } else {
                System.out.println("Encrytped key is null. Returning FAILURE...");
                return "" + FAILURE;
            }
            if (retVal != SUCCESS) {
                System.out.println("Could not add license details");
                return "" + FAILURE;
            }
        } catch (NullPointerException e1) {
            e1.getMessage();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Licenses details added successfully");
        return "" + SUCCESS;
    }
public String createLicense ( String customerName , String productId , String licenseType , String timeStamp , String timeZone , String startDate , String endDate , String optionalAttribs ) { int retVal = FAILURE ; char sep = ',' ; try { System . out . println ( "In License: " + customerName + " " + productId + " " + licenseType + " " + timeStamp + " " + timeZone + " " + endDate + " " + optionalAttribs ) ; LicenseDao licenseDao = new LicenseDao ( request ) ; if ( customerName != null ) { licenseKey = customerName ; } else { System . out . println ( "createLicense(): customerName is null" ) ; return "" + FAILURE ; } licenseKey += sep ; if ( productId != null ) { licenseKey = licenseKey . concat ( productId ) ; } else { System . out . println ( "createLicense(): Product id is null" ) ; return "" + FAILURE ; } licenseKey += sep ; if ( licenseType != null ) { licenseKey = licenseKey . concat ( licenseType ) ; } else { System . out . println ( "createLicense(): License type is null" ) ; return "" + FAILURE ; } licenseKey += sep ; if ( timeZone != null ) { licenseKey = licenseKey . concat ( timeZone ) ; } else { System . out . println ( "createLicense(): TimeZone is null" ) ; return "" + FAILURE ; } licenseKey += sep ; if ( startDate != null ) { licenseKey = licenseKey . concat ( startDate ) ; } else { System . out . println ( "createLicense(): Start Date is null" ) ; return "" + FAILURE ; } licenseKey += sep ; if ( endDate != null ) { licenseKey = licenseKey . concat ( endDate ) ; } else { System . out . println ( "createLicense(): End Date is null" ) ; return "" + FAILURE ; } if ( optionalAttribs != null ) { licenseKey += sep ; licenseKey = licenseKey . concat ( optionalAttribs ) ; } else { System . out . println ( "createLicense(): Optional attributes are null" ) ; } String scustName = customerName ; System . out . println ( "scustName==>" + scustName ) ; String sprodId = productId ; System . out . println ( "sprodId===>" + sprodId ) ; String tStamp = timeStamp ; System . out . println ( "License: tStamp=" + tStamp ) ; String encryptedLicenseKey = encryptLicenseKey ( scustName , sprodId , licenseKey ) ; System . out . println ( "encryptedLicenseKe==>" + encryptedLicenseKey ) ; if ( encryptedLicenseKey != null ) { retVal = licenseDao . updateCustomerLicense ( customerName , sprodId , tStamp , encryptedLicenseKey ) ; } else { System . out . println ( "Encrytped key is null. Returning FAILURE..." ) ; return "" + FAILURE ; } if ( retVal != SUCCESS ) { System . out . println ( "Could not add license details" ) ; return "" + FAILURE ; } } catch ( NullPointerException e1 ) { e1 . getMessage ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } System . out . println ( "Licenses details added successfully" ) ; return "" + SUCCESS ; }
Input: Label value pairs
 Description: Builds licenseKey as comma separated string of label-value pairs and stores in
 the database table CustomerInfoTable
 Returns: Success or Failure
Input : Label value pairs Description : Builds licenseKey as comma separated string of label - value pairs and stores in the database table CustomerInfoTable Returns : Success or Failure
//  System.out.println("In License():1 " + licenseKey);
 //   System.out.println("In License():2 " + licenseKey);
 //Optional attributes can be null
 //  System.out.println("In License: " + licenseKey);
 //Read customerId,  productId values into cusId, and prodId
 //Encrypt licenseKey here - 14-Jan-2015
 //Insert customerId, productId, licenseKey into database table CustomerInfo.
