예제 #1
0
 ProductLicense _IKeyStoreProvider.Retrieve(ref string ProductName, IActiveLock.ALLicenseFileTypes mLicenseFileType)
 {
     return(IKeyStoreProvider_Retrieve(ProductName, mLicenseFileType));
 }
예제 #2
0
 void _IKeyStoreProvider.Store(ref ProductLicense Lic, IActiveLock.ALLicenseFileTypes mLicenseFileType)
 {
     IKeyStoreProvider_Store(Lic, mLicenseFileType);
 }
예제 #3
0
    /// <summary>
    /// Retrieves the registered license for the specified product.
    /// </summary>
    /// <param name="ProductName">String - Product or application name</param>
    /// <param name="mLicenseFileType">IActiveLock.ALLicenseFileTypes - License file type!</param>
    /// <returns>ProductLicense - Returns the product license object</returns>
    /// <remarks></remarks>

    private ProductLicense IKeyStoreProvider_Retrieve(ref string ProductName, IActiveLock.ALLicenseFileTypes mLicenseFileType)
    {
        ProductLicense functionReturnValue = null;

        functionReturnValue = null;

        mINIFile.Section = ProductName;

        // ERROR: Not supported in C#: OnErrorStatement

        // No license found
        if (string.IsNullOrEmpty(mINIFile.GetValue(KEY_LICKEY)))
        {
            return;
        }


        // Read the LIC file quickly and decide whether this is a valid LIC file
        string fileText = ActiveLock3_6NET.My.MyProject.Computer.FileSystem.ReadAllText(mINIFile.File);
        string astring  = string.Empty;

        if (string.IsNullOrEmpty(fileText))
        {
            return;
        }

        if (mLicenseFileType == IActiveLock.ALLicenseFileTypes.alsLicenseFileEncrypted)
        {
            astring = modTrial.DecryptString128Bit(fileText, PSWD());
        }
        else
        {
            astring = fileText;
        }
        if (astring.ToLower().Contains("productversion") == false)
        {
            modActiveLock.Set_locale(modActiveLock.regionalSymbol);
            Err().Raise(Globals.ActiveLockErrCodeConstants.AlerrKeyStoreInvalid, modTrial.ACTIVELOCKSTRING, modActiveLock.STRKEYSTOREINVALID);
        }

        ProductLicense Lic = new ProductLicense();

        if (mLicenseFileType == IActiveLock.ALLicenseFileTypes.alsLicenseFileEncrypted & mINIFile.GetValue(KEY_LICCLASS) != "Single" & mINIFile.GetValue(KEY_LICCLASS) != "MultiUser")
        {
            // This was the original idea... to read the file, and encrypt and write again
            // But since this is a stream based operation, it conflicts with the
            // ADS therefore should NOT be used
            //' Read the LIC file
            //Dim stream_reader1 As New IO.StreamReader(mINIFile.File)
            //Dim fileContents1 As String = stream_reader1.ReadToEnd()
            //stream_reader1.Close()
            //' Decrypt the LIC file
            //Dim decryptedFile1 As String
            //decryptedFile1 = DecryptString128Bit(fileContents1, PSWD)
            //' Save the LIC file again
            //Dim stream_writer1 As New IO.StreamWriter(mINIFile.File, False)
            //stream_writer1.Write(decryptedFile1)
            //stream_writer1.Close()

            // Read license properties from INI file section
            {
                Lic.ProductName     = ProductName;
                Lic.ProductVer      = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_PRODVER), PSWD());
                Lic.Licensee        = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_LICENSEE), PSWD()) + "&&&" + Lic.ProductName + " (" + Lic.ProductVer + ")";
                Lic.RegisteredLevel = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_REGISTERED_LEVEL), PSWD());
                Lic.MaxCount        = (int)modTrial.DecryptString128Bit(mINIFile.Values(KEY_MAXCOUNT), PSWD());
                Lic.LicenseType     = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_LICTYPE), PSWD());
                Lic.LicenseClass    = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_LICCLASS), PSWD());
                Lic.LicenseKey      = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_LICKEY), PSWD());
                Lic.Expiration      = modTrial.DecryptString128Bit(mINIFile.GetValue(KEY_EXP), PSWD());
                Lic.RegisteredDate  = modTrial.DecryptString128Bit(mINIFile.Values(KEY_REGISTERED_DATE), PSWD());
                Lic.LastUsed        = modTrial.DecryptString128Bit(mINIFile.Values(KEY_LASTRUN_DATE), PSWD());
                Lic.Hash1           = modTrial.DecryptString128Bit(mINIFile.Values(KEY_LASTRUN_DATE_HASH), PSWD());
                Lic.LicenseCode     = modTrial.DecryptString128Bit(mINIFile.Values(KEY_LICCODE), PSWD());
            }
        }
        // INI file (LIC) is in PLAIN format
        else
        {
            // Read license properties from INI file section
            {
                Lic.ProductName     = ProductName;
                Lic.ProductVer      = mINIFile.GetValue(KEY_PRODVER);
                Lic.Licensee        = mINIFile.GetValue(KEY_LICENSEE) + "&&&" + Lic.ProductName + " (" + Lic.ProductVer + ")";
                Lic.RegisteredLevel = mINIFile.GetValue(KEY_REGISTERED_LEVEL);
                Lic.MaxCount        = (int)mINIFile.Values(KEY_MAXCOUNT);
                Lic.LicenseType     = mINIFile.GetValue(KEY_LICTYPE);
                Lic.LicenseClass    = mINIFile.GetValue(KEY_LICCLASS);
                Lic.LicenseKey      = mINIFile.GetValue(KEY_LICKEY);
                Lic.Expiration      = mINIFile.GetValue(KEY_EXP);
                Lic.RegisteredDate  = mINIFile.Values(KEY_REGISTERED_DATE);
                Lic.LastUsed        = mINIFile.Values(KEY_LASTRUN_DATE);
                Lic.Hash1           = mINIFile.Values(KEY_LASTRUN_DATE_HASH);
                Lic.LicenseCode     = mINIFile.Values(KEY_LICCODE);
                // New in v3.1
            }
        }
        functionReturnValue = Lic;

        return;

