Mixed Signed and Unsigned Code Warning Dialog in Java 1.6u19 and Later

Starting with Java SE 6 Update 19, a new warning dialog is displayed when a program contains both signed and unsigned components (see Mixing Signed and Unsigned Code for more detail)  Even when all client side jars are signed, users may still see this dialog when running Nexaweb applications because of the way Nexaweb plugin jars are packaged and used. To prevent the dialog, unpack, rearrange, re-pack and then sign the plugin jars.

Here are the steps:

  1. Unjar the plugin jar file
    For PluginDataFramework.jar, this will create:

       plugin.xml (keep this)
       PLUGIN-INF (keep this)
       lib - PluginDataFramework-classes.jar (keep this), ognl-2.6.7.jar (delete this - it is not required as it is already in NexawebClient.jar)

  2. Repackage inner classes jar files in the lib folder

    a. Unjar inner classes jarfiles

        For PluginDataFramework-classes.jar, you will get:

           META-INF (delete this)
           com\nexaweb\plugin\data directory structure with classes

    b. Create a folder, nxPlugin-<plugin class name> inside the exploded folder

         For PluginDataFramework-classes, you will have:

            com\nexaweb\plugin\data directory structure with classes
            nxplugin-PluginDataFramework folder

    c. Move plugin.xml to the nxPlugin-<plugin class name> folder

    d. jar plugin classes into plugin classes jar file
         Following the example: PluginDataFramework-classes.jar

    e. Sign the inner plugin classes jar files

    f. Remove exploded folder

  3. If <ui-test> is set to true in nexaweb-client.xml, the debug/plugin classes-debug jar files will be used. Repeat the process above for the debug versions of the jar files..
  4. Jar the main plugin folder.
  5. Create a pre-loaded folder in WebContent/WEB-INF/client/plugins
  6. Copy the repackaged jar files into the pre-loaded folder and delete the jars from plugins
  7. Add tag mapping for plugin.xml in your nexaweb-client.xml:

    nexaweb-client.xml
    <client-tag-mapping>
    	<tag-map-file>classpath://nxplugin-PluginDataFramework/plugin.xml</tag-map-file>
    </client-tag-mapping>

     

    Here is a sample ant task to rearrange and sign Nexaweb plugins jars

    Repackage Plugin jars
    <project default="repackagePluginJars" basedir=".">
        <property name="plugin.build.dir" value="PluginTempDir"/>
        <property name="plugin.dest.dir" value="${build.webcontent.dir}/WEB-INF/client/plugins/pre-loaded"/>
        <property name="plugin.src.dir" value="${build.webcontent.dir}/WEB-INF/client/plugins"/>
        
        <macrodef name="repackagePlugin" description="Repackages the given plugin jar from Nexaweb into a new jar that can be signed.">
            <attribute name="plugin"/>
            <sequential>
                <tempfile property="plugin.build.dir" deleteonexit="true" createfile="false"/>
                <mkdir dir="${plugin.build.dir}" />
                <delete includeemptydirs="true">
                    <!-- clean up the temp directory that might have files from the last run -->
                    <fileset dir="${plugin.build.dir}" includes="**/*" />
                </delete>
            	
                <!--unjar main plugin jar file -->
                <unjar src="${plugin.src.dir}/@{plugin}.jar" dest="${plugin.build.dir}" />
                
            	<!--- repackage classes jar files  -->
                <repackage-classes plugin="@{plugin}" location="${plugin.build.dir}/lib" classname="@{plugin}-classes"/>
                
            	<!-- created pre-loaded folder inside plugins -->
                <mkdir dir="${plugin.dest.dir}" />
                
            	<!--jar up and store jar files in pre-loaded  folder -->
                <jar destfile="${plugin.dest.dir}/@{plugin}.jar" basedir="${plugin.build.dir}"/>
            </sequential>
        </macrodef>
        
        <macrodef name="repackage-classes">
            <attribute name="plugin"/>
            <attribute name="location"/>
            <attribute name="classname"/>
            <sequential>
                <mkdir dir="@{location}/@{classname}" />
                
            	<!-- unjar inner classes jar file-->
                <unjar src="@{location}/@{classname}.jar" dest="@{location}/@{classname}"/>
                
            	<!--delete -classes.jar , ognl.jar files in lib -->
                <delete>
                    <fileset dir="@{location}/" >
                        <include name="**/*.jar"/>
                    </fileset>
                </delete>
                
                <!-- move plugin file to plugin-key folder -->
                <move file="${plugin.build.dir}/plugin.xml" todir="@{location}/@{classname}/nxplugin-@{plugin}" />
                
                <!-- jar up inner classes files -->
                <jar destfile="@{location}/@{classname}.jar" basedir="@{location}/@{classname}">
                    <patternset>
                        <exclude name="**/META-INF/**" />
                        <exclude name="**/*.jar" />
                    </patternset>
                </jar>
                
            	<!--delete exploded folder  -->
                <delete dir="@{location}/@{classname}"/>
                
                <!-- sign inner classes jar file -->
                <signjar alias="${keystore.alias}" keystore="${keystore.file}" storepass="${keystore.password}" lazy="true">
                    <path>
                        <fileset dir="@{location}" includes="**/*.jar" />
                    </path>
                </signjar>
            </sequential>
        </macrodef>
        	
        <macrodef name="delete-files-from-plugin">
            <sequential>
                <delete>
                    <fileset dir="${plugin.src.dir}">
                        <exclude name="**/pre-loaded/**" />
                    </fileset>
                </delete>
            </sequential>
        </macrodef>
        
        <target name="repackagePluginJars" description="Repackages the Nexaweb plugin jars so they can be signed properly" >
            <repackagePlugin plugin="PluginDataFramework"/>
            <repackagePlugin plugin="PluginDataRequest"/>	
            <delete-files-from-plugin/>	     	
        </target>
    </project>