~ubuntu-branches/ubuntu/raring/icedtea-web/raring

« back to all changes in this revision

Viewing changes to netx/net/sourceforge/jnlp/JNLPFile.java

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-04 18:19:46 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20120204181946-jngobgzz4mlen9yl
Tags: 1.2~pre1-0ubuntu1
* Update to hg 20120203, taken from the icedtea-web-1.2 release branch.
* Build separate plugin packages for OpenJDK 6 and OpenJDK 7, needed
  to provide the path to the runtime and the mime description in the plugin.
* Use icedtea-<jre version>-plugin as the name for both plugin packages.
* Remove icedtea-web-1.1.4-npapi-fix.patch, fixed upstream.
* Pass -n to gzip when compressing manpages to be Multi-Arch: same safe.
* Build multiarch packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
 
108
108
    /** the default jvm */
109
109
    protected String defaultArch = null;
 
110
    
 
111
    /** A signed JNLP file is missing from the main jar */
 
112
    private boolean missingSignedJNLP = false;
 
113
    
 
114
    /** JNLP file contains special properties */
 
115
    private boolean containsSpecialProperties = false;
110
116
 
 
117
    /**
 
118
     * List of acceptable properties (not-special)
 
119
     */
 
120
    private String[] generalProperties = SecurityDesc.getJnlpRIAPermissions();
 
121
    
111
122
    { // initialize defaults if security allows
112
123
        try {
113
124
            defaultLocale = Locale.getDefault();
174
185
     * @throws ParseException if the JNLP file was invalid
175
186
     */
176
187
    public JNLPFile(URL location, Version version, boolean strict, UpdatePolicy policy) throws IOException, ParseException {
 
188
        this(location, version, strict, policy, null);
 
189
    }
 
190
    
 
191
    /**
 
192
     * Create a JNLPFile from a URL and a version, checking for updates
 
193
     * using the specified policy.
 
194
     *
 
195
     * @param location the location of the JNLP file
 
196
     * @param version the version of the JNLP file
 
197
     * @param strict whether to enforce the spec when
 
198
     * @param policy the update policy
 
199
     * @param forceCodebase codebase to use if not specified in JNLP file.
 
200
     * @throws IOException if an IO exception occurred
 
201
     * @throws ParseException if the JNLP file was invalid
 
202
     */
 
203
    protected JNLPFile(URL location, Version version, boolean strict, UpdatePolicy policy, URL forceCodebase) throws IOException, ParseException {
177
204
        Node root = Parser.getRootNode(openURL(location, version, policy));
178
 
        parse(root, strict, location);
 
205
        parse(root, strict, location, forceCodebase);
179
206
 
180
207
        //Downloads the original jnlp file into the cache if possible
181
208
        //(i.e. If the jnlp file being launched exist locally, but it
222
249
     * @throws ParseException if the JNLP file was invalid
223
250
     */
224
251
    public JNLPFile(InputStream input, boolean strict) throws ParseException {
225
 
        parse(Parser.getRootNode(input), strict, null);
 
252
        parse(Parser.getRootNode(input), strict, null, null);
226
253
    }
227
254
 
228
255
    /**
574
601
     * @param strict whether to enforce the spec when
575
602
     * @param location the file location or null
576
603
     */
577
 
    private void parse(Node root, boolean strict, URL location) throws ParseException {
 
604
    private void parse(Node root, boolean strict, URL location, URL forceCodebase) throws ParseException {
578
605
        try {
579
606
            //if (location != null)
580
607
            //  location = new URL(location, "."); // remove filename
581
608
 
582
 
            Parser parser = new Parser(this, location, root, strict, true); // true == allow extensions
 
609
            Parser parser = new Parser(this, location, root, strict, true, forceCodebase); // true == allow extensions
583
610
 
584
611
            // JNLP tag information
585
612
            specVersion = parser.getSpecVersion();
592
619
            launchType = parser.getLauncher(root);
593
620
            component = parser.getComponent(root);
594
621
            security = parser.getSecurity(root);
 
622
            
 
623
            checkForSpecialProperties();
 
624
            
595
625
        } catch (ParseException ex) {
596
626
            throw ex;
597
627
        } catch (Exception ex) {
603
633
    }
604
634
 
605
635
    /**
 
636
     * Inspects the JNLP file to check if it contains any special properties
 
637
     */
 
638
    private void checkForSpecialProperties() {
 
639
 
 
640
        for (ResourcesDesc res : resources) {
 
641
            for (PropertyDesc propertyDesc : res.getProperties()) {
 
642
 
 
643
                for (int i = 0; i < generalProperties.length; i++) {
 
644
                    String property = propertyDesc.getKey();
 
645
 
 
646
                    if (property.equals(generalProperties[i])) {
 
647
                        break;
 
648
                    } else if (!property.equals(generalProperties[i])
 
649
                            && i == generalProperties.length - 1) {
 
650
                        containsSpecialProperties = true;
 
651
                        return;
 
652
                    }
 
653
                }
 
654
 
 
655
            }
 
656
        }
 
657
    }
 
658
 
 
659
    /**
606
660
     *
607
661
     * @return true if the JNLP file specifies things that can only be
608
662
     * applied on a new vm (eg: different max heap memory)
674
728
        return new DownloadOptions(usePack, useVersion);
675
729
    }
676
730
 
 
731
    /**
 
732
     * Returns a boolean after determining if a signed JNLP warning should be
 
733
     * displayed in the 'More Information' panel.
 
734
     * 
 
735
     * @return true if a warning should be displayed; otherwise false
 
736
     */
 
737
    public boolean requiresSignedJNLPWarning() {
 
738
        return (missingSignedJNLP && containsSpecialProperties);
 
739
    }
 
740
 
 
741
    /**
 
742
     * Informs that a signed JNLP file is missing in the main jar
 
743
     */
 
744
    public void setSignedJNLPAsMissing() {
 
745
        missingSignedJNLP = true;
 
746
    }
 
747
 
677
748
}