~ubuntu-branches/ubuntu/oneiric/icedtea-web/oneiric

« back to all changes in this revision

Viewing changes to plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-04-06 13:10:44 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110406131044-6jky8obchc43cf02
Tags: 1.1~20110406-0ubuntu1
Fix typo in icedtea-netx postinst to install the javaws alternative.

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
            c = Class.forName(name);
182
182
        } catch (ClassNotFoundException cnfe) {
183
183
 
184
 
            PluginDebug.debug("Class " + name + " not found in primordial loader. Looking in " + cl);
 
184
            PluginDebug.debug("Class ", name, " not found in primordial loader. Looking in ", cl);
185
185
            try {
186
186
                c = cl.loadClass(name);
187
187
            } catch (ClassNotFoundException e) {
225
225
    private static Hashtable<ClassLoader, URL> classLoaders = new Hashtable<ClassLoader, URL>();
226
226
    private static Hashtable<Integer, ClassLoader> instanceClassLoaders = new Hashtable<Integer, ClassLoader>();
227
227
 
228
 
    // FIXME: make private
229
 
    public PluginObjectStore store = new PluginObjectStore();
 
228
    private PluginObjectStore store = PluginObjectStore.getInstance();
230
229
    private Throwable throwable = null;
231
230
    private ClassLoader liveconnectLoader = ClassLoader.getSystemClassLoader();
232
231
    int identifier = 0;
294
293
    }
295
294
 
296
295
    public void associateSrc(ClassLoader cl, URL src) {
297
 
        PluginDebug.debug("Associating " + cl + " with " + src);
 
296
        PluginDebug.debug("Associating ", cl, " with ", src);
298
297
        this.classLoaders.put(cl, src);
299
298
    }
300
299
 
301
300
    public void associateInstance(Integer i, ClassLoader cl) {
302
 
        PluginDebug.debug("Associating " + cl + " with instance " + i);
 
301
        PluginDebug.debug("Associating ", cl, " with instance ", i);
303
302
        this.instanceClassLoaders.put(i, cl);
304
303
    }
305
304
 
329
328
                String[] args = message.split(" ");
330
329
                Integer instance = new Integer(args[1]);
331
330
                String className = args[2].replace('/', '.');
332
 
                PluginDebug.debug("Searching for class " + className + " in " + cl);
 
331
                PluginDebug.debug("Searching for class ", className, " in ", cl);
333
332
 
334
333
                try {
335
334
                    c = cl.loadClass(className);
338
337
                } catch (ClassNotFoundException cnfe) {
339
338
 
340
339
                    cl = this.instanceClassLoaders.get(instance);
341
 
                    PluginDebug.debug("Not found. Looking in " + cl);
 
340
                    PluginDebug.debug("Not found. Looking in ", cl);
342
341
 
343
342
                    if (instance != 0 && cl != null) {
344
343
                        try {
381
380
                    o = m = c.getMethod(methodName, signature.getClassArray());
382
381
                    store.reference(m);
383
382
                }
384
 
                PluginDebug.debug(o + " has id " + store.getIdentifier(o));
 
383
                PluginDebug.debug(o, " has id ", store.getIdentifier(o));
385
384
                write(reference, args[0] + " " + store.getIdentifier(o));
386
385
            } else if (message.startsWith("GetStaticFieldID")
387
386
                                        || message.startsWith("GetFieldID")) {
392
391
 
393
392
                Class<?> c = (Class<?>) store.getObject(classID);
394
393
 
395
 
                PluginDebug.debug("GetStaticFieldID/GetFieldID got class=" + c.getName());
 
394
                PluginDebug.debug("GetStaticFieldID/GetFieldID got class=", c.getName());
396
395
 
397
396
                Field f = null;
398
397
                f = c.getField(fieldName);
631
630
                arguments[1] = methodName;
632
631
                for (int i = 0; i < args.length - 3; i++) {
633
632
                    arguments[i + 2] = store.getObject(parseCall(args[3 + i], null, Integer.class));
634
 
                    PluginDebug.debug("GOT ARG: " + arguments[i + 2]);
 
633
                    PluginDebug.debug("GOT ARG: ", arguments[i + 2]);
635
634
                }
636
635
 
637
636
                Object[] matchingMethodAndArgs = MethodOverloadResolver.getMatchingMethod(arguments);
652
651
                    collapsedArgs += " " + arg;
653
652
                }
654
653
 
655
 
                PluginDebug.debug("Calling method " + m + " on object " + o
656
 
                                                + " (" + c + ") with " + collapsedArgs);
 
654
                PluginDebug.debug("Calling method ", m, " on object ", o
 
655
                                                , " (", c, ") with ", collapsedArgs);
657
656
 
658
657
                AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
659
658
                checkPermission(src, c, acc);
683
682
                    retO = m.getReturnType().toString();
684
683
                }
685
684
 
686
 
                PluginDebug.debug("Calling " + m + " on " + o + " with "
687
 
                                                + collapsedArgs + " and that returned: " + ret
688
 
                                                + " of type " + retO);
 
685
                PluginDebug.debug("Calling ", m, " on ", o, " with "
 
686
                                                , collapsedArgs, " and that returned: ", ret
 
687
                                                , " of type ", retO);
689
688
 
690
689
                if (m.getReturnType().equals(java.lang.Void.class) ||
691
690
                                    m.getReturnType().equals(java.lang.Void.TYPE)) {
799
798
                                                                        + Integer
800
799
                                                                                        .toString(((int) b[i]) & 0x0ff, 16));
801
800
 
802
 
                PluginDebug.debug("Java: GetStringChars: " + o);
803
 
                PluginDebug.debug("  String BYTES: " + buf);
 
801
                PluginDebug.debug("Java: GetStringChars: ", o);
 
802
                PluginDebug.debug("  String BYTES: ", buf);
804
803
                write(reference, "GetStringChars " + buf);
805
804
            } else if (message.startsWith("GetToStringValue")) {
806
805
                String[] args = message.split(" ");
965
964
                for (int i = 0; i < args.length - 2; i++) {
966
965
                    arguments[i + 1] = store.getObject(parseCall(args[2 + i],
967
966
                            null, Integer.class));
968
 
                    PluginDebug.debug("GOT ARG: " + arguments[i + 1]);
 
967
                    PluginDebug.debug("GOT ARG: ", arguments[i + 1]);
969
968
                }
970
969
 
971
970
                Object[] matchingConstructorAndArgs = MethodOverloadResolver
990
989
                    collapsedArgs += " " + arg.toString();
991
990
                }
