Using Application Protection Library in an application

2024/1/22 |

This article describes how to use Application Protection Library (APL) in an application.

.NET

In most situations, MSBuild and Visual Studio automatically detect and add referenced libraries to .NET projects. If APL needs to be manually added as a reference, follow these steps to add APL as a reference to a .NET project:

  1. Obtain APL

    • When generating the remediated source code archive, Lucent Sky AVM will attempt to add ApplicationProtectionLibrary.dll in the bin directory of the application.
    • Lucent Sky AVM CLI can download APL from CLEAR Engine. For example:

        # Replace <AplPath> with path to download the APL
        $aplPath = "<AplPath>"
        .\SkyAnalyzer.Interface.Console.exe --Interface Maintenance --Method DownloadApl --Framework "DotNet" --AplPath "$aplPath"
      
    • Alternatively, APL can be located in C:\Program Files\Lucent Sky\CLEAR Engine\Resources\ApplicationProtectionLibrary.dll on a server running CLEAR Engine.
  2. Add APL in the reference list

    • MSBuild - open the project file (.*proj) of the project, create a new <Reference> section with the path to ApplicationProtectionLibrary.dll as the value of its <HintPath> tag. For example:

        <ItemGroup>
            <Reference Include="LucentSky.Security.Application">
                <HintPath>bin\ApplicationProtectionLibrary.dll</HintPath>
            </Reference>
        </ItemGroup>
      
    • Visual Studio - right-click on the project node and select Add > Reference. In Reference Manager, select Browse, locate ApplicationProtectionLibrary.dll, then select OK

ECMAScript

To use APL in ECMAScript, include a reference to the ApplicationProtectionLibrary.js file.

  1. Obtain APL

    • Lucent Sky AVM CLI can download APL from CLEAR Engine. For example:

        # Replace <AplPath> with path to download the APL
        $aplPath = "<AplPath>"
        .\SkyAnalyzer.Interface.Console.exe --Interface Maintenance --Method DownloadApl --Framework "StaticWeb" --AplPath "$aplPath"
      

      ApplicationProtectionLibrary.js is included when downloading the APL for any framework that supports ECMAScript, not just the static web framework.

    • APL can be located in C:\Program Files\Lucent Sky\CLEAR Engine\Resources\ApplicationProtectionLibrary.js on a server running CLEAR Engine.

  2. Add reference to APL

    • To use APL in browsers, APL can be loaded using the HTML script tag, ECMAScript module, or other methods.
    • To use APL in Node.js, APL can be loaded using ECMAScript module.

Java

While some build tools detect and add required dependencies automatically, some build tools (such as Maven) requires dependencies to be explicitly added. Follow these steps to add APL as a dependency to a Ant or Maven project:

  1. Obtain APL

    • When generating the remediated source code archive, Lucent Sky AVM will attempt to add ApplicationProtectionLibrary.jar in the lib directory of the application.
    • Lucent Sky AVM CLI can download APL from CLEAR Engine. For example:

        # Replace <AplPath> with path to download the APL
        $aplPath = "<AplPath>"
        .\SkyAnalyzer.Interface.Console.exe --Interface Maintenance --Method DownloadApl --Framework "Java" --AplPath "$aplPath"
      
    • Alternatively, APL can be located in C:\Program Files\Lucent Sky\CLEAR Engine\Resources\ApplicationProtectionLibrary.jar on a server running CLEAR Engine.
  2. Add APL in the dependency list

    • Apache Ant - open the build.xml in the root of the project, and add the path to ApplicationProtectionLibrary.jar in the <classpath> section. For example:

        <classpath>
            <fileset dir="lib">
                <include name="ApplicationProtectionLibrary.jar" />
            </fileset>
        </classpath>
      
    • Apache Maven - open the pom.xml in the root of the project, create a new <dependency> section with the path to ApplicationProtectionLibrary.jar as the value of its <systemPath> tag. For example:

        <dependency>
            <groupId>com.lucentsky.security.application</groupId>
            <artifactId>com.lucentsky.security.application</artifactId>
            <version>1.0</version>
            <type>jar</type>
            <scope>system</scope>
            <systemPath>${project.basedir}/WEB-INF/lib/ApplicationProtectionLibrary.jar</systemPath>
        </dependency>
      

PHP

To use APL in a PHP application, it is recommended to reference ApplicationProtectionLibrary.php using a .htaccess file. This will automatically reference APL in all PHP files. Alternatively, each PHP file that uses APL can reference ApplicationProtectionLibrary.php individually.

  1. Obtain APL

    • When generating the remediated source code archive, Lucent Sky AVM will attempt to add ApplicationProtectionLibrary.php in the root directory of the application.
    • Lucent Sky AVM CLI can download APL from CLEAR Engine. For example:

        # Replace <AplPath> with path to download the APL
        $aplPath = "<AplPath>"
        .\SkyAnalyzer.Interface.Console.exe --Interface Maintenance --Method DownloadApl --Framework "Php" --AplPath "$aplPath"
      
    • Alternatively, APL can be located in C:\Program Files\Lucent Sky\CLEAR Engine\Resources\ApplicationProtectionLibrary.php on a server running CLEAR Engine.
  2. Add reference to APL

    • Add reference to APL with .htaccess

      1. Create a .htaccess file under the root directory of the PHP application, or open the existing .htaccess.
      2. Add the following line to .htaccess:

         php_value auto_prepend_file "/ApplicationProtectionLibrary.php"
        
    • Add reference to APL in an individual PHP file

      1. Open a PHP file that need to reference APL, and insert the following at the beginning of the file:

         <?php require('/ApplicationProtectionLibrary.php'); ?>