Java applet manifest - Allow all Caller-Allowable-Codebase

后端 未结 16 2365
暗喜
暗喜 2020-11-28 02:10

As of Java 7u45 an applet will display a warning message (even if signed with a trusted cert) if a webpage tries to interact with it via javascript and that page isn\'t list

相关标签:
16条回答
  • 2020-11-28 03:13

    I'm finding now that some of my users still get this "mixed signed and unsigned code" warning (due to LiveConnect calls in the web page to the applet) even though I've set Caller-Allowable-Codebase correctly, and the difference between those that get it and those that don't get it is whether they have applet .jar file caching enabled in the client host. Those that allow Java to keep temporary files on the client (i.e., allow applet .jar files to be cached) get the warning, and those that turned caching off (because applet caching has never worked quite right) don't get the warning. Go figure.

    0 讨论(0)
  • 2020-11-28 03:13

    To disable this "Security Warning" popup and other related popups using the Java 8 Update 45 JRE.

    Trusted-Library: true
    Caller-Allowable-Codebase: *.mycompany.com
    

    Note: security warning popup was not disabled with wildcards * and *.com.

    0 讨论(0)
  • 2020-11-28 03:14

    I had the same issue, So I remove Trusted-Library=true from my MANIFEST.MF, work Caller-Allowable-Codebase attribute fine.

    0 讨论(0)
  • 2020-11-28 03:15

    The only solution that I can think of that works with 7u45 and the Trusted-Library versions (7u21, 7u25 and 7u40) is to create two different JARs with different manifests and then detecting the user's version and loading the right one.

    The main version served to versions before 7u21 and 7u45 and up will have the new Caller-Allowable-Codebase and no Trusted-Library entry. The second version produced will have Trusted-Library and will be served only to 7u21, 7u25 and 7u40.

    Here is an ant macro to create the new jar with the modified manifest:

    <macrodef name="addtrustedlibrarytojar">
        <attribute name="jarpath" />
        <attribute name="newjarpath" />
        <sequential>
            <echo>Unzipping @{jarpath} to add Trusted-Library</echo>
            <mkdir dir="build/temp_trusted_library" />
            <unjar src="@{jarpath}" dest="build/temp_trusted_library" />
    
            <echo>Inserting Trusted-Library in manifest</echo>
            <replaceregexp match="^" replace="Trusted-Library: true${line.separator}" flags="s">
                <fileset dir="build/temp_trusted_library/META-INF" includes="MANIFEST.MF"/>
            </replaceregexp>
    
            <echo>Creating @{newjarpath}</echo>
            <zip file="@{newjarpath}" basedir="build/temp_trusted_library" />
    
            <echo>Deleting build/temp_trusted_library directory</echo>
            <delete dir="build/temp_trusted_library" />
        </sequential>
    </macrodef>
    

    Call the macro like this for each JAR that needs the change made:

        <addtrustedlibrarytojar jarpath="dist/myapplet.jar" newjarpath="dist/myapplet_tl.jar" />
    

    Remember to sign the new JAR. If it was signed already this change will invalidate the signature.

    We use the PluginDetect library to detect the version of Java. Just extract PluginDetect_Java_Simple.js and getJavaInfo.jar. This code will get the java version:

    <script type="text/javascript" src="js/PluginDetect_Java_Simple.js"></script>
    <script type="text/javascript">
    var javaVersionDetected = '0';
    function javaDetectionDone(pd) {
        javaVersionDetected = pd.getVersion("Java");
        if (console) console.info('Detected java version: ' + javaVersionDetected);
    }
    PluginDetect.onDetectionDone("Java", javaDetectionDone, "js/getJavaInfo.jar", null);
    </script>
    

    We use javascript to launch our applets so we use this to decide between the standard and trusted-library applets:

            if (javaVersionDetected === '1,7,0,21' || javaVersionDetected === '1,7,0,25' || javaVersionDetected === '1,7,0,40') {
                if (console) console.debug('Using TL applet');
                attribs['archive'] = 'applets/myapplet_tl.jar';
            }
            else {
                if (console) console.debug('Using normal applet');
                attribs['archive'] = 'applets/myapplet.jar';
            }
    
    0 讨论(0)
提交回复
热议问题