InvalidValue:
        modActiveLock.Set_locale(modActiveLock.regionalSymbol);
        Err().Raise(Globals.ActiveLockErrCodeConstants.AlerrKeyStoreInvalid, modTrial.ACTIVELOCKSTRING, modActiveLock.STRKEYSTOREINVALID);
        return(functionReturnValue);
    }
예제 #4
0
    // TODO: Perhaps we need to lock the file first.?
    /// <summary>
    /// Write license properties to INI file section
    /// </summary>
    /// <param name="Lic">ProductLicense - Product license object</param>
    /// <param name="mLicenseFileType">IActiveLock.ALLicenseFileTypes - License file type!</param>
    /// <remarks></remarks>
    private void IKeyStoreProvider_Store(ref ProductLicense Lic, IActiveLock.ALLicenseFileTypes mLicenseFileType)
    {
        string[] arrProdVer     = null;
        string   actualLicensee = null;

        arrProdVer     = Lic.Licensee.Split("&&&");
        actualLicensee = arrProdVer[0];

        // Write license properties to INI file section
        mINIFile.Section = Lic.ProductName;

        if (mLicenseFileType == IActiveLock.ALLicenseFileTypes.alsLicenseFileEncrypted)
        {
            {
                mINIFile.Values(KEY_PRODVER)           = modTrial.EncryptString128Bit(Lic.ProductVer, PSWD());
                mINIFile.Values(KEY_LICTYPE)           = modTrial.EncryptString128Bit(Lic.LicenseType, PSWD());
                mINIFile.Values(KEY_LICCLASS)          = modTrial.EncryptString128Bit(Lic.LicenseClass, PSWD());
                mINIFile.Values(KEY_LICENSEE)          = modTrial.EncryptString128Bit(actualLicensee, PSWD());
                mINIFile.Values(KEY_REGISTERED_LEVEL)  = modTrial.EncryptString128Bit(Lic.RegisteredLevel, PSWD());
                mINIFile.Values(KEY_MAXCOUNT)          = modTrial.EncryptString128Bit((string)Lic.MaxCount, PSWD());
                mINIFile.Values(KEY_LICKEY)            = modTrial.EncryptString128Bit(Lic.LicenseKey, PSWD());
                mINIFile.Values(KEY_REGISTERED_DATE)   = modTrial.EncryptString128Bit(Lic.RegisteredDate, PSWD());
                mINIFile.Values(KEY_LASTRUN_DATE)      = modTrial.EncryptString128Bit(Lic.LastUsed, PSWD());
                mINIFile.Values(KEY_LASTRUN_DATE_HASH) = modTrial.EncryptString128Bit(Lic.Hash1, PSWD());
                mINIFile.Values(KEY_EXP)     = modTrial.EncryptString128Bit(Lic.Expiration, PSWD());
                mINIFile.Values(KEY_LICCODE) = modTrial.EncryptString128Bit(Lic.LicenseCode, PSWD());
            }
        }
        else
        {
            {
                mINIFile.Values(KEY_PRODVER)           = Lic.ProductVer;
                mINIFile.Values(KEY_LICTYPE)           = Lic.LicenseType;
                mINIFile.Values(KEY_LICCLASS)          = Lic.LicenseClass;
                mINIFile.Values(KEY_LICENSEE)          = actualLicensee;
                mINIFile.Values(KEY_REGISTERED_LEVEL)  = Lic.RegisteredLevel;
                mINIFile.Values(KEY_MAXCOUNT)          = (string)Lic.MaxCount;
                mINIFile.Values(KEY_LICKEY)            = Lic.LicenseKey;
                mINIFile.Values(KEY_REGISTERED_DATE)   = Lic.RegisteredDate;
                mINIFile.Values(KEY_LASTRUN_DATE)      = Lic.LastUsed;
                mINIFile.Values(KEY_LASTRUN_DATE_HASH) = Lic.Hash1;
                mINIFile.Values(KEY_EXP)     = Lic.Expiration;
                mINIFile.Values(KEY_LICCODE) = Lic.LicenseCode;
            }
        }

        // This was the original idea... to read the file, and encrypt and write again
        // But since this is a stream based operation, it conflicts with the
        // ADS therefore should NOT be used
        //If mLicenseFileType = IActiveLock.ALLicenseFileTypes.alsLicenseFileEncrypted Then
        //    ' Read the LIC file again
        //    Dim stream_reader2 As New IO.StreamReader(mINIFile.File)
        //    Dim fileContents2 As String = stream_reader2.ReadToEnd()
        //    stream_reader2.Close()
        //    ' Encrypt the file and save it
        //    Dim encryptedFile2 As String
        //    encryptedFile2 = EncryptString128Bit(fileContents2, PSWD)
        //    Dim stream_writer2 As New IO.StreamWriter(mINIFile.File, False)
        //    stream_writer2.Write(encryptedFile2)
        //    stream_writer2.Close()
        //End If
    }