992
991
 
993
 
                PluginDebug.debug("Calling constructor on class " + c +
994
 
                                   " with " + collapsedArgs);
 
992
                PluginDebug.debug("Calling constructor on class ", c,
 
993
                                   " with ", collapsedArgs);
995
994
 
996
995
                AccessControlContext acc = callContext != null ? callContext : getClosedAccessControlContext();
997
996
                checkPermission(src, c, acc);
1014
1013
                write(reference, "NewObject " + store.getIdentifier(ret));
1015
1014
 
1016
1015
            } else if (message.startsWith("NewStringUTF")) {
1017
 
                PluginDebug.debug("MESSAGE: " + message);
 
1016
                PluginDebug.debug("MESSAGE: ", message);
1018
1017
                String[] args = message.split(" ");
1019
1018
                int length = new Integer(args[1]);
1020
1019
                byte[] byteArray = new byte[length];
1028
1027
                }
1029
1028
 
1030
1029
                ret = new String(byteArray, "UTF-8");
1031
 
                PluginDebug.debug("NEWSTRINGUTF: " + ret);
 
1030
                PluginDebug.debug("NEWSTRINGUTF: ", ret);
1032
1031
 
1033
1032
                store.reference(ret);
1034
1033
                write(reference, "NewStringUTF " + store.getIdentifier(ret));
1035
1034
            } else if (message.startsWith("NewString")) {
1036
 
                PluginDebug.debug("MESSAGE: " + message);
 
1035
                PluginDebug.debug("MESSAGE: ", message);
1037
1036
                String[] args = message.split(" ");
1038
1037
                Integer strlength = parseCall(args[1], null, Integer.class);
1039
1038
                int bytelength = 2 * strlength;
1041
1040
                String ret = null;
1042
1041
                for (int i = 0; i < strlength; i++) {
1043
1042
                    int c = parseCall(args[2 + i], null, Integer.class);
1044
 
                    PluginDebug.debug("char " + i + " " + c);
 
1043
                    PluginDebug.debug("char ", i, " ", c);
1045
1044
                    // Low.
1046
1045
                    byteArray[2 * i] = (byte) (c & 0x0ff);
1047
1046
                    // High.
1048
1047
                    byteArray[2 * i + 1] = (byte) ((c >> 8) & 0x0ff);
1049
1048
                }
1050
1049
                ret = new String(byteArray, 0, bytelength, "UTF-16LE");
1051
 
                PluginDebug.debug("NEWSTRING: " + ret);
 
1050
                PluginDebug.debug("NEWSTRING: ", ret);
1052
1051
 
1053
1052
                store.reference(ret);
1054
1053
                write(reference, "NewString " + store.getIdentifier(ret));
1055
1054
 
1056
1055
            } else if (message.startsWith("ExceptionOccurred")) {
1057
 
                PluginDebug.debug("EXCEPTION: " + throwable);
 
1056
                PluginDebug.debug("EXCEPTION: ", throwable);
1058
1057
                if (throwable != null)
1059
1058
                    store.reference(throwable);
1060
1059
                write(reference, "ExceptionOccurred "
1132
1131
    }
1133
1132
 
1134
1133
    private void write(int reference, String message) {
1135
 
        PluginDebug.debug("appletviewer writing " + message);
 
1134
        PluginDebug.debug("appletviewer writing ", message);
1136
1135
        streamhandler.write("context " + identifier + " reference " + reference
1137
1136
                                + " " + message);
1138
1137
    }