Java applet manifest - Allow all Caller-Allowable-Codebase

后端 未结 16 2496
暗喜
暗喜 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条回答
  •  Happy的楠姐
    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:

    
        
        
        
            Unzipping @{jarpath} to add Trusted-Library
            
            
    
            Inserting Trusted-Library in manifest
            
                
            
    
            Creating @{newjarpath}
            
    
            Deleting build/temp_trusted_library directory
            
        
    
    

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

        
    

    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:

    
    
    

    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';
            }
    

提交回复
热议问题