예제 #5
0
    //*   ActiveLock
    //*   Copyright 1998-2002 Nelson Ferraz
    //*   Copyright 2006 The ActiveLock Software Group (ASG)
    //*   All material is the property of the contributing authors.
    //*
    //*   Redistribution and use in source and binary forms, with or without
    //*   modification, are permitted provided that the following conditions are
    //*   met:
    //*
    //*     [o] Redistributions of source code must retain the above copyright
    //*         notice, this list of conditions and the following disclaimer.
    //*
    //*     [o] Redistributions in binary form must reproduce the above
    //*         copyright notice, this list of conditions and the following
    //*         disclaimer in the documentation and/or other materials provided
    //*         with the distribution.
    //*
    //*   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    //*   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    //*   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    //*   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    //*   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    //*   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    //*   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    //*   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    //*   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    //*   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    //*   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //*
    //*
    //===============================================================================
    // Name: RegistryKeyStoreProvider
    // Purpose: This IKeyStoreProvider implementation is used to  maintain the license keys in the registry.
    // Functions:
    // Properties:
    // Methods:
    // Started: 04.21.2005
    // Modified: 08.15.2005
    //===============================================================================
    // @author activelock-admins
    // @version 3.0.0
    // @date 20050815
    //
    //* ///////////////////////////////////////////////////////////////////////
    //  /                        MODULE TO DO LIST                            /
    //  ///////////////////////////////////////////////////////////////////////
    //
    //  ///////////////////////////////////////////////////////////////////////
    //  /                        MODULE CHANGE LOG                            /
    //  ///////////////////////////////////////////////////////////////////////
    //
    //   07.07.03 - mcrute   - Updated the header comments for this file.
    //
    //
    //  ///////////////////////////////////////////////////////////////////////
    //  /                MODULE CODE BEGINS BELOW THIS LINE                   /
    //  ///////////////////////////////////////////////////////////////////////


    //===============================================================================
    // Name: Function IKeyStoreProvider_Retrieve
    // Input:
    //   ProductCode As String - Product (software) code
    // Output:
    //   Productlicense - Product license object
    // Purpose:  Not implemented yet
    // Remarks: None
    //===============================================================================
    private ProductLicense IKeyStoreProvider_Retrieve(ref string ProductCode, IActiveLock.ALLicenseFileTypes mLicenseFileType)
    {
        // TODO: Implement Me
        return(null);
    }
예제 #6
0
 //===============================================================================
 // Name: Sub IKeyStoreProvider_Store
 // Input:
 //    Lic As ProductLicense - Product license object
 // Output: None
 // Purpose: Not implemented yet
 // Remarks: None
 //===============================================================================
 private void IKeyStoreProvider_Store(ref ProductLicense Lic, IActiveLock.ALLicenseFileTypes mLicenseFileType)
 {
     // TODO: Implement Me
 }
예제 #7
0
    //===============================================================================
    // Name: Sub Store
    // Input:
    //   ByRef Lic As ProductLicense - Product license
    // Output: None
    // Purpose: Stores a license.
    // Remarks: None
    //===============================================================================

    public void Store(ref ProductLicense Lic, IActiveLock.ALLicenseFileTypes mLicenseFileType)
    {
    }
예제 #8
0
 //===============================================================================
 // Name: Function Retrieve
 // Input:
 //   ByRef ProductName As String - Product Name
 // Output:
 //   ProductLicense - ProductLicense object matching the specified product name.
 //   If no license found, then <code>Nothing</code> is returned.
 // Purpose: Retrieves license info for the specified product name.
 // Remarks: None
 //===============================================================================
 public ProductLicense Retrieve(ref string ProductName, IActiveLock.ALLicenseFileTypes mLicenseFileType)
 {
     return(null);
